mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #13848: open() and the FileIO constructor now check for NUL characters in the file name.
Patch by Hynek Schlawack.
This commit is contained in:
parent
c875d2032b
commit
1334884ff2
7 changed files with 44 additions and 22 deletions
|
@ -305,6 +305,11 @@ class OtherFileTests(unittest.TestCase):
|
|||
finally:
|
||||
os.unlink(TESTFN)
|
||||
|
||||
def testConstructorHandlesNULChars(self):
|
||||
fn_with_NUL = 'foo\0bar'
|
||||
self.assertRaises(TypeError, _FileIO, fn_with_NUL, 'w')
|
||||
self.assertRaises(TypeError, _FileIO, bytes(fn_with_NUL, 'ascii'), 'w')
|
||||
|
||||
def testInvalidFd(self):
|
||||
self.assertRaises(ValueError, _FileIO, -10)
|
||||
self.assertRaises(OSError, _FileIO, make_bad_fd())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue