File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44# TO DO
55# handle fields that have a type but no name
66
7- import errno
8- import os
9- import sys
10- import StringIO
7+ import os , sys
118import subprocess
129
1310import asdl
@@ -1158,7 +1155,7 @@ def main(srcfile):
11581155 sys .exit (1 )
11591156 if INC_DIR :
11601157 p = "%s/%s-ast.h" % (INC_DIR , mod .name )
1161- f = StringIO . StringIO ( )
1158+ f = open ( p , "w" )
11621159 f .write (auto_gen_msg )
11631160 f .write ('#include "asdl.h"\n \n ' )
11641161 c = ChainOfVisitors (TypeDefVisitor (f ),
@@ -1169,24 +1166,7 @@ def main(srcfile):
11691166 f .write ("PyObject* PyAST_mod2obj(mod_ty t);\n " )
11701167 f .write ("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n " )
11711168 f .write ("int PyAST_Check(PyObject* obj);\n " )
1172- s = f .getvalue ()
1173- write = True
1174- try :
1175- fp = open (p , "r" )
1176- except IOError , e :
1177- if e .errno != errno .ENOENT :
1178- raise
1179- else :
1180- try :
1181- write = fp .read () != s
1182- finally :
1183- fp .close ()
1184- if write :
1185- fp = open (p , "w" )
1186- try :
1187- fp .write (s )
1188- finally :
1189- fp .close ()
1169+ f .close ()
11901170
11911171 if SRC_DIR :
11921172 p = os .path .join (SRC_DIR , str (mod .name ) + "-ast.c" )
You can’t perform that action at this time.
0 commit comments