[Python-checkins] cpython: Small fixes in Parser/asdl.py - no change in functionality.
eli.bendersky
python-checkins at python.org
Thu Sep 26 15:33:17 CEST 2013
http://hg.python.org/cpython/rev/21d46e3ae60c
changeset: 85799:21d46e3ae60c
parent: 85796:436b606ecfe8
user: Eli Bendersky <eliben at gmail.com>
date: Thu Sep 26 06:31:32 2013 -0700
summary:
Small fixes in Parser/asdl.py - no change in functionality.
1. Make it work when invoked directly from the command-line. It was failing
due to a couple of stale function/class usages in the __main__ section.
2. Close the parsed file in the parse() function after opening it.
files:
Parser/asdl.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Parser/asdl.py b/Parser/asdl.py
--- a/Parser/asdl.py
+++ b/Parser/asdl.py
@@ -16,8 +16,9 @@
import spark
-def output(string):
- sys.stdout.write(string + "\n")
+def output(*strings):
+ for s in strings:
+ sys.stdout.write(str(s) + "\n")
class Token(object):
@@ -397,7 +398,8 @@
scanner = ASDLScanner()
parser = ASDLParser()
- buf = open(file).read()
+ with open(file) as f:
+ buf = f.read()
tokens = scanner.tokenize(buf)
try:
return parser.parse(tokens)
@@ -428,4 +430,4 @@
output("Check failed")
else:
for dfn in mod.dfns:
- output(dfn.type)
+ output(dfn.name, dfn.value)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list