gh-96670: Raise SyntaxError when parsing NULL bytes (#97594)

This commit is contained in:
Pablo Galindo Salgado 2022-09-27 23:23:42 +01:00 committed by GitHub
parent dd53b79de0
commit aab01e3524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 65 additions and 21 deletions

View file

@ -844,6 +844,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