cpython: 46e2755b022c (original) (raw)

Mercurial > cpython

changeset 105360:46e2755b022c

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.

Victor Stinner victor.stinner@gmail.com
date Fri, 25 Nov 2016 11:59:52 +0100
parents 45713818fd81
children 0bf7c2d99bf1
files Tools/scripts/generate_opcode_h.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-)[+] [-] Tools/scripts/generate_opcode_h.py 6

line wrap: on

line diff

--- a/Tools/scripts/generate_opcode_h.py +++ b/Tools/scripts/generate_opcode_h.py @@ -32,10 +32,14 @@ enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py #endif /* !Py_OPCODE_H */ """ +import tokenize + def main(opcode_py, outfile='Include/opcode.h'): opcode = {}