merge 2.7.15 release branch
diff --git a/.travis.yml b/.travis.yml
index 175432d..695b5a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,11 @@
- pip
- ccache
+env:
+ global:
+ # Use -O3 because we don't use debugger on Travis-CI
+ - CFLAGS="-O3"
+
branches:
only:
- master
diff --git a/Doc/distutils/introduction.rst b/Doc/distutils/introduction.rst
index fc6184f..5229e64 100644
--- a/Doc/distutils/introduction.rst
+++ b/Doc/distutils/introduction.rst
@@ -193,8 +193,8 @@
module distribution
a collection of Python modules distributed together as a single downloadable
resource and meant to be installed *en masse*. Examples of some well-known
- module distributions are Numeric Python, PyXML, PIL (the Python Imaging
- Library), or mxBase. (This would be called a *package*, except that term is
+ module distributions are Numeric Python, PyXML, Pillow,
+ or mxBase. (This would be called a *package*, except that term is
already taken in the Python context: a single module distribution may contain
zero, one, or many Python packages.)
diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
index ce5e63a..3356e4e 100644
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -11,6 +11,11 @@
platforms, as well as on Windows systems. (Tk itself is not part of Python; it
is maintained at ActiveState.)
+Running ``python -m Tkinter`` from the command line should open a window
+demonstrating a simple Tk interface, letting you know that :mod:`Tkinter` is
+properly installed on your system, and also showing what version of Tcl/Tk is
+installed, so you can read the Tcl/Tk documentation specific to that version.
+
.. note::
:mod:`Tkinter` has been renamed to :mod:`tkinter` in Python 3. The
@@ -19,6 +24,8 @@
.. seealso::
+ Tkinter documentation:
+
`Python Tkinter Resources <https://wiki.python.org/moin/TkInter>`_
The Python Tkinter Topic Guide provides a great deal of information on using Tk
from Python and links to other sources of information on Tk.
@@ -32,17 +39,32 @@
`Tkinter docs from effbot <http://effbot.org/tkinterbook/>`_
Online reference for tkinter supported by effbot.org.
- `Tcl/Tk manual <https://www.tcl.tk/man/tcl8.5/>`_
- Official manual for the latest tcl/tk version.
-
- `Programming Python <http://learning-python.com/books/about-pp4e.html>`_
+ `Programming Python <http://learning-python.com/about-pp4e.html>`_
Book by Mark Lutz, has excellent coverage of Tkinter.
- `Modern Tkinter for Busy Python Developers <http://www.amazon.com/Modern-Tkinter-Python-Developers-ebook/dp/B0071QDNLO/>`_
+ `Modern Tkinter for Busy Python Developers <https://www.amazon.com/Modern-Tkinter-Python-Developers-ebook/dp/B0071QDNLO/>`_
Book by Mark Rozerman about building attractive and modern graphical user interfaces with Python and Tkinter.
`Python and Tkinter Programming <https://www.manning.com/books/python-and-tkinter-programming>`_
- The book by John Grayson (ISBN 1-884777-81-3).
+ Book by John Grayson (ISBN 1-884777-81-3).
+
+ Tcl/Tk documentation:
+
+ `Tk commands <https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm>`_
+ Most commands are available as :mod:`Tkinter` or :mod:`Tkinter.ttk` classes.
+ Change '8.6' to match the version of your Tcl/Tk installation.
+
+ `Tcl/Tk recent man pages <https://www.tcl.tk/doc/>`_
+ Recent Tcl/Tk manuals on www.tcl.tk.
+
+ `ActiveState Tcl Home Page <http://tcl.activestate.com/>`_
+ The Tk/Tcl development is largely taking place at ActiveState.
+
+ `Tcl and the Tk Toolkit <https://www.amazon.com/exec/obidos/ASIN/020163337X>`_
+ Book by John Ousterhout, the inventor of Tcl.
+
+ `Practical Programming in Tcl and Tk <http://www.beedub.com/book/>`_
+ Brent Welch's encyclopedic book.
Tkinter Modules
@@ -182,18 +204,6 @@
when nothing else makes sense.
-.. seealso::
-
- `ActiveState Tcl Home Page <http://tcl.activestate.com/>`_
- The Tk/Tcl development is largely taking place at ActiveState.
-
- `Tcl and the Tk Toolkit <http://www.amazon.com/exec/obidos/ASIN/020163337X>`_
- The book by John Ousterhout, the inventor of Tcl.
-
- `Practical Programming in Tcl and Tk <http://www.beedub.com/book/>`_
- Brent Welch's encyclopedic book.
-
-
A Simple Hello World Program
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -801,12 +811,13 @@
Images
^^^^^^
-Bitmap/Pixelmap images can be created through the subclasses of
-:class:`Tkinter.Image`:
+Images of different formats can be created through the corresponding subclass
+of :class:`Tkinter.Image`:
-* :class:`BitmapImage` can be used for X11 bitmap data.
+* :class:`BitmapImage` for images in XBM format.
-* :class:`PhotoImage` can be used for GIF and PPM/PGM color bitmaps.
+* :class:`PhotoImage` for images in PGM, PPM, GIF and PNG formats. The latter
+ is supported starting with Tk 8.6.
Either type of image is created through either the ``file`` or the ``data``
option (other options are available as well).
@@ -817,6 +828,10 @@
deleted, the image data is deleted as well, and Tk will display an empty box
wherever the image was used.
+.. seealso::
+
+ The `Pillow <http://python-pillow.org/>`_ package adds support for
+ formats such as BMP, JPEG, TIFF, and WebP, among others.
.. _tkinter-file-handlers:
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index 7bbd580..8c45274 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -15,9 +15,11 @@
from docutils import nodes, utils
from docutils.parsers.rst import Directive
+from sphinx.util import status_iterator
from sphinx.util.nodes import split_explicit_title
from sphinx.writers.html import HTMLTranslator
from sphinx.writers.latex import LaTeXTranslator
+from sphinx.writers.text import TextTranslator
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
from docutils.parsers.rst.states import Body
@@ -158,8 +160,11 @@
class PydocTopicsBuilder(Builder):
name = 'pydoc-topics'
+ default_translator_class = TextTranslator
+
def init(self):
self.topics = {}
+ self.secnumbers = {}
def get_outdated_docs(self):
return 'all pydoc topics'
@@ -169,9 +174,9 @@
def write(self, *ignored):
writer = TextWriter(self)
- for label in self.status_iterator(pydoc_topic_labels,
- 'building topics... ',
- length=len(pydoc_topic_labels)):
+ for label in status_iterator(pydoc_topic_labels,
+ 'building topics... ',
+ length=len(pydoc_topic_labels)):
if label not in self.env.domaindata['std']['labels']:
self.warn('label %r not in documentation' % label)
continue
diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst
index ec3bd9c..042d233 100644
--- a/Doc/tutorial/modules.rst
+++ b/Doc/tutorial/modules.rst
@@ -377,7 +377,7 @@
named ``B`` in a package named ``A``. Just like the use of modules saves the
authors of different modules from having to worry about each other's global
variable names, the use of dotted module names saves the authors of multi-module
-packages like NumPy or the Python Imaging Library from having to worry about
+packages like NumPy or Pillow from having to worry about
each other's module names.
Suppose you want to design a collection of modules (a "package") for the uniform
diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py
index 1dd5a3b..60b7be9 100644
--- a/Lib/curses/has_key.py
+++ b/Lib/curses/has_key.py
@@ -182,7 +182,7 @@
L = []
_curses.initscr()
for key in _capability_names.keys():
- system = key in _curses
+ system = _curses.has_key(key)
python = has_key(key)
if system != python:
L.append( 'Mismatch for key %s, system=%i, Python=%i'
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index 89ed1ef..49d74cd 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -14,7 +14,7 @@
_SETUPTOOLS_VERSION = "39.0.1"
-_PIP_VERSION = "9.0.3"
+_PIP_VERSION = "10.0.1"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
@@ -28,8 +28,8 @@
sys.path = additional_paths + sys.path
# Install the bundled software
- import pip
- return pip.main(args)
+ import pip._internal
+ return pip._internal.main(args)
def version():
diff --git a/Lib/ensurepip/_bundled/pip-10.0.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/pip-10.0.1-py2.py3-none-any.whl
new file mode 100644
index 0000000..9837092
--- /dev/null
+++ b/Lib/ensurepip/_bundled/pip-10.0.1-py2.py3-none-any.whl
Binary files differ
diff --git a/Lib/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl
deleted file mode 100644
index 5d33bba..0000000
--- a/Lib/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl
+++ /dev/null
Binary files differ
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 6198c4c..b226fd5 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -3362,7 +3362,7 @@
self.tk.call('image', 'width', self.name))
class PhotoImage(Image):
- """Widget which can display colored images in GIF, PPM/PGM format."""
+ """Widget which can display images in PGM, PPM, GIF, PNG format."""
def __init__(self, name=None, cnf={}, master=None, **kw):
"""Create an image with NAME.
@@ -3426,7 +3426,7 @@
self.tk.call(args)
class BitmapImage(Image):
- """Widget which can display a bitmap."""
+ """Widget which can display images in XBM format."""
def __init__(self, name=None, cnf={}, master=None, **kw):
"""Create a bitmap with NAME.
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 34b9cbb..73974a9 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -263,21 +263,19 @@
# An absolutely minimal test of position information. Better
# tests would be a big project.
code = "def f(x):\n return x + 1"
- st1 = parser.suite(code)
- st2 = st1.totuple(line_info=1, col_info=1)
+ st = parser.suite(code)
def walk(tree):
node_type = tree[0]
next = tree[1]
- if isinstance(next, tuple):
+ if isinstance(next, (tuple, list)):
for elt in tree[1:]:
for x in walk(elt):
yield x
else:
yield tree
- terminals = list(walk(st2))
- self.assertEqual([
+ expected = [
(1, 'def', 1, 0),
(1, 'f', 1, 4),
(7, '(', 1, 5),
@@ -293,8 +291,25 @@
(4, '', 2, 16),
(6, '', 2, -1),
(4, '', 2, -1),
- (0, '', 2, -1)],
- terminals)
+ (0, '', 2, -1),
+ ]
+
+ self.assertEqual(list(walk(st.totuple(line_info=True, col_info=True))),
+ expected)
+ self.assertEqual(list(walk(st.totuple())),
+ [(t, n) for t, n, l, c in expected])
+ self.assertEqual(list(walk(st.totuple(line_info=True))),
+ [(t, n, l) for t, n, l, c in expected])
+ self.assertEqual(list(walk(st.totuple(col_info=True))),
+ [(t, n, c) for t, n, l, c in expected])
+ self.assertEqual(list(walk(st.tolist(line_info=True, col_info=True))),
+ [list(x) for x in expected])
+ self.assertEqual(list(walk(parser.st2tuple(st, line_info=True,
+ col_info=True))),
+ expected)
+ self.assertEqual(list(walk(parser.st2list(st, line_info=True,
+ col_info=True))),
+ [list(x) for x in expected])
#
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 89ee759..4ba79cb 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -184,6 +184,7 @@
opener.open(request)
self.assertEqual(request.get_header('User-agent'),'Test-Agent')
+ @unittest.skip('XXX: http://www.imdb.com is gone')
def test_sites_no_connection_close(self):
# Some sites do not send Connection: close header.
# Verify that those work properly. (#issue12576)
diff --git a/Misc/NEWS.d/next/Library/2018-04-18-19-12-25.bpo-33308.fW75xi.rst b/Misc/NEWS.d/next/Library/2018-04-18-19-12-25.bpo-33308.fW75xi.rst
new file mode 100644
index 0000000..586004a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-04-18-19-12-25.bpo-33308.fW75xi.rst
@@ -0,0 +1,2 @@
+Fixed a crash in the :mod:`parser` module when converting an ST object to a
+tree of tuples or lists with ``line_info=False`` and ``col_info=True``.
diff --git a/Misc/NEWS.d/next/Library/2018-04-20-10-43-17.bpo-33131.L2E977.rst b/Misc/NEWS.d/next/Library/2018-04-20-10-43-17.bpo-33131.L2E977.rst
new file mode 100644
index 0000000..875c6ac
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-04-20-10-43-17.bpo-33131.L2E977.rst
@@ -0,0 +1 @@
+Upgrade bundled version of pip to 10.0.1.
diff --git a/Misc/NEWS.d/next/Library/2018-04-25-22-41-04.bpo-33359.Nr4CzK.rst b/Misc/NEWS.d/next/Library/2018-04-25-22-41-04.bpo-33359.Nr4CzK.rst
new file mode 100644
index 0000000..5a90f2f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-04-25-22-41-04.bpo-33359.Nr4CzK.rst
@@ -0,0 +1 @@
+Fix running ``python -m curses.has_key``.
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 7955542..fcc618d 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -121,10 +121,10 @@
if (result != NULL) {
(void) addelem(result, 0, PyInt_FromLong(TYPE(n)));
(void) addelem(result, 1, PyString_FromString(STR(n)));
- if (lineno == 1)
+ if (lineno)
(void) addelem(result, 2, PyInt_FromLong(n->n_lineno));
- if (col_offset == 1)
- (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset));
+ if (col_offset)
+ (void) addelem(result, 2 + lineno, PyInt_FromLong(n->n_col_offset));
}
return (result);
}
diff --git a/Python/import.c b/Python/import.c
index 1d74faf..f43a47c 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -447,7 +447,9 @@
dict = PyModule_GetDict(value);
if (Py_VerboseFlag)
PySys_WriteStderr("# clear __builtin__._\n");
- PyDict_SetItemString(dict, "_", Py_None);
+ if (PyDict_SetItemString(dict, "_", Py_None) < 0) {
+ PyErr_Clear();
+ }
}
value = PyDict_GetItemString(modules, "sys");
if (value != NULL && PyModule_Check(value)) {
@@ -457,7 +459,9 @@
for (p = sys_deletes; *p != NULL; p++) {
if (Py_VerboseFlag)
PySys_WriteStderr("# clear sys.%s\n", *p);
- PyDict_SetItemString(dict, *p, Py_None);
+ if (PyDict_SetItemString(dict, *p, Py_None) < 0) {
+ PyErr_Clear();
+ }
}
for (p = sys_files; *p != NULL; p+=2) {
if (Py_VerboseFlag)
@@ -465,7 +469,9 @@
v = PyDict_GetItemString(dict, *(p+1));
if (v == NULL)
v = Py_None;
- PyDict_SetItemString(dict, *p, v);
+ if (PyDict_SetItemString(dict, *p, v) < 0) {
+ PyErr_Clear();
+ }
}
}
@@ -475,7 +481,9 @@
if (Py_VerboseFlag)
PySys_WriteStderr("# cleanup __main__\n");
_PyModule_Clear(value);
- PyDict_SetItemString(modules, "__main__", Py_None);
+ if (PyDict_SetItemString(modules, "__main__", Py_None) < 0) {
+ PyErr_Clear();
+ }
}
/* The special treatment of __builtin__ here is because even
@@ -510,10 +518,15 @@
PySys_WriteStderr(
"# cleanup[1] %s\n", name);
_PyModule_Clear(value);
- PyDict_SetItem(modules, key, Py_None);
+ if (PyDict_SetItem(modules, key, Py_None) < 0) {
+ PyErr_Clear();
+ }
ndone++;
}
}
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ }
} while (ndone > 0);
/* Next, delete all modules (still skipping __builtin__ and sys) */
@@ -528,7 +541,12 @@
if (Py_VerboseFlag)
PySys_WriteStderr("# cleanup[2] %s\n", name);
_PyModule_Clear(value);
- PyDict_SetItem(modules, key, Py_None);
+ if (PyDict_SetItem(modules, key, Py_None) < 0) {
+ PyErr_Clear();
+ }
+ }
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
}
}
@@ -538,14 +556,18 @@
if (Py_VerboseFlag)
PySys_WriteStderr("# cleanup sys\n");
_PyModule_Clear(value);
- PyDict_SetItemString(modules, "sys", Py_None);
+ if (PyDict_SetItemString(modules, "sys", Py_None) < 0) {
+ PyErr_Clear();
+ }
}
value = PyDict_GetItemString(modules, "__builtin__");
if (value != NULL && PyModule_Check(value)) {
if (Py_VerboseFlag)
PySys_WriteStderr("# cleanup __builtin__\n");
_PyModule_Clear(value);
- PyDict_SetItemString(modules, "__builtin__", Py_None);
+ if (PyDict_SetItemString(modules, "__builtin__", Py_None) < 0) {
+ PyErr_Clear();
+ }
}
/* Finally, clear and delete the modules directory */
diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py
index b69d540..093ef31 100755
--- a/Tools/scripts/patchcheck.py
+++ b/Tools/scripts/patchcheck.py
@@ -221,10 +221,11 @@
return os.path.join('Misc', 'ACKS') in file_paths
-@status("Misc/NEWS updated", modal=True)
+@status("Misc/NEWS.d updated with `blurb`", modal=True)
def reported_news(file_paths):
- """Check if Misc/NEWS has been changed."""
- return os.path.join('Misc', 'NEWS') in file_paths
+ """Check if Misc/NEWS.d has been changed."""
+ return any(p.startswith(os.path.join('Misc', 'NEWS.d', 'next'))
+ for p in file_paths)
def main():
@@ -234,8 +235,7 @@
c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))]
doc_files = [fn for fn in file_paths if fn.startswith('Doc') and
fn.endswith(('.rst', '.inc'))]
- misc_files = {os.path.join('Misc', 'ACKS'), os.path.join('Misc', 'NEWS')}\
- & set(file_paths)
+ misc_files = {p for p in file_paths if p.startswith('Misc')}
# PEP 8 whitespace rules enforcement.
normalize_whitespace(python_files)
# C rules enforcement.