equal
deleted
inserted
replaced
17 import shlex |
17 import shlex |
18 import sys |
18 import sys |
19 import tempfile |
19 import tempfile |
20 |
20 |
21 ispy3 = sys.version_info[0] >= 3 |
21 ispy3 = sys.version_info[0] >= 3 |
22 ispypy = r'__pypy__' in sys.builtin_module_names |
22 ispypy = '__pypy__' in sys.builtin_module_names |
23 |
23 |
24 if not ispy3: |
24 if not ispy3: |
25 import cookielib |
25 import cookielib |
26 import cPickle as pickle |
26 import cPickle as pickle |
27 import httplib |
27 import httplib |
149 # On Windows, the native argv is unicode and is converted to MBCS bytes |
149 # On Windows, the native argv is unicode and is converted to MBCS bytes |
150 # since we do enable the legacy filesystem encoding. |
150 # since we do enable the legacy filesystem encoding. |
151 if getattr(sys, 'argv', None) is not None: |
151 if getattr(sys, 'argv', None) is not None: |
152 sysargv = list(map(os.fsencode, sys.argv)) |
152 sysargv = list(map(os.fsencode, sys.argv)) |
153 |
153 |
154 bytechr = struct.Struct(r'>B').pack |
154 bytechr = struct.Struct('>B').pack |
155 byterepr = b'%r'.__mod__ |
155 byterepr = b'%r'.__mod__ |
156 |
156 |
157 class bytestr(bytes): |
157 class bytestr(bytes): |
158 """A bytes which mostly acts as a Python 2 str |
158 """A bytes which mostly acts as a Python 2 str |
159 |
159 |
498 # mode must include 'b'ytes as encoding= is not supported |
498 # mode must include 'b'ytes as encoding= is not supported |
499 def namedtempfile( |
499 def namedtempfile( |
500 mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, delete=True |
500 mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, delete=True |
501 ): |
501 ): |
502 mode = sysstr(mode) |
502 mode = sysstr(mode) |
503 assert r'b' in mode |
503 assert 'b' in mode |
504 return tempfile.NamedTemporaryFile( |
504 return tempfile.NamedTemporaryFile( |
505 mode, bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete |
505 mode, bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete |
506 ) |
506 ) |