summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rw-r--r--Tools/buildbot/external-amd64.bat10
-rw-r--r--Tools/buildbot/external.bat8
-rw-r--r--Tools/freeze/bkfile.py4
-rwxr-xr-xTools/freeze/freeze.py4
-rw-r--r--Tools/gdb/libpython.py44
-rw-r--r--Tools/importbench/importbench.py31
-rw-r--r--Tools/msi/msi.py11
-rw-r--r--Tools/parser/unparse.py15
-rw-r--r--Tools/scripts/README126
-rwxr-xr-x[-rw-r--r--]Tools/scripts/analyze_dxp.py0
-rwxr-xr-xTools/scripts/byext.py2
-rwxr-xr-xTools/scripts/byteyears.py2
-rwxr-xr-xTools/scripts/checkpyc.py12
-rwxr-xr-xTools/scripts/copytime.py4
-rwxr-xr-xTools/scripts/finddiv.py2
-rwxr-xr-xTools/scripts/findlinksto.py2
-rwxr-xr-xTools/scripts/fixcid.py8
-rwxr-xr-xTools/scripts/ftpmirror.py20
-rwxr-xr-xTools/scripts/linktree.py6
-rwxr-xr-xTools/scripts/parse_html5_entities.py105
-rwxr-xr-xTools/scripts/pathfix.py10
-rwxr-xr-xTools/scripts/pindent.py4
-rwxr-xr-x[-rw-r--r--]Tools/scripts/pydocgui.pyw0
-rwxr-xr-xTools/scripts/reindent.py2
-rwxr-xr-xTools/scripts/treesync.py2
-rwxr-xr-xTools/scripts/untabify.py4
-rwxr-xr-xTools/scripts/which.py2
-rwxr-xr-x[-rw-r--r--]Tools/scripts/win_add2path.py2
-rwxr-xr-xTools/stringbench/stringbench.py2
-rw-r--r--Tools/unicode/makeunicodedata.py6
30 files changed, 280 insertions, 170 deletions
diff --git a/Tools/buildbot/external-amd64.bat b/Tools/buildbot/external-amd64.bat
index d2ff255..a44c662 100644
--- a/Tools/buildbot/external-amd64.bat
+++ b/Tools/buildbot/external-amd64.bat
@@ -6,16 +6,16 @@ call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
if not exist tcltk64\bin\tcl85g.dll (
cd tcl-8.5.11.0\win
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install
+ nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all
+ nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install
cd ..\..
)
if not exist tcltk64\bin\tk85g.dll (
cd tk-8.5.11.0\win
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 clean
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 all
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 install
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 clean
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 all
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 install
cd ..\..
)
diff --git a/Tools/buildbot/external.bat b/Tools/buildbot/external.bat
index ed5c10e..83b3861 100644
--- a/Tools/buildbot/external.bat
+++ b/Tools/buildbot/external.bat
@@ -7,15 +7,15 @@ call "%VS100COMNTOOLS%\vsvars32.bat"
if not exist tcltk\bin\tcl85g.dll (
@rem all and install need to be separate invocations, otherwise nmakehlp is not found on install
cd tcl-8.5.11.0\win
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 INSTALLDIR=..\..\tcltk clean all
+ nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk clean all
nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk install
cd ..\..
)
if not exist tcltk\bin\tk85g.dll (
cd tk-8.5.11.0\win
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 clean
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 all
- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 install
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 clean
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 all
+ nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 install
cd ..\..
)
diff --git a/Tools/freeze/bkfile.py b/Tools/freeze/bkfile.py
index 0e895f2..58246fa 100644
--- a/Tools/freeze/bkfile.py
+++ b/Tools/freeze/bkfile.py
@@ -7,11 +7,11 @@ class _BkFile:
self.__backup = file + '~'
try:
os.unlink(self.__backup)
- except os.error:
+ except OSError:
pass
try:
os.rename(file, self.__backup)
- except os.error:
+ except OSError:
self.__backup = None
self.__file = _orig_open(file, mode, bufsize)
self.closed = self.__file.closed
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index a41267a..479ca3c 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -125,7 +125,7 @@ def main():
# default the exclude list for each platform
if win: exclude = exclude + [
'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix',
- 'os2', 'ce',
+ 'ce',
]
fail_import = exclude[:]
@@ -311,7 +311,7 @@ def main():
try:
os.mkdir(odir)
print("Created output directory", odir)
- except os.error as msg:
+ except OSError as msg:
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
base = ''
if odir:
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 84d4fa3..684713f 100644
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -922,21 +922,26 @@ class PyFrameObjectPtr(PyObjectPtr):
class PySetObjectPtr(PyObjectPtr):
_typename = 'PySetObject'
+ @classmethod
+ def _dummy_key(self):
+ return gdb.lookup_global_symbol('_PySet_Dummy').value()
+
+ def __iter__(self):
+ dummy_ptr = self._dummy_key()
+ table = self.field('table')
+ for i in safe_range(self.field('mask') + 1):
+ setentry = table[i]
+ key = setentry['key']
+ if key != 0 and key != dummy_ptr:
+ yield PyObjectPtr.from_pyobject_ptr(key)
+
def proxyval(self, visited):
# Guard against infinite loops:
if self.as_address() in visited:
return ProxyAlreadyVisited('%s(...)' % self.safe_tp_name())
visited.add(self.as_address())
- members = []
- table = self.field('table')
- for i in safe_range(self.field('mask')+1):
- setentry = table[i]
- key = setentry['key']
- if key != 0:
- key_proxy = PyObjectPtr.from_pyobject_ptr(key).proxyval(visited)
- if key_proxy != '<dummy key>':
- members.append(key_proxy)
+ members = (key.proxyval(visited) for key in self)
if self.safe_tp_name() == 'frozenset':
return frozenset(members)
else:
@@ -965,18 +970,11 @@ class PySetObjectPtr(PyObjectPtr):
out.write('{')
first = True
- table = self.field('table')
- for i in safe_range(self.field('mask')+1):
- setentry = table[i]
- key = setentry['key']
- if key != 0:
- pyop_key = PyObjectPtr.from_pyobject_ptr(key)
- key_proxy = pyop_key.proxyval(visited) # FIXME!
- if key_proxy != '<dummy key>':
- if not first:
- out.write(', ')
- first = False
- pyop_key.write_repr(out, visited)
+ for key in self:
+ if not first:
+ out.write(', ')
+ first = False
+ key.write_repr(out, visited)
out.write('}')
if tp_name != 'set':
@@ -1160,7 +1158,9 @@ class PyUnicodeObjectPtr(PyObjectPtr):
# Convert the int code points to unicode characters, and generate a
# local unicode instance.
# This splits surrogate pairs if sizeof(Py_UNICODE) is 2 here (in gdb).
- result = u''.join([_unichr(ucs) for ucs in Py_UNICODEs])
+ result = u''.join([
+ (_unichr(ucs) if ucs <= 0x10ffff else '\ufffd')
+ for ucs in Py_UNICODEs])
return result
def write_repr(self, out, visited):
diff --git a/Tools/importbench/importbench.py b/Tools/importbench/importbench.py
index 714c0e4..635dd56 100644
--- a/Tools/importbench/importbench.py
+++ b/Tools/importbench/importbench.py
@@ -46,8 +46,7 @@ def from_cache(seconds, repeat):
module.__package__ = ''
with util.uncache(name):
sys.modules[name] = module
- for result in bench(name, repeat=repeat, seconds=seconds):
- yield result
+ yield from bench(name, repeat=repeat, seconds=seconds)
def builtin_mod(seconds, repeat):
@@ -56,9 +55,8 @@ def builtin_mod(seconds, repeat):
if name in sys.modules:
del sys.modules[name]
# Relying on built-in importer being implicit.
- for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
- seconds=seconds):
- yield result
+ yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds)
def source_wo_bytecode(seconds, repeat):
@@ -73,9 +71,8 @@ def source_wo_bytecode(seconds, repeat):
loader = (importlib.machinery.SourceFileLoader,
importlib.machinery.SOURCE_SUFFIXES, True)
sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
- for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
- seconds=seconds):
- yield result
+ yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds)
finally:
sys.dont_write_bytecode = False
@@ -89,9 +86,8 @@ def _wo_bytecode(module):
os.unlink(bytecode_path)
sys.dont_write_bytecode = True
try:
- for result in bench(name, lambda: sys.modules.pop(name),
- repeat=repeat, seconds=seconds):
- yield result
+ yield from bench(name, lambda: sys.modules.pop(name),
+ repeat=repeat, seconds=seconds)
finally:
sys.dont_write_bytecode = False
@@ -127,8 +123,7 @@ def _writing_bytecode(module):
def cleanup():
sys.modules.pop(name)
os.unlink(imp.cache_from_source(module.__file__))
- for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
- yield result
+ yield from bench(name, cleanup, repeat=repeat, seconds=seconds)
writing_bytecode_benchmark.__doc__ = (
writing_bytecode_benchmark.__doc__.format(name))
@@ -148,9 +143,8 @@ def source_using_bytecode(seconds, repeat):
sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
py_compile.compile(mapping[name])
assert os.path.exists(imp.cache_from_source(mapping[name]))
- for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
- seconds=seconds):
- yield result
+ yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds)
def _using_bytecode(module):
@@ -158,9 +152,8 @@ def _using_bytecode(module):
def using_bytecode_benchmark(seconds, repeat):
"""Source w/ bytecode: {}"""
py_compile.compile(module.__file__)
- for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
- seconds=seconds):
- yield result
+ yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds)
using_bytecode_benchmark.__doc__ = (
using_bytecode_benchmark.__doc__.format(name))
diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py
index 5ed025d..73f1c83 100644
--- a/Tools/msi/msi.py
+++ b/Tools/msi/msi.py
@@ -99,7 +99,9 @@ extensions = [
'_multiprocessing.pyd',
'_lzma.pyd',
'_decimal.pyd',
- '_testbuffer.pyd'
+ '_testbuffer.pyd',
+ '_sha3.pyd',
+ '_testimportmultiple.pyd',
]
# Well-known component UUIDs
@@ -119,6 +121,7 @@ pythondll_uuid = {
"31":"{4afcba0b-13e4-47c3-bebe-477428b46913}",
"32":"{3ff95315-1096-4d31-bd86-601d5438ad5e}",
"33":"{f7581ca4-d368-4eea-8f82-d48c64c4f047}",
+ "34":"{7A0C5812-2583-40D9-BCBB-CD7485F11377}",
} [major+minor]
# Compute the name that Sphinx gives to the docfile
@@ -954,8 +957,6 @@ def add_files(db):
# Add all executables, icons, text files into the TARGETDIR component
root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
default_feature.set_current()
- if not msilib.Win64:
- root.add_file("%s/w9xpopen.exe" % PCBUILD)
root.add_file("README.txt", src="README")
root.add_file("NEWS.txt", src="Misc/NEWS")
generate_license()
@@ -1269,6 +1270,10 @@ def add_registry(db):
"{60254CA5-953B-11CF-8C96-00AA00B8708C}", "REGISTRY.def"),
])
+ # PATHEXT
+ add_data(db, "Environment",
+ [("PathExtAddition", "=-*PathExt", "[~];.PY", "REGISTRY.def")])
+
# Registry keys
prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
add_data(db, "Registry",
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py
index b55e2c6..837cd81 100644
--- a/Tools/parser/unparse.py
+++ b/Tools/parser/unparse.py
@@ -307,6 +307,9 @@ class Unparser:
def _Name(self, t):
self.write(t.id)
+ def _NameConstant(self, t):
+ self.write(repr(t.value))
+
def _Num(self, t):
# Substitute overflowing decimal literal for AST infinities.
self.write(repr(t.n).replace("inf", INFSTR))
@@ -515,10 +518,10 @@ class Unparser:
else: self.write(", ")
self.write("*")
if t.vararg:
- self.write(t.vararg)
- if t.varargannotation:
+ self.write(t.vararg.arg)
+ if t.vararg.annotation:
self.write(": ")
- self.dispatch(t.varargannotation)
+ self.dispatch(t.vararg.annotation)
# keyword-only arguments
if t.kwonlyargs:
@@ -534,10 +537,10 @@ class Unparser:
if t.kwarg:
if first:first = False
else: self.write(", ")
- self.write("**"+t.kwarg)
- if t.kwargannotation:
+ self.write("**"+t.kwarg.arg)
+ if t.kwarg.annotation:
self.write(": ")
- self.dispatch(t.kwargannotation)
+ self.dispatch(t.kwarg.annotation)
def _keyword(self, t):
self.write(t.arg)
diff --git a/Tools/scripts/README b/Tools/scripts/README
index d65d1fd..c6b2282 100644
--- a/Tools/scripts/README
+++ b/Tools/scripts/README
@@ -2,64 +2,68 @@ This directory contains a collection of executable Python scripts that are
useful while building, extending or managing Python. Some (e.g., dutree or lll)
are also generally useful UNIX tools.
-2to3 Main script for running the 2to3 conversion tool
-analyze_dxp.py Analyzes the result of sys.getdxp()
-byext.py Print lines/words/chars stats of files by extension
-byteyears.py Print product of a file's size and age
-checkpyc.py Check presence and validity of ".pyc" files
-cleanfuture.py Fix redundant Python __future__ statements
-combinerefs.py A helper for analyzing PYTHONDUMPREFS output
-copytime.py Copy one file's atime and mtime to another
-crlf.py Change CRLF line endings to LF (Windows to Unix)
-db2pickle.py Dump a database file to a pickle
-diff.py Print file diffs in context, unified, or ndiff formats
-dutree.py Format du(1) output as a tree sorted by size
-eptags.py Create Emacs TAGS file for Python modules
-find_recursionlimit.py Find the maximum recursion limit on this machine
-finddiv.py A grep-like tool that looks for division operators
-findlinksto.py Recursively find symbolic links to a given path prefix
-findnocoding.py Find source files which need an encoding declaration
-fixcid.py Massive identifier substitution on C source files
-fixdiv.py Tool to fix division operators.
-fixheader.py Add some cpp magic to a C include file
-fixnotice.py Fix the copyright notice in source files
-fixps.py Fix Python scripts' first line (if #!)
-ftpmirror.py FTP mirror script
-google.py Open a webbrowser with Google
-gprof2html.py Transform gprof(1) output into useful HTML
-h2py.py Translate #define's into Python assignments
-highlight.py Python syntax highlighting with HTML output
-idle3 Main program to start IDLE
-ifdef.py Remove #if(n)def groups from C sources
-lfcr.py Change LF line endings to CRLF (Unix to Windows)
-linktree.py Make a copy of a tree with links to original files
-lll.py Find and list symbolic links in current directory
-mailerdaemon.py Parse error messages from mailer daemons (Sjoerd&Jack)
-make_ctype.py Generate ctype.h replacement in stringobject.c
-md5sum.py Print MD5 checksums of argument files
-mkreal.py Turn a symbolic link into a real file or directory
-ndiff.py Intelligent diff between text files (Tim Peters)
-nm2def.py Create a template for PC/python_nt.def (Marc Lemburg)
-objgraph.py Print object graph from nm output on a library
-parseentities.py Utility for parsing HTML entity definitions
-patchcheck.py Perform common checks and cleanup before committing
-pathfix.py Change #!/usr/local/bin/python into something else
-pdeps.py Print dependencies between Python modules
-pickle2db.py Load a pickle generated by db2pickle.py to a database
-pindent.py Indent Python code, giving block-closing comments
-ptags.py Create vi tags file for Python modules
-pydoc3 Python documentation browser
-pysource.py Find Python source files
-redemo.py Basic regular expression demonstration facility
-reindent.py Change .py files to use 4-space indents
-reindent-rst.py Fix-up reStructuredText file whitespace
-rgrep.py Reverse grep through a file (useful for big logfiles)
-run_tests.py Run the test suite with more sensible default options
-serve.py Small wsgiref-based web server, used in make serve in Doc
-suff.py Sort a list of files by suffix
-svneol.py Set svn:eol-style on all files in directory
-texi2html.py Convert GNU texinfo files into HTML
-treesync.py Synchronize source trees (very idiosyncratic)
-untabify.py Replace tabs with spaces in argument files
-win_add2path.py Add Python to the search path on Windows
-which.py Find a program in $PATH
+2to3 Main script for running the 2to3 conversion tool
+abitype.py Converts a C file to use the PEP 384 type definition API
+analyze_dxp.py Analyzes the result of sys.getdxp()
+byext.py Print lines/words/chars stats of files by extension
+byteyears.py Print product of a file's size and age
+checkpyc.py Check presence and validity of ".pyc" files
+cleanfuture.py Fix redundant Python __future__ statements
+combinerefs.py A helper for analyzing PYTHONDUMPREFS output
+copytime.py Copy one file's atime and mtime to another
+crlf.py Change CRLF line endings to LF (Windows to Unix)
+db2pickle.py Dump a database file to a pickle
+diff.py Print file diffs in context, unified, or ndiff formats
+dutree.py Format du(1) output as a tree sorted by size
+eptags.py Create Emacs TAGS file for Python modules
+finddiv.py A grep-like tool that looks for division operators
+findlinksto.py Recursively find symbolic links to a given path prefix
+findnocoding.py Find source files which need an encoding declaration
+find_recursionlimit.py Find the maximum recursion limit on this machine
+find-uname.py Look for the given arguments in the sets of all Unicode names
+fixcid.py Massive identifier substitution on C source files
+fixdiv.py Tool to fix division operators.
+fixheader.py Add some cpp magic to a C include file
+fixnotice.py Fix the copyright notice in source files
+fixps.py Fix Python scripts' first line (if #!)
+ftpmirror.py FTP mirror script
+get-remote-certificate.py Fetch the certificate that the server(s) are providing in PEM form
+google.py Open a webbrowser with Google
+gprof2html.py Transform gprof(1) output into useful HTML
+h2py.py Translate #define's into Python assignments
+highlight.py Python syntax highlighting with HTML output
+idle3 Main program to start IDLE
+ifdef.py Remove #if(n)def groups from C sources
+import_diagnostics.py Miscellaneous diagnostics for the import system
+lfcr.py Change LF line endings to CRLF (Unix to Windows)
+linktree.py Make a copy of a tree with links to original files
+lll.py Find and list symbolic links in current directory
+mailerdaemon.py Parse error messages from mailer daemons (Sjoerd&Jack)
+make_ctype.py Generate ctype.h replacement in stringobject.c
+md5sum.py Print MD5 checksums of argument files
+mkreal.py Turn a symbolic link into a real file or directory
+ndiff.py Intelligent diff between text files (Tim Peters)
+nm2def.py Create a template for PC/python_nt.def (Marc Lemburg)
+objgraph.py Print object graph from nm output on a library
+parseentities.py Utility for parsing HTML entity definitions
+parse_html5_entities.py Utility for parsing HTML5 entity definitions
+patchcheck.py Perform common checks and cleanup before committing
+pathfix.py Change #!/usr/local/bin/python into something else
+pdeps.py Print dependencies between Python modules
+pickle2db.py Load a pickle generated by db2pickle.py to a database
+pindent.py Indent Python code, giving block-closing comments
+ptags.py Create vi tags file for Python modules
+pydoc3 Python documentation browser
+pysource.py Find Python source files
+reindent.py Change .py files to use 4-space indents
+reindent-rst.py Fix-up reStructuredText file whitespace
+rgrep.py Reverse grep through a file (useful for big logfiles)
+run_tests.py Run the test suite with more sensible default options
+serve.py Small wsgiref-based web server, used in make serve in Doc
+suff.py Sort a list of files by suffix
+svneol.py Set svn:eol-style on all files in directory
+texi2html.py Convert GNU texinfo files into HTML
+treesync.py Synchronize source trees (very idiosyncratic)
+untabify.py Replace tabs with spaces in argument files
+which.py Find a program in $PATH
+win_add2path.py Add Python to the search path on Windows
diff --git a/Tools/scripts/analyze_dxp.py b/Tools/scripts/analyze_dxp.py
index bde931e..bde931e 100644..100755
--- a/Tools/scripts/analyze_dxp.py
+++ b/Tools/scripts/analyze_dxp.py
diff --git a/Tools/scripts/byext.py b/Tools/scripts/byext.py
index b79ff37..736a441 100755
--- a/Tools/scripts/byext.py
+++ b/Tools/scripts/byext.py
@@ -25,7 +25,7 @@ class Stats:
self.addstats("<dir>", "dirs", 1)
try:
names = os.listdir(dir)
- except os.error as err:
+ except OSError as err:
sys.stderr.write("Can't list %s: %s\n" % (dir, err))
self.addstats("<dir>", "unlistable", 1)
return
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py
index 490b37f..f58c346 100755
--- a/Tools/scripts/byteyears.py
+++ b/Tools/scripts/byteyears.py
@@ -43,7 +43,7 @@ def main():
for filename in sys.argv[1:]:
try:
st = statfunc(filename)
- except os.error as msg:
+ except OSError as msg:
sys.stderr.write("can't stat %r: %r\n" % (filename, msg))
status = 1
st = ()
diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py
index d4fdce2..bbaa3d1 100755
--- a/Tools/scripts/checkpyc.py
+++ b/Tools/scripts/checkpyc.py
@@ -5,11 +5,11 @@
import sys
import os
from stat import ST_MTIME
-import imp
+import importlib.util
# PEP 3147 compatibility (PYC Repository Directories)
-cache_from_source = (imp.cache_from_source if hasattr(imp, 'get_tag') else
- lambda path: path + 'c')
+cache_from_source = (importlib.util.cache_from_source if sys.implementation.cache_tag
+ else lambda path: path + 'c')
def main():
@@ -18,13 +18,13 @@ def main():
silent = (sys.argv[1] == '-s')
else:
verbose = silent = False
- MAGIC = imp.get_magic()
+ MAGIC = importlib.util.MAGIC_NUMBER
if not silent:
print('Using MAGIC word', repr(MAGIC))
for dirname in sys.path:
try:
names = os.listdir(dirname)
- except os.error:
+ except OSError:
print('Cannot list directory', repr(dirname))
continue
if not silent:
@@ -34,7 +34,7 @@ def main():
name = os.path.join(dirname, name)
try:
st = os.stat(name)
- except os.error:
+ except OSError:
print('Cannot stat', repr(name))
continue
if verbose:
diff --git a/Tools/scripts/copytime.py b/Tools/scripts/copytime.py
index e0220b5..715683f 100755
--- a/Tools/scripts/copytime.py
+++ b/Tools/scripts/copytime.py
@@ -13,12 +13,12 @@ def main():
file1, file2 = sys.argv[1], sys.argv[2]
try:
stat1 = os.stat(file1)
- except os.error:
+ except OSError:
sys.stderr.write(file1 + ': cannot stat\n')
sys.exit(1)
try:
os.utime(file2, (stat1[ST_ATIME], stat1[ST_MTIME]))
- except os.error:
+ except OSError:
sys.stderr.write(file2 + ': cannot change time\n')
sys.exit(2)
diff --git a/Tools/scripts/finddiv.py b/Tools/scripts/finddiv.py
index f24a702..a705f56 100755
--- a/Tools/scripts/finddiv.py
+++ b/Tools/scripts/finddiv.py
@@ -70,7 +70,7 @@ def process(filename, listnames):
def processdir(dir, listnames):
try:
names = os.listdir(dir)
- except os.error as msg:
+ except OSError as msg:
sys.stderr.write("Can't list directory: %s\n" % dir)
return 1
files = []
diff --git a/Tools/scripts/findlinksto.py b/Tools/scripts/findlinksto.py
index b4c09ef..b924f27 100755
--- a/Tools/scripts/findlinksto.py
+++ b/Tools/scripts/findlinksto.py
@@ -36,7 +36,7 @@ def visit(prog, dirname, names):
linkto = os.readlink(name)
if prog.search(linkto) is not None:
print(name, '->', linkto)
- except os.error:
+ except OSError:
pass
if __name__ == '__main__':
diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 87e2a09..1e4c428 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -97,7 +97,7 @@ def recursedown(dirname):
bad = 0
try:
names = os.listdir(dirname)
- except os.error as msg:
+ except OSError as msg:
err(dirname + ': cannot list directory: ' + str(msg) + '\n')
return 1
names.sort()
@@ -175,17 +175,17 @@ def fix(filename):
try:
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 0o7777)
- except os.error as msg:
+ except OSError as msg:
err(tempname + ': warning: chmod failed (' + str(msg) + ')\n')
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
- except os.error as msg:
+ except OSError as msg:
err(filename + ': warning: backup failed (' + str(msg) + ')\n')
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
- except os.error as msg:
+ except OSError as msg:
err(filename + ': rename failed (' + str(msg) + ')\n')
return 1
# Return success
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index 9e8be1d..a1b683a 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -108,7 +108,7 @@ def mirrorsubdir(f, localdir):
if verbose: print('Creating local directory', repr(localdir))
try:
makedir(localdir)
- except os.error as msg:
+ except OSError as msg:
print("Failed to establish local directory", repr(localdir))
return
infofilename = os.path.join(localdir, '.mirrorinfo')
@@ -183,7 +183,7 @@ def mirrorsubdir(f, localdir):
continue
try:
os.unlink(tempname)
- except os.error:
+ except OSError:
pass
if mode[0] == 'l':
if verbose:
@@ -218,11 +218,11 @@ def mirrorsubdir(f, localdir):
fp1.close()
try:
os.unlink(fullname)
- except os.error:
+ except OSError:
pass # Ignore the error
try:
os.rename(tempname, fullname)
- except os.error as msg:
+ except OSError as msg:
print("Can't rename %r to %r: %s" % (tempname, fullname, msg))
continue
info[filename] = infostuff
@@ -255,7 +255,7 @@ def mirrorsubdir(f, localdir):
try:
if not localdir: names = os.listdir(os.curdir)
else: names = os.listdir(localdir)
- except os.error:
+ except OSError:
names = []
for name in names:
if name[0] == '.' or name in info or name in subdirs:
@@ -312,7 +312,7 @@ def remove(fullname):
if os.path.isdir(fullname) and not os.path.islink(fullname):
try:
names = os.listdir(fullname)
- except os.error:
+ except OSError:
names = []
ok = 1
for name in names:
@@ -322,13 +322,13 @@ def remove(fullname):
return 0
try:
os.rmdir(fullname)
- except os.error as msg:
+ except OSError as msg:
print("Can't remove local directory %r: %s" % (fullname, msg))
return 0
else:
try:
os.unlink(fullname)
- except os.error as msg:
+ except OSError as msg:
print("Can't remove local file %r: %s" % (fullname, msg))
return 0
return 1
@@ -386,7 +386,7 @@ def writedict(dict, filename):
backup = os.path.join(dir, fname + '~')
try:
os.unlink(backup)
- except os.error:
+ except OSError:
pass
fp = open(tempname, 'w')
fp.write('{\n')
@@ -396,7 +396,7 @@ def writedict(dict, filename):
fp.close()
try:
os.rename(filename, backup)
- except os.error:
+ except OSError:
pass
os.rename(tempname, filename)
diff --git a/Tools/scripts/linktree.py b/Tools/scripts/linktree.py
index 982f480..e83f198 100755
--- a/Tools/scripts/linktree.py
+++ b/Tools/scripts/linktree.py
@@ -32,13 +32,13 @@ def main():
return 1
try:
os.mkdir(newtree, 0o777)
- except os.error as msg:
+ except OSError as msg:
print(newtree + ': cannot mkdir:', msg)
return 1
linkname = os.path.join(newtree, link)
try:
os.symlink(os.path.join(os.pardir, oldtree), linkname)
- except os.error as msg:
+ except OSError as msg:
if not link_may_fail:
print(linkname + ': cannot symlink:', msg)
return 1
@@ -51,7 +51,7 @@ def linknames(old, new, link):
if debug: print('linknames', (old, new, link))
try:
names = os.listdir(old)
- except os.error as msg:
+ except OSError as msg:
print(old + ': warning: cannot listdir:', msg)
return
for name in names:
diff --git a/Tools/scripts/parse_html5_entities.py b/Tools/scripts/parse_html5_entities.py
new file mode 100755
index 0000000..c011328
--- /dev/null
+++ b/Tools/scripts/parse_html5_entities.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+"""
+Utility for parsing HTML5 entity definitions available from:
+
+ http://dev.w3.org/html5/spec/entities.json
+
+Written by Ezio Melotti and Iuliia Proskurnia.
+
+"""
+
+import os
+import sys
+import json
+from urllib.request import urlopen
+from html.entities import html5
+
+entities_url = 'http://dev.w3.org/html5/spec/entities.json'
+
+def get_json(url):
+ """Download the json file from the url and returns a decoded object."""
+ with urlopen(url) as f:
+ data = f.read().decode('utf-8')
+ return json.loads(data)
+
+def create_dict(entities):
+ """Create the html5 dict from the decoded json object."""
+ new_html5 = {}
+ for name, value in entities.items():
+ new_html5[name.lstrip('&')] = value['characters']
+ return new_html5
+
+def compare_dicts(old, new):
+ """Compare the old and new dicts and print the differences."""
+ added = new.keys() - old.keys()
+ if added:
+ print('{} entitie(s) have been added:'.format(len(added)))
+ for name in sorted(added):
+ print(' {!r}: {!r}'.format(name, new[name]))
+ removed = old.keys() - new.keys()
+ if removed:
+ print('{} entitie(s) have been removed:'.format(len(removed)))
+ for name in sorted(removed):
+ print(' {!r}: {!r}'.format(name, old[name]))
+ changed = set()
+ for name in (old.keys() & new.keys()):
+ if old[name] != new[name]:
+ changed.add((name, old[name], new[name]))
+ if changed:
+ print('{} entitie(s) have been modified:'.format(len(changed)))
+ for item in sorted(changed):
+ print(' {!r}: {!r} -> {!r}'.format(*item))
+
+def write_items(entities, file=sys.stdout):
+ """Write the items of the dictionary in the specified file."""
+ # The keys in the generated dictionary should be sorted
+ # in a case-insensitive way, however, when two keys are equal,
+ # the uppercase version should come first so that the result
+ # looks like: ['Aacute', 'aacute', 'Aacute;', 'aacute;', ...]
+ # To do this we first sort in a case-sensitive way (so all the
+ # uppercase chars come first) and then sort with key=str.lower.
+ # Since the sorting is stable the uppercase keys will eventually
+ # be before their equivalent lowercase version.
+ keys = sorted(entities.keys())
+ keys = sorted(keys, key=str.lower)
+ print('html5 = {', file=file)
+ for name in keys:
+ print(' {!r}: {!a},'.format(name, entities[name]), file=file)
+ print('}', file=file)
+
+
+if __name__ == '__main__':
+ # without args print a diff between html.entities.html5 and new_html5
+ # with --create print the new html5 dict
+ # with --patch patch the Lib/html/entities.py file
+ new_html5 = create_dict(get_json(entities_url))
+ if '--create' in sys.argv:
+ print('# map the HTML5 named character references to the '
+ 'equivalent Unicode character(s)')
+ print('# Generated by {}. Do not edit manually.'.format(__file__))
+ write_items(new_html5)
+ elif '--patch' in sys.argv:
+ fname = 'Lib/html/entities.py'
+ temp_fname = fname + '.temp'
+ with open(fname) as f1, open(temp_fname, 'w') as f2:
+ skip = False
+ for line in f1:
+ if line.startswith('html5 = {'):
+ write_items(new_html5, file=f2)
+ skip = True
+ continue
+ if skip:
+ # skip the old items until the }
+ if line.startswith('}'):
+ skip = False
+ continue
+ f2.write(line)
+ os.remove(fname)
+ os.rename(temp_fname, fname)
+ else:
+ if html5 == new_html5:
+ print('The current dictionary is updated.')
+ else:
+ compare_dicts(html5, new_html5)
+ print('Run "./python {0} --patch" to update Lib/html/entities.html '
+ 'or "./python {0} --create" to see the generated ' 'dictionary.'.format(__file__))
diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py
index dd08e0a..ae15561 100755
--- a/Tools/scripts/pathfix.py
+++ b/Tools/scripts/pathfix.py
@@ -73,7 +73,7 @@ def recursedown(dirname):
bad = 0
try:
names = os.listdir(dirname)
- except os.error as msg:
+ except OSError as msg:
err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
@@ -131,24 +131,24 @@ def fix(filename):
mtime = statbuf.st_mtime
atime = statbuf.st_atime
os.chmod(tempname, statbuf[ST_MODE] & 0o7777)
- except os.error as msg:
+ except OSError as msg:
err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
- except os.error as msg:
+ except OSError as msg:
err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
- except os.error as msg:
+ except OSError as msg:
err('%s: rename failed (%r)\n' % (filename, msg))
return 1
if preserve_timestamps:
if atime and mtime:
try:
os.utime(filename, (atime, mtime))
- except os.error as msg:
+ except OSError as msg:
err('%s: reset of timestamp failed (%r)\n' % (filename, msg))
return 1
# Return succes
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
index 2872dc0..3333420 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -376,13 +376,13 @@ def make_backup(filename):
if os.path.lexists(backup):
try:
os.remove(backup)
- except os.error:
+ except OSError:
print("Can't remove backup %r" % (backup,), file=sys.stderr)
# end try
# end if
try:
os.rename(filename, backup)
- except os.error:
+ except OSError:
print("Can't rename %r to %r" % (filename, backup), file=sys.stderr)
# end try
# end def make_backup
diff --git a/Tools/scripts/pydocgui.pyw b/Tools/scripts/pydocgui.pyw
index 8e9a3d6..8e9a3d6 100644..100755
--- a/Tools/scripts/pydocgui.pyw
+++ b/Tools/scripts/pydocgui.pyw
diff --git a/Tools/scripts/reindent.py b/Tools/scripts/reindent.py
index 4a916ea..18424de 100755
--- a/Tools/scripts/reindent.py
+++ b/Tools/scripts/reindent.py
@@ -52,8 +52,8 @@ verbose = False
recurse = False
dryrun = False
makebackup = True
+# A specified newline to be used in the output (set by --newline option)
spec_newline = None
-"""A specified newline to be used in the output (set by --newline option)"""
def usage(msg=None):
diff --git a/Tools/scripts/treesync.py b/Tools/scripts/treesync.py
index b2649c4..652d394 100755
--- a/Tools/scripts/treesync.py
+++ b/Tools/scripts/treesync.py
@@ -78,7 +78,7 @@ def process(slave, master):
print("creating slave directory", slave)
try:
os.mkdir(slave)
- except os.error as msg:
+ except OSError as msg:
print("can't make slave directory", slave, ":", msg)
return
else:
diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py
index 4b67c15..861c83c 100755
--- a/Tools/scripts/untabify.py
+++ b/Tools/scripts/untabify.py
@@ -39,11 +39,11 @@ def process(filename, tabsize, verbose=True):
backup = filename + "~"
try:
os.unlink(backup)
- except os.error:
+ except OSError:
pass
try:
os.rename(filename, backup)
- except os.error:
+ except OSError:
pass
with open(filename, "w", encoding=encoding) as f:
f.write(newtext)
diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py
index 4fc37a0..df54ce0 100755
--- a/Tools/scripts/which.py
+++ b/Tools/scripts/which.py
@@ -29,7 +29,7 @@ def main():
filename = os.path.join(dir, prog)
try:
st = os.stat(filename)
- except os.error:
+ except OSError:
continue
if not S_ISREG(st[ST_MODE]):
msg(filename + ': not a disk file')
diff --git a/Tools/scripts/win_add2path.py b/Tools/scripts/win_add2path.py
index 9259b44..c85bea5 100644..100755
--- a/Tools/scripts/win_add2path.py
+++ b/Tools/scripts/win_add2path.py
@@ -30,7 +30,7 @@ def modify():
with winreg.CreateKey(HKCU, ENV) as key:
try:
envpath = winreg.QueryValueEx(key, PATH)[0]
- except WindowsError:
+ except OSError:
envpath = DEFAULT
paths = [envpath]
diff --git a/Tools/stringbench/stringbench.py b/Tools/stringbench/stringbench.py
index a0a21fa..c72e16d 100755
--- a/Tools/stringbench/stringbench.py
+++ b/Tools/stringbench/stringbench.py
@@ -808,7 +808,7 @@ standard libraries, and can be learned in a few days. Many Python
programmers report substantial productivity gains and feel the language
encourages the development of higher quality, more maintainable code.
-Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm
+Python runs on Windows, Linux/Unix, Mac OS X, Amiga, Palm
Handhelds, and Nokia mobile phones. Python has also been ported to the
Java and .NET virtual machines.
diff --git a/Tools/unicode/makeunicodedata.py b/Tools/unicode/makeunicodedata.py
index d83cf63..01021c8 100644
--- a/Tools/unicode/makeunicodedata.py
+++ b/Tools/unicode/makeunicodedata.py
@@ -37,7 +37,7 @@ SCRIPT = sys.argv[0]
VERSION = "3.2"
# The Unicode Database
-UNIDATA_VERSION = "6.1.0"
+UNIDATA_VERSION = "6.2.0"
UNICODE_DATA = "UnicodeData%s.txt"
COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt"
EASTASIAN_WIDTH = "EastAsianWidth%s.txt"
@@ -552,7 +552,7 @@ def makeunicodetype(unicode, trace):
print("/* Returns 1 for Unicode characters having the bidirectional", file=fp)
print(" * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise.", file=fp)
print(" */", file=fp)
- print('int _PyUnicode_IsWhitespace(register const Py_UCS4 ch)', file=fp)
+ print('int _PyUnicode_IsWhitespace(const Py_UCS4 ch)', file=fp)
print('{', file=fp)
print(' switch (ch) {', file=fp)
@@ -570,7 +570,7 @@ def makeunicodetype(unicode, trace):
print(" * property 'BK', 'CR', 'LF' or 'NL' or having bidirectional", file=fp)
print(" * type 'B', 0 otherwise.", file=fp)
print(" */", file=fp)
- print('int _PyUnicode_IsLinebreak(register const Py_UCS4 ch)', file=fp)
+ print('int _PyUnicode_IsLinebreak(const Py_UCS4 ch)', file=fp)
print('{', file=fp)
print(' switch (ch) {', file=fp)
for codepoint in sorted(linebreaks):