mirror of
https://github.com/python/cpython.git
synced 2025-10-04 22:20:46 +00:00
[3.6] bpo-13617: Reject embedded null characters in wchar* strings. (GH-2302) (#2462)
Based on patch by Victor Stinner.
Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters..
(cherry picked from commit f7eae0adfc
)
This commit is contained in:
parent
413c0a92bc
commit
0834905d9b
22 changed files with 115 additions and 24 deletions
|
@ -151,6 +151,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, __import__, 1, 2, 3, 4)
|
||||
self.assertRaises(ValueError, __import__, '')
|
||||
self.assertRaises(TypeError, __import__, 'sys', name='sys')
|
||||
# embedded null character
|
||||
self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
|
||||
|
||||
def test_abs(self):
|
||||
# int
|
||||
|
@ -1002,6 +1004,10 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(fp.read(300), 'XXX'*100)
|
||||
self.assertEqual(fp.read(1000), 'YYY'*100)
|
||||
|
||||
# embedded null bytes and characters
|
||||
self.assertRaises(ValueError, open, 'a\x00b')
|
||||
self.assertRaises(ValueError, open, b'a\x00b')
|
||||
|
||||
def test_open_default_encoding(self):
|
||||
old_environ = dict(os.environ)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue