Issue #23908: os functions, open() and the io.FileIO constructor now reject
unicode paths with embedded null character on Windows instead of silently
truncate them.
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 8fdad14..634a764 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -361,6 +361,11 @@
finally:
os.unlink(TESTFN)
+ def testConstructorHandlesNULChars(self):
+ fn_with_NUL = 'foo\0bar'
+ self.assertRaises(TypeError, _FileIO, fn_with_NUL, 'w')
+ self.assertRaises(TypeError, _FileIO, fn_with_NUL.encode('ascii'), 'w')
+
def testInvalidFd(self):
self.assertRaises(ValueError, _FileIO, -10)
self.assertRaises(OSError, _FileIO, make_bad_fd())