Kaydet (Commit) 6193ecd7 authored tarafından Victor Stinner's avatar Victor Stinner

Fix a ResourceWarning in generate_opcode_h.py

Use a context manager to close the Python file. Replace also open() with
tokenize.open() to handle coding cookie if any in Lib/opcode.py.
üst 1018fad6
......@@ -32,10 +32,14 @@ enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE,
#endif /* !Py_OPCODE_H */
"""
import tokenize
def main(opcode_py, outfile='Include/opcode.h'):
opcode = {}
exec(open(opcode_py).read(), opcode)
with tokenize.open(opcode_py) as fp:
code = fp.read()
exec(code, opcode)
opmap = opcode['opmap']
with open(outfile, 'w') as fobj:
fobj.write(header)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment