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 @@ -1917,6 +1917,19 @@ and classes for traversing abstract syntax trees:
1917
1917
``await `` as variable names. The lowest supported version is
1918
1918
8000
``(3, 4) ``; the highest is ``sys.version_info[0:2] ``.
1919
1919
1920
+ If source contains a null character ('\0 '), :exc: `ValueError ` is raised.
1921
+
1922
+ .. warning ::
1923
+ Note that succesfully parsing souce code into an AST object doesn't
1924
+ guarantee that the source code provided is valid Python code that can
1925
+ be executed as the compilation step can raise further :exc: `SyntaxError `
1926
+ exceptions. For instance, the source ``return 42 `` generates a valid
1927
+ AST node for a return statement, but it cannot be compiled alone (it needs
1928
+ to be inside a function node).
1929
+
1930
+ In particular, :func: `ast.parse ` won't do any scoping checks, which the
1931
+ compilation step does.
1932
+
1920
1933
.. warning ::
1921
1934
It is possible to crash the Python interpreter with a
1922
1935
sufficiently large/complex string due to stack depth limitations
You can’t perform that action at this time.
0 commit comments