About the "RuntimeError: Failed to change the filesystem default encoding" error in _patch_filesystem_default_encoding(), IMO brz should re-exec itself (os.execv) to enabled Python 3.7 UTF-8 Mode: https://www.python.org/dev/peps/pep-0540/
Example:
---
import os
import sys
# FIXME: skip this code on Python 3.6 and older ;-)
if not sys.flags.utf8_mode:
print("re-exec!")
argv = [sys.executable, "-X", "utf8"] + sys.argv
try: os.execv(argv[0], argv)
except Exception: print("os.execv failed, too bad: %r" % exc)
sys.exit(1)
With the C and POSIX locales, UTF-8 is enabled by default, no need to re-exec:
---
vstinner@apu$ LANG= python3 x.py arg1 arg2
UTF-8 Mode: 1
filesystem encoding: utf-8
argv: ['x.py', 'arg1', 'arg2']
---
About the "RuntimeError: Failed to change the filesystem default encoding" error in _patch_ filesystem_ default_ encoding( ), IMO brz should re-exec itself (os.execv) to enabled Python 3.7 UTF-8 Mode: /www.python. org/dev/ peps/pep- 0540/
https:/
Example:
---
import os
import sys
# FIXME: skip this code on Python 3.6 and older ;-) utf8_mode: "re-exec! ")
os.execv( argv[0] , argv)
print( "os.execv failed, too bad: %r" % exc)
if not sys.flags.
print(
argv = [sys.executable, "-X", "utf8"] + sys.argv
try:
except Exception:
sys.exit(1)
print("UTF-8 Mode:", sys.flags. utf8_mode) emencoding( ))
print("filesystem encoding:", sys.getfilesyst
print("argv:", sys.argv)
---
Output:
---
$ python3 script.py arg1 arg2
re-exec!
UTF-8 Mode: 1
filesystem encoding: utf-8
argv: ['x.py', 'arg1', 'arg2']
---
With the C and POSIX locales, UTF-8 is enabled by default, no need to re-exec:
---
vstinner@apu$ LANG= python3 x.py arg1 arg2
UTF-8 Mode: 1
filesystem encoding: utf-8
argv: ['x.py', 'arg1', 'arg2']
---