Disallow opening files with modes 'aU' or 'wU' as specified by PEP

278. Closes bug 967182.
This commit is contained in:
Skip Montanaro 2005-05-20 03:07:06 +00:00
parent 7961aa6135
commit bbf12ba7b2
3 changed files with 64 additions and 0 deletions

View file

@ -40,6 +40,16 @@ for attr in 'name', 'mode', 'closed':
raise TestFailed('expected exception setting file attr %r' % attr)
f.close()
# check invalid mode strings
for mode in ("", "aU", "wU+"):
try:
f = file(TESTFN, mode)
except ValueError:
pass
else:
f.close()
raise TestFailed('%r is an invalid file mode' % mode)
# verify writelines with instance sequence
l = UserList(['1', '2'])
f = open(TESTFN, 'wb')