Show More
@@ -66,33 +66,15 b' else:' | |||
|
66 | 66 | def sysstr(s): |
|
67 | 67 | return s |
|
68 | 68 | |
|
69 | # Partial backport from os.py in Python 3 | |
|
70 | def _fscodec(): | |
|
71 | encoding = sys.getfilesystemencoding() | |
|
72 | if encoding == 'mbcs': | |
|
73 | errors = 'strict' | |
|
74 | else: | |
|
75 | errors = 'surrogateescape' | |
|
76 | ||
|
69 | # Partial backport from os.py in Python 3, which only accepts bytes. | |
|
70 | # In Python 2, our paths should only ever be bytes, a unicode path | |
|
71 | # indicates a bug. | |
|
77 | 72 |
|
|
78 | """ | |
|
79 | Encode filename to the filesystem encoding with 'surrogateescape' | |
|
80 | error handler, return bytes unchanged. On Windows, use 'strict' | |
|
81 | error handler if the file system encoding is 'mbcs' (which is the | |
|
82 | default encoding). | |
|
83 | """ | |
|
84 | 73 |
|
|
85 | 74 |
|
|
86 | elif isinstance(filename, unicode): | |
|
87 | return filename.encode(encoding, errors) | |
|
88 | 75 |
|
|
89 | 76 |
|
|
90 |
|
|
|
91 | ||
|
92 | return fsencode | |
|
93 | ||
|
94 | fsencode = _fscodec() | |
|
95 | del _fscodec | |
|
77 | "expect str, not %s" % type(filename).__name__) | |
|
96 | 78 | |
|
97 | 79 | stringio = io.StringIO |
|
98 | 80 | empty = _queue.Empty |
General Comments 0
You need to be logged in to leave comments.
Login now