Skip to content

Commit

Permalink
Using str instead of repr for multipart boundary.
Browse files Browse the repository at this point in the history
This is because in Python 2.7, the `repr()` includes the `L`
to indicate the type is `long` (not `int`).

See: https://ci.appveyor.com/project/dhermes/google-resumable-media-python/build/1.0.1.master/job/9hrecnkosjs5q4l8
  • Loading branch information
dhermes committed Oct 20, 2017
1 parent 5da8fc2 commit 8700f14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions appveyor/env_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,30 @@
import sys


def env_var(var_name):
value = os.environ.get(var_name)
print('os.environ[{!r}]: {}'.format(var_name, value))


def main():
print('os.name: {}'.format(os.name))
env_var('PYTHON_ARCH')
env_var('PYTHON_VERSION')
print('sys.platform: {}'.format(sys.platform))

print('>>> import os')
print('>>> os.name')
print(repr(os.name))
print('>>> print(os.environ.get(\'PYTHON_ARCH\'))')
print(os.environ.get('PYTHON_ARCH'))
print('>>> print(os.environ.get(\'PYTHON_VERSION\'))')
print(os.environ.get('PYTHON_VERSION'))
print('>>> import sys')
print('>>> sys.platform')
print(repr(sys.platform))
print('>>> sys.maxsize')
print(repr(sys.maxsize))
if sys.maxsize == 2**63 - 1:
print('sys.maxsize: 2^(63) - 1')
print('>>> sys.maxsize == 2**63 - 1')
print('True')
elif sys.maxsize == 2**31 - 1:
print('sys.maxsize: 2^(31) - 1')
else:
print('sys.maxsize: {}'.format(sys.maxsize))

print('sys.version:\n{}'.format(sys.version))
bitness = struct.calcsize('P') * 8
print('struct.calcsize(\'P\') * 8: {}'.format(bitness))
print('>>> sys.maxsize == 2**31 - 1')
print('True')
print('>>> print(sys.version)')
print(sys.version)
print('>>> import struct')
print('>>> struct.calcsize(\'P\') * 8')
print(repr(struct.calcsize('P') * 8))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion google/resumable_media/_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
_CONTENT_RANGE_TEMPLATE = u'bytes {:d}-{:d}/{:d}'
_RANGE_UNKNOWN_TEMPLATE = u'bytes {:d}-{:d}/*'
_EMPTY_RANGE_TEMPLATE = u'bytes */{:d}'
_BOUNDARY_WIDTH = len(repr(sys.maxsize - 1))
_BOUNDARY_WIDTH = len(str(sys.maxsize - 1))
_BOUNDARY_FORMAT = u'==============={{:0{:d}d}}=='.format(_BOUNDARY_WIDTH)
_MULTIPART_SEP = b'--'
_CRLF = b'\r\n'
Expand Down

0 comments on commit 8700f14

Please sign in to comment.