diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-12-04 17:24:33 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-12-04 17:24:33 (GMT) |
commit | 13d49ee7d6a44af656fd77713342e419ec57e4a5 (patch) | |
tree | 30250bac5be4f5e904d62f3628424e0ef6e22c2c /Lib/test/test_cmd_line.py | |
parent | 44588b45d2b9cedb9fd91f82c1b00cd781a56c94 (diff) | |
download | cpython-13d49ee7d6a44af656fd77713342e419ec57e4a5.zip cpython-13d49ee7d6a44af656fd77713342e419ec57e4a5.tar.gz cpython-13d49ee7d6a44af656fd77713342e419ec57e4a5.tar.bz2 |
Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
UnicodeEncodeError.
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r-- | Lib/test/test_cmd_line.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index e1fe7f5..b21b61e 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -221,6 +221,24 @@ class CmdLineTest(unittest.TestCase): self.assertIn(path1.encode('ascii'), out) self.assertIn(path2.encode('ascii'), out) + def test_displayhook_unencodable(self): + for encoding in ('ascii', 'latin1', 'utf8'): + env = os.environ.copy() + env['PYTHONIOENCODING'] = encoding + p = subprocess.Popen( + [sys.executable, '-i'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + env=env) + # non-ascii, surrogate, non-BMP printable, non-BMP unprintable + text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF" + p.stdin.write(ascii(text).encode('ascii') + b"\n") + p.stdin.write(b'exit()\n') + data = kill_python(p) + escaped = repr(text).encode(encoding, 'backslashreplace') + self.assertIn(escaped, data) + def test_main(): test.support.run_unittest(CmdLineTest) |