summaryrefslogtreecommitdiffstats
path: root/Tools/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-xTools/scripts/diff.py34
-rw-r--r--Tools/scripts/dutree.doc6
-rw-r--r--Tools/scripts/generate_opcode_h.py54
-rw-r--r--Tools/scripts/run_tests.py8
-rw-r--r--Tools/scripts/win_add2path.py3
5 files changed, 82 insertions, 23 deletions
diff --git a/Tools/scripts/diff.py b/Tools/scripts/diff.py
index 8be527f..9720a43 100755
--- a/Tools/scripts/diff.py
+++ b/Tools/scripts/diff.py
@@ -8,7 +8,7 @@
"""
-import sys, os, time, difflib, optparse
+import sys, os, time, difflib, argparse
from datetime import datetime, timezone
def file_mtime(path):
@@ -18,23 +18,25 @@ def file_mtime(path):
def main():
- usage = "usage: %prog [options] fromfile tofile"
- parser = optparse.OptionParser(usage)
- parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)')
- parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff')
- parser.add_option("-m", action="store_true", default=False, help='Produce HTML side by side diff (can use -c and -l in conjunction)')
- parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff')
- parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)')
- (options, args) = parser.parse_args()
-
- if len(args) == 0:
- parser.print_help()
- sys.exit(1)
- if len(args) != 2:
- parser.error("need to specify both a fromfile and tofile")
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-c', action='store_true', default=False,
+ help='Produce a context format diff (default)')
+ parser.add_argument('-u', action='store_true', default=False,
+ help='Produce a unified format diff')
+ parser.add_argument('-m', action='store_true', default=False,
+ help='Produce HTML side by side diff '
+ '(can use -c and -l in conjunction)')
+ parser.add_argument('-n', action='store_true', default=False,
+ help='Produce a ndiff format diff')
+ parser.add_argument('-l', '--lines', type=int, default=3,
+ help='Set number of context lines (default 3)')
+ parser.add_argument('fromfile')
+ parser.add_argument('tofile')
+ options = parser.parse_args()
n = options.lines
- fromfile, tofile = args
+ fromfile = options.fromfile
+ tofile = options.tofile
fromdate = file_mtime(fromfile)
todate = file_mtime(tofile)
diff --git a/Tools/scripts/dutree.doc b/Tools/scripts/dutree.doc
index 2a09426..97bd2e2 100644
--- a/Tools/scripts/dutree.doc
+++ b/Tools/scripts/dutree.doc
@@ -34,13 +34,13 @@ sometimes it's not worth it. I actually wrote a C program the other day
: | 1 sm.bak
At first I thought I could just keep one local list around
-at once, but this seems inherently recursive. Which means
+at once, but this seems inherently recursive. Which means
I need an real recursive data structure. Maybe you could
do it with one of the %assoc arrays Larry uses in the begat
programs, but I broke down and got dirty. I think the hardest
-part was matching Felix's desired output exactly. It's not
+part was matching Felix's desired output exactly. It's not
blazingly fast: I should probably inline the &childof routine,
-but it *was* faster to write than I could have written the
+but it *was* faster to write than I could have written the
equivalent C program.
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__':
diff --git a/Tools/scripts/win_add2path.py b/Tools/scripts/win_add2path.py
index c85bea5..1c9aedc 100644
--- a/Tools/scripts/win_add2path.py
+++ b/Tools/scripts/win_add2path.py
@@ -22,7 +22,8 @@ def modify():
scripts = os.path.join(pythonpath, "Scripts")
appdata = os.environ["APPDATA"]
if hasattr(site, "USER_SITE"):
- userpath = site.USER_SITE.replace(appdata, "%APPDATA%")
+ usersite = site.USER_SITE.replace(appdata, "%APPDATA%")
+ userpath = os.path.dirname(usersite)
userscripts = os.path.join(userpath, "Scripts")
else:
userscripts = None