equal
deleted
inserted
replaced
36 |
36 |
37 if ispy3: |
37 if ispy3: |
38 import builtins |
38 import builtins |
39 import functools |
39 import functools |
40 import io |
40 import io |
|
41 import struct |
41 |
42 |
42 fsencode = os.fsencode |
43 fsencode = os.fsencode |
43 fsdecode = os.fsdecode |
44 fsdecode = os.fsdecode |
44 # A bytes version of os.name. |
45 # A bytes version of os.name. |
45 osname = os.name.encode('ascii') |
46 osname = os.name.encode('ascii') |
71 # TODO: On Windows, the native argv is wchar_t, so we'll need a different |
72 # TODO: On Windows, the native argv is wchar_t, so we'll need a different |
72 # workaround to simulate the Python 2 (i.e. ANSI Win32 API) behavior. |
73 # workaround to simulate the Python 2 (i.e. ANSI Win32 API) behavior. |
73 if getattr(sys, 'argv', None) is not None: |
74 if getattr(sys, 'argv', None) is not None: |
74 sysargv = list(map(os.fsencode, sys.argv)) |
75 sysargv = list(map(os.fsencode, sys.argv)) |
75 |
76 |
76 def bytechr(i): |
77 bytechr = struct.Struct('>B').pack |
77 return bytes([i]) |
|
78 |
78 |
79 def iterbytestr(s): |
79 def iterbytestr(s): |
80 """Iterate bytes as if it were a str object of Python 2""" |
80 """Iterate bytes as if it were a str object of Python 2""" |
81 return iter(s[i:i + 1] for i in range(len(s))) |
81 return iter(s[i:i + 1] for i in range(len(s))) |
82 |
82 |