Skip to content

Commit fa8a6f4

Browse files
committed
Adding long() for compatibility
1 parent 0727747 commit fa8a6f4

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

googleapiclient/discovery.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
from oauth2client.util import _add_query_parameter
8080
from oauth2client.util import positional
8181

82+
import sys
83+
if sys.version > '3':
84+
long = int
8285

8386
# The client library requires a version of httplib2 that supports RETRIES.
8487
httplib2.RETRIES = 1
@@ -339,7 +342,7 @@ def _media_size_to_long(maxSize):
339342
The size as an integer value.
340343
"""
341344
if len(maxSize) < 2:
342-
return 0L
345+
return long(0)
343346
units = maxSize[-2:].upper()
344347
bit_shift = _MEDIA_SIZE_BIT_SHIFTS.get(units)
345348
if bit_shift is not None:
@@ -436,7 +439,7 @@ def _fix_up_media_upload(method_desc, root_desc, path_url, parameters):
436439
accepted for media upload. Defaults to empty list if not in the
437440
discovery document.
438441
- max_size is a long representing the max size in bytes allowed for a
439-
media upload. Defaults to 0L if not in the discovery document.
442+
media upload. Defaults to long(0) if not in the discovery document.
440443
- media_path_url is a String; the absolute URI for media upload for the
441444
API method. Constructed using the API root URI and service path from
442445
the discovery document and the relative path for the API method. If
@@ -481,7 +484,7 @@ def _fix_up_method_description(method_desc, root_desc):
481484
accepted for media upload. Defaults to empty list if not in the
482485
discovery document.
483486
- max_size is a long representing the max size in bytes allowed for a
484-
media upload. Defaults to 0L if not in the discovery document.
487+
media upload. Defaults to long(0) if not in the discovery document.
485488
- media_path_url is a String; the absolute URI for media upload for the
486489
API method. Constructed using the API root URI and service path from
487490
the discovery document and the relative path for the API method. If

tests/test_discovery.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777

7878
import uritemplate
7979

80+
import sys
81+
if sys.version > '3':
82+
long = int
8083

8184
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
8285

@@ -258,7 +261,7 @@ def test_fix_up_method_description_get(self):
258261
http_method = 'GET'
259262
method_id = 'bigquery.query'
260263
accept = []
261-
max_size = 0L
264+
max_size = long(0)
262265
media_path_url = None
263266
self.assertEqual(result, (path_url, http_method, method_id, accept,
264267
max_size, media_path_url))
@@ -270,7 +273,7 @@ def test_fix_up_method_description_insert(self):
270273
http_method = 'POST'
271274
method_id = 'zoo.animals.insert'
272275
accept = ['image/png']
273-
max_size = 1024L
276+
max_size = long(1024)
274277
media_path_url = 'https://www.googleapis.com/upload/zoo/v1/animals'
275278
self.assertEqual(result, (path_url, http_method, method_id, accept,
276279
max_size, media_path_url))

0 commit comments

Comments
 (0)