diff options
Diffstat (limited to 'Tools/scripts')
| -rw-r--r-- | Tools/scripts/generate_opcode_h.py | 54 | ||||
| -rw-r--r-- | Tools/scripts/run_tests.py | 8 |
2 files changed, 59 insertions, 3 deletions
diff --git a/Tools/scripts/generate_opcode_h.py b/Tools/scripts/generate_opcode_h.py new file mode 100644 index 0000000..efa18a1 --- /dev/null +++ b/Tools/scripts/generate_opcode_h.py @@ -0,0 +1,54 @@ +# This script generates the opcode.h header file. + +from __future__ import with_statement + +import sys +header = """/* Auto-generated by Tools/scripts/generate_opcode_h.py */ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + + /* Instruction opcodes for compiled code */ +""" + +footer = """ +/* EXCEPT_HANDLER is a special, implicit block type which is created when + entering an except handler. It is not an opcode but we define it here + as we want it to be available to both frameobject.c and ceval.c, while + remaining private.*/ +#define EXCEPT_HANDLER 257 + + +enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, + PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, + PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; + +#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ +""" + + +def main(opcode_py, outfile='Include/opcode.h'): + opcode = {} + exec(open(opcode_py).read(), opcode) + opmap = opcode['opmap'] + with open(outfile, 'w') as fobj: + fobj.write(header) + for name in opcode['opname']: + if name in opmap: + fobj.write("#define %-20s\t%-3s\n" % (name, opmap[name])) + if name == 'POP_EXCEPT': # Special entry for HAVE_ARGUMENT + fobj.write("#define %-20s\t%-3d\n" % + ('HAVE_ARGUMENT', opcode['HAVE_ARGUMENT'])) + fobj.write(footer) + + +if __name__ == '__main__': + main(sys.argv[1], sys.argv[2]) diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py index a6c5da3..b582e13 100644 --- a/Tools/scripts/run_tests.py +++ b/Tools/scripts/run_tests.py @@ -33,8 +33,6 @@ def main(regrtest_args): # Allow user-specified interpreter options to override our defaults. args.extend(test.support.args_from_interpreter_flags()) - # Workaround for issue #20355 - os.environ.pop("PYTHONWARNINGS", None) # Workaround for issue #20361 args.extend(['-W', 'error::BytesWarning']) @@ -50,7 +48,11 @@ def main(regrtest_args): args.extend(['-u', 'all,-largefile,-audio,-gui']) args.extend(regrtest_args) print(' '.join(args)) - os.execv(sys.executable, args) + if sys.platform == 'win32': + from subprocess import call + sys.exit(call(args)) + else: + os.execv(sys.executable, args) if __name__ == '__main__': |
