Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
832bfe2e
Commit
832bfe2e
authored
Aug 09, 2011
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a AST validator (closes #12575)
parent
450bb594
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
897 additions
and
6 deletions
+897
-6
Include/ast.h
Include/ast.h
+1
-0
Lib/test/test_ast.py
Lib/test/test_ast.py
+408
-2
Misc/NEWS
Misc/NEWS
+2
-0
Python/ast.c
Python/ast.c
+482
-4
Python/bltinmodule.c
Python/bltinmodule.c
+4
-0
No files found.
Include/ast.h
View file @
832bfe2e
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
PyAPI_FUNC
(
int
)
PyAST_Validate
(
mod_ty
);
PyAPI_FUNC
(
mod_ty
)
PyAST_FromNode
(
PyAPI_FUNC
(
mod_ty
)
PyAST_FromNode
(
const
node
*
n
,
const
node
*
n
,
PyCompilerFlags
*
flags
,
PyCompilerFlags
*
flags
,
...
...
Lib/test/test_ast.py
View file @
832bfe2e
This diff is collapsed.
Click to expand it.
Misc/NEWS
View file @
832bfe2e
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #12575: Validate user-generated AST before it is compiled.
- Make type(None), type(Ellipsis), and type(NotImplemented) callable. They
- Make type(None), type(Ellipsis), and type(NotImplemented) callable. They
return the respective singleton instances.
return the respective singleton instances.
...
...
Python/ast.c
View file @
832bfe2e
This diff is collapsed.
Click to expand it.
Python/bltinmodule.c
View file @
832bfe2e
...
@@ -604,6 +604,10 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -604,6 +604,10 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
PyArena_Free
(
arena
);
PyArena_Free
(
arena
);
goto
error
;
goto
error
;
}
}
if
(
!
PyAST_Validate
(
mod
))
{
PyArena_Free
(
arena
);
goto
error
;
}
result
=
(
PyObject
*
)
PyAST_CompileEx
(
mod
,
filename
,
result
=
(
PyObject
*
)
PyAST_CompileEx
(
mod
,
filename
,
&
cf
,
optimize
,
arena
);
&
cf
,
optimize
,
arena
);
PyArena_Free
(
arena
);
PyArena_Free
(
arena
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment