[3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195)

This commit is contained in:
Lysandros Nikolaou 2023-05-07 12:12:04 +02:00 committed by GitHub
parent c5dafeaa6d
commit a09d3901a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 77 additions and 22 deletions

View file

@ -857,6 +857,10 @@ class AST_Tests(unittest.TestCase):
check_limit("a", "[0]")
check_limit("a", "*a")
def test_null_bytes(self):
with self.assertRaises(SyntaxError,
msg="source code string cannot contain null bytes"):
ast.parse("a\0b")
class ASTHelpers_Test(unittest.TestCase):
maxDiff = None