File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1549,6 +1549,19 @@ and classes for traversing abstract syntax trees:
1549
1549
``await `` as variable names. The lowest supported version is
1550
1550
``(3, 4) ``; the highest is ``sys.version_info[0:2] ``.
1551
1551
1552
+ If source contains a null character ('\0 '), :exc: `ValueError ` is raised.
1553
+
1554
+ .. warning ::
1555
+ Note that succesfully parsing souce code into an AST object doesn't
1556
+ guarantee that the source code provided is valid Python code that can
1557
+ be executed as the compilation step can raise further :exc: `SyntaxError `
1558
+ exceptions. For instance, the source ``return 42 `` generates a valid
1559
+ AST node for a return statement, but it cannot be compiled alone (it needs
1560
+ to be inside a function node).
1561
+
1562
+ In particular, :func: `ast.parse ` won't do any scoping checks, which the
1563
+ compilation step does.
1564
+
1552
1565
.. warning ::
1553
1566
It is possible to crash the Python interpreter with a
1554
1567
sufficiently large/complex string due to stack depth limitations
You can’t perform that action at this time.
0 commit comments