File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# This script generates the opcode.h header file.
22
33import sys
4+ import tokenize
5+
46header = """/* Auto-generated by Tools/scripts/generate_opcode_h.py */
57#ifndef Py_OPCODE_H
68#define Py_OPCODE_H
3234#endif /* !Py_OPCODE_H */
3335"""
3436
35- import tokenize
36-
3737
3838def main (opcode_py , outfile = 'Include/opcode.h' ):
3939 opcode = {}
40- with tokenize .open (opcode_py ) as fp :
40+ if hasattr (tokenize , 'open' ):
41+ fp = tokenize .open (opcode_py ) # Python 3.2+
42+ else :
43+ fp = open (opcode_py ) # Python 2.7
44+ with fp :
4145 code = fp .read ()
4246 exec (code , opcode )
4347 opmap = opcode ['opmap' ]
@@ -51,6 +55,8 @@ def main(opcode_py, outfile='Include/opcode.h'):
5155 ('HAVE_ARGUMENT' , opcode ['HAVE_ARGUMENT' ]))
5256 fobj .write (footer )
5357
58+ print ("%s regenerated from %s" % (outfile , opcode_py ))
59+
5460
5561if __name__ == '__main__' :
5662 main (sys .argv [1 ], sys .argv [2 ])
You can’t perform that action at this time.
0 commit comments