equal
deleted
inserted
replaced
176 # encoding, which will pass CP_ACP to the underlying Windows API to |
176 # encoding, which will pass CP_ACP to the underlying Windows API to |
177 # produce bytes. |
177 # produce bytes. |
178 if os.name == r'nt': |
178 if os.name == r'nt': |
179 sysargv = [a.encode("mbcs", "ignore") for a in sys.argv] |
179 sysargv = [a.encode("mbcs", "ignore") for a in sys.argv] |
180 else: |
180 else: |
|
181 |
|
182 def getdefaultlocale_if_known(): |
|
183 try: |
|
184 return locale.getdefaultlocale() |
|
185 except ValueError: |
|
186 return None, None |
|
187 |
181 encoding = ( |
188 encoding = ( |
182 locale.getlocale()[1] |
189 locale.getlocale()[1] |
183 or locale.getdefaultlocale()[1] |
190 or getdefaultlocale_if_known()[1] |
184 or sys.getfilesystemencoding() |
191 or sys.getfilesystemencoding() |
185 ) |
192 ) |
186 sysargv = [a.encode(encoding, "surrogateescape") for a in sys.argv] |
193 sysargv = [a.encode(encoding, "surrogateescape") for a in sys.argv] |
187 |
194 |
188 bytechr = struct.Struct('>B').pack |
195 bytechr = struct.Struct('>B').pack |