summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-08-11 19:42:28 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-08-11 19:42:28 (GMT)
commit5a3f49bb7e6b5e11ced022f2b5b8974b98caae68 (patch)
tree97df6937ce3175a7c6ea8959b730d0132625bd19
parentf0dda5f876966b27c92046c7be2bc6fb420f654b (diff)
downloadcpython-5a3f49bb7e6b5e11ced022f2b5b8974b98caae68.zip
cpython-5a3f49bb7e6b5e11ced022f2b5b8974b98caae68.tar.gz
cpython-5a3f49bb7e6b5e11ced022f2b5b8974b98caae68.tar.bz2
revert code which conditionally writes Python-ast.h (closes #12727)
-rwxr-xr-xParser/asdl_c.py26
1 files changed, 3 insertions, 23 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index ceac32f..0b95aaa 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -4,10 +4,7 @@
# TO DO
# handle fields that have a type but no name
-import errno
-import os
-import sys
-import StringIO
+import os, sys
import subprocess
import asdl
@@ -1158,7 +1155,7 @@ def main(srcfile):
sys.exit(1)
if INC_DIR:
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
- f = StringIO.StringIO()
+ f = open(p, "w")
f.write(auto_gen_msg)
f.write('#include "asdl.h"\n\n')
c = ChainOfVisitors(TypeDefVisitor(f),
@@ -1169,24 +1166,7 @@ def main(srcfile):
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
f.write("int PyAST_Check(PyObject* obj);\n")
- s = f.getvalue()
- write = True
- try:
- fp = open(p, "r")
- except IOError, e:
- if e.errno != errno.ENOENT:
- raise
- else:
- try:
- write = fp.read() != s
- finally:
- fp.close()
- if write:
- fp = open(p, "w")
- try:
- fp.write(s)
- finally:
- fp.close()
+ f.close()
if SRC_DIR:
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")