diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-08-29 11:25:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 11:25:36 (GMT) |
commit | b2457efc78b74a1d6d1b77d11a939e886b8a4e2c (patch) | |
tree | b715b8061d730f07584d13e4475660d61fd261f5 /Lib/test/test_sys.py | |
parent | dfe0dc74536dfb6f331131d9b2b49557675bb6b7 (diff) | |
download | cpython-b2457efc78b74a1d6d1b77d11a939e886b8a4e2c.zip cpython-b2457efc78b74a1d6d1b77d11a939e886b8a4e2c.tar.gz cpython-b2457efc78b74a1d6d1b77d11a939e886b8a4e2c.tar.bz2 |
bpo-34523: Add _PyCoreConfig.filesystem_encoding (GH-8963)
_PyCoreConfig_Read() is now responsible to choose the filesystem
encoding and error handler. Using Py_Main(), the encoding is now
chosen even before calling Py_Initialize().
_PyCoreConfig.filesystem_encoding is now the reference, instead of
Py_FileSystemDefaultEncoding, for the Python filesystem encoding.
Changes:
* Add filesystem_encoding and filesystem_errors to _PyCoreConfig
* _PyCoreConfig_Read() now reads the locale encoding for the file
system encoding.
* PyUnicode_EncodeFSDefault() and PyUnicode_DecodeFSDefaultAndSize()
now use the interpreter configuration rather than
Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors
global configuration variables.
* Add _Py_SetFileSystemEncoding() and _Py_ClearFileSystemEncoding()
private functions to only modify Py_FileSystemDefaultEncoding and
Py_FileSystemDefaultEncodeErrors in coreconfig.c.
* _Py_CoerceLegacyLocale() now takes an int rather than
_PyCoreConfig for the warning.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r-- | Lib/test/test_sys.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index f3dd3bb..b90366d 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -861,6 +861,16 @@ class SysModuleTest(unittest.TestCase): def test_no_duplicates_in_meta_path(self): self.assertEqual(len(sys.meta_path), len(set(sys.meta_path))) + @unittest.skipUnless(hasattr(sys, "_enablelegacywindowsfsencoding"), + 'needs sys._enablelegacywindowsfsencoding()') + def test__enablelegacywindowsfsencoding(self): + code = ('import sys', + 'sys._enablelegacywindowsfsencoding()', + 'print(sys.getfilesystemencoding(), sys.getfilesystemencodeerrors())') + rc, out, err = assert_python_ok('-c', '; '.join(code)) + out = out.decode('ascii', 'replace').rstrip() + self.assertEqual(out, 'mbcs replace') + @test.support.cpython_only class SizeofTest(unittest.TestCase): |