[Python-checkins] cpython: Simplify main() of test_ast
victor.stinner
python-checkins at python.org
Mon Feb 8 12:12:02 EST 2016
https://hg.python.org/cpython/rev/a0d053899ff8
changeset: 100190:a0d053899ff8
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Feb 08 17:15:21 2016 +0100
summary:
Simplify main() of test_ast
* Use ast.parse() to get the AST for a statement
* Use str%args syntax for format a line
Issue #26204.
files:
Lib/test/test_ast.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1064,8 +1064,9 @@
for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
(eval_tests, "eval")):
print(kind+"_results = [")
- for s in statements:
- print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
+ for statement in statements:
+ tree = ast.parse(statement, "?", kind)
+ print("%r," % (to_tuple(tree),))
print("]")
print("main()")
raise SystemExit
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list