summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 231b460..e1bc98d 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -349,6 +349,26 @@ class SysModuleTest(unittest.TestCase):
#self.assert_(r[0][1] > 100, r[0][1])
#self.assert_(r[0][2] > 100, r[0][2])
+ def test_ioencoding(self):
+ import subprocess,os
+ env = dict(os.environ)
+
+ # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
+ # not representable in ASCII.
+
+ env["PYTHONIOENCODING"] = "cp424"
+ p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
+ stdout = subprocess.PIPE, env=env)
+ out = p.stdout.read()
+ self.assertEqual(out, "\xa2\n".encode("cp424"))
+
+ env["PYTHONIOENCODING"] = "ascii:replace"
+ p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
+ stdout = subprocess.PIPE, env=env)
+ out = p.stdout.read().strip()
+ self.assertEqual(out, b'?')
+
+
def test_main():
test.support.run_unittest(SysModuleTest)