summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-25 20:52:56 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-25 20:52:56 (GMT)
commit17617a07d1f2d2ffb6b0f77be8926f54cd0f4ae8 (patch)
tree90b9bdabd59ba83dabbdea1f49ac745a22a7fe43 /Lib
parent22d3c92480b419c4ad1adf42ffb723ba2d471f26 (diff)
downloadcpython-17617a07d1f2d2ffb6b0f77be8926f54cd0f4ae8.zip
cpython-17617a07d1f2d2ffb6b0f77be8926f54cd0f4ae8.tar.gz
cpython-17617a07d1f2d2ffb6b0f77be8926f54cd0f4ae8.tar.bz2
#3965: on Windows, open() crashes if the filename or the mode is invalid,
and if the filename is a unicode string. Reviewed by Martin von Loewis.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_file.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 7cfaef7..b93bdbd 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -134,6 +134,16 @@ class OtherFileTests(unittest.TestCase):
f.close()
self.fail('%r is an invalid file mode' % mode)
+ # Some invalid modes fail on Windows, but pass on Unix
+ # Issue3965: avoid a crash on Windows when filename is unicode
+ for name in (TESTFN, unicode(TESTFN), unicode(TESTFN + '\t')):
+ try:
+ f = open(name, "rr")
+ except IOError:
+ pass
+ else:
+ f.close()
+
def testStdin(self):
# This causes the interpreter to exit on OSF1 v5.1.
if sys.platform != 'osf1V5':