diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-10 11:34:13 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-10 11:34:13 (GMT) |
commit | fc43511867bfee131a3bfb18969ad02a1bb44a07 (patch) | |
tree | 2f07faf1728b809886d9e2616baaec002ff9cea4 /Lib/test/test_sys.py | |
parent | 731b1b12b8de92b5da8bcdb5ba686f1d3a83662a (diff) | |
download | cpython-fc43511867bfee131a3bfb18969ad02a1bb44a07.zip cpython-fc43511867bfee131a3bfb18969ad02a1bb44a07.tar.gz cpython-fc43511867bfee131a3bfb18969ad02a1bb44a07.tar.bz2 |
Issue #25339: PYTHONIOENCODING now has priority over locale in setting the
error handler for stdin and stdout.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r-- | Lib/test/test_sys.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 6046671..2aa16fc 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -691,8 +691,10 @@ class SysModuleTest(unittest.TestCase): args = [sys.executable, "-c", code] if isolated: args.append("-I") - elif encoding: + if encoding is not None: env['PYTHONIOENCODING'] = encoding + else: + env.pop('PYTHONIOENCODING', None) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -709,15 +711,32 @@ class SysModuleTest(unittest.TestCase): 'stderr: backslashreplace\n') # replace the default error handler - out = self.c_locale_get_error_handler(encoding=':strict') + out = self.c_locale_get_error_handler(encoding=':ignore') self.assertEqual(out, - 'stdin: strict\n' - 'stdout: strict\n' + 'stdin: ignore\n' + 'stdout: ignore\n' 'stderr: backslashreplace\n') # force the encoding out = self.c_locale_get_error_handler(encoding='iso8859-1') self.assertEqual(out, + 'stdin: strict\n' + 'stdout: strict\n' + 'stderr: backslashreplace\n') + out = self.c_locale_get_error_handler(encoding='iso8859-1:') + self.assertEqual(out, + 'stdin: strict\n' + 'stdout: strict\n' + 'stderr: backslashreplace\n') + + # have no any effect + out = self.c_locale_get_error_handler(encoding=':') + self.assertEqual(out, + 'stdin: surrogateescape\n' + 'stdout: surrogateescape\n' + 'stderr: backslashreplace\n') + out = self.c_locale_get_error_handler(encoding='') + self.assertEqual(out, 'stdin: surrogateescape\n' 'stdout: surrogateescape\n' 'stderr: backslashreplace\n') |