summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fileio.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-04-19 18:52:43 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-04-19 18:52:43 (GMT)
commit7c587bf53d67ef0e279e471ac6d52d5087f4b3e8 (patch)
tree47441dac0ca51451071740cc30d3507b84edea71 /Lib/test/test_fileio.py
parent35b76027f94b12911cc97f960ebbb3c137d10d2b (diff)
downloadcpython-7c587bf53d67ef0e279e471ac6d52d5087f4b3e8.zip
cpython-7c587bf53d67ef0e279e471ac6d52d5087f4b3e8.tar.gz
cpython-7c587bf53d67ef0e279e471ac6d52d5087f4b3e8.tar.bz2
Issue #8438: Remove reference to the missing "surrogateescape" encoding
error handler from the new IO library.
Diffstat (limited to 'Lib/test/test_fileio.py')
-rw-r--r--Lib/test/test_fileio.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 21d231f..930b654 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -12,6 +12,7 @@ from functools import wraps
from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd
from test.test_support import py3k_bytes as bytes
+from test.script_helper import run_python
from _io import FileIO as _FileIO
@@ -397,6 +398,25 @@ class OtherFileTests(unittest.TestCase):
self.assertRaises(ValueError, _FileIO, "/some/invalid/name", "rt")
self.assertEqual(w.warnings, [])
+ def test_surrogates(self):
+ # Issue #8438: try to open a filename containing surrogates.
+ # It should either fail because the file doesn't exist or the filename
+ # can't be represented using the filesystem encoding, but not because
+ # of a LookupError for the error handler "surrogateescape".
+ filename = u'\udc80.txt'
+ try:
+ with _FileIO(filename):
+ pass
+ except (UnicodeEncodeError, IOError):
+ pass
+ # Spawn a separate Python process with a different "file system
+ # default encoding", to exercise this further.
+ env = dict(os.environ)
+ env[b'LC_CTYPE'] = b'C'
+ _, out = run_python('-c', 'import _io; _io.FileIO(%r)' % filename, env=env)
+ if ('UnicodeEncodeError' not in out and
+ 'IOError: [Errno 2] No such file or directory' not in out):
+ self.fail('Bad output: %r' % out)
def test_main():
# Historically, these tests have been sloppy about removing TESTFN.