Issue #22215: Now ValueError is raised instead of TypeError when str or bytes

argument contains not permitted null character or byte.
This commit is contained in:
Serhiy Storchaka 2014-09-06 20:07:17 +03:00
parent 4a4b679515
commit d8a1447c99
14 changed files with 41 additions and 39 deletions

View file

@ -363,8 +363,8 @@ class IOTest(unittest.TestCase):
def test_open_handles_NUL_chars(self):
fn_with_NUL = 'foo\0bar'
self.assertRaises(TypeError, self.open, fn_with_NUL, 'w')
self.assertRaises(TypeError, self.open, bytes(fn_with_NUL, 'ascii'), 'w')
self.assertRaises(ValueError, self.open, fn_with_NUL, 'w')
self.assertRaises(ValueError, self.open, bytes(fn_with_NUL, 'ascii'), 'w')
def test_raw_file_io(self):
with self.open(support.TESTFN, "wb", buffering=0) as f: