Forward-port PYTHONIOENCODING.
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 @@
#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)