diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-17 01:26:01 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-17 01:26:01 (GMT) |
commit | 372ac5e73260d6e8c8aefe31fd979a7706841868 (patch) | |
tree | 6c8feac35bff3c12181a819e4925f6d094831df4 /Lib/test/test_sys.py | |
parent | 6baded49d0abf07f141dae489c6a010af1b1e209 (diff) | |
download | cpython-372ac5e73260d6e8c8aefe31fd979a7706841868.zip cpython-372ac5e73260d6e8c8aefe31fd979a7706841868.tar.gz cpython-372ac5e73260d6e8c8aefe31fd979a7706841868.tar.bz2 |
PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead
of strict) error handler to escape surrogates
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 abbd759..ecbc9db 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -145,6 +145,16 @@ class SysModuleTest(unittest.TestCase): "raise SystemExit(47)"]) self.assertEqual(rc, 47) + # test that the exit message is written with backslashreplace error + # handler to stderr + import subprocess + code = r'import sys; sys.exit("surrogates:\uDCFF")' + process = subprocess.Popen([sys.executable, "-c", code], + stderr=subprocess.PIPE) + stdout, stderr = process.communicate() + self.assertEqual(process.returncode, 1) + self.assertTrue(stderr.startswith(b"surrogates:\\udcff"), stderr) + def test_getdefaultencoding(self): self.assertRaises(TypeError, sys.getdefaultencoding, 42) # can't check more than the type, as the user might have changed it |