Imported Upstream version 2.7.15 50/187350/1 upstream/2.7.15
authorDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 22 Aug 2018 06:55:41 +0000 (15:55 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 22 Aug 2018 06:55:51 +0000 (15:55 +0900)
Change-Id: Id9c63619cb3e0b8e0af22357474f6f6429c63c61
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
291 files changed:
Doc/c-api/buffer.rst
Doc/c-api/init.rst
Doc/c-api/memory.rst
Doc/c-api/sequence.rst
Doc/c-api/structures.rst
Doc/c-api/typeobj.rst
Doc/conf.py
Doc/copyright.rst
Doc/docutils.conf [new file with mode: 0644]
Doc/extending/extending.rst
Doc/extending/newtypes.rst
Doc/faq/design.rst
Doc/faq/extending.rst
Doc/howto/logging-cookbook.rst
Doc/howto/regex.rst
Doc/howto/urllib2.rst
Doc/includes/noddy4.c
Doc/includes/sqlite3/load_extension.py
Doc/library/argparse.rst
Doc/library/atexit.rst
Doc/library/collections.rst
Doc/library/constants.rst
Doc/library/csv.rst
Doc/library/curses.rst
Doc/library/ensurepip.rst
Doc/library/gettext.rst
Doc/library/itertools.rst
Doc/library/locale.rst
Doc/library/logging.rst
Doc/library/mailbox.rst
Doc/library/msilib.rst
Doc/library/re.rst
Doc/library/sched.rst
Doc/library/socketserver.rst
Doc/library/ssl.rst
Doc/library/stdtypes.rst
Doc/library/sys.rst
Doc/library/tkinter.rst
Doc/library/unittest.rst
Doc/library/xml.etree.elementtree.rst
Doc/license.rst
Doc/make.bat
Doc/tools/static/switchers.js
Doc/tools/templates/indexsidebar.html
Doc/tutorial/classes.rst
Doc/tutorial/inputoutput.rst
Doc/tutorial/interpreter.rst
Doc/tutorial/introduction.rst
Doc/tutorial/modules.rst
Doc/using/cmdline.rst
Doc/using/unix.rst
Doc/whatsnew/2.6.rst
Doc/whatsnew/2.7.rst
Include/Python.h
Include/frameobject.h
Include/intobject.h
Include/objimpl.h
Include/patchlevel.h
Include/py_curses.h
Include/pymem.h
LICENSE
Lib/_threading_local.py
Lib/aifc.py
Lib/codecs.py
Lib/csv.py
Lib/ctypes/test/test_anon.py
Lib/ctypes/test/test_frombuffer.py
Lib/ctypes/test/test_funcptr.py
Lib/ctypes/test/test_parameters.py
Lib/ctypes/test/test_pep3118.py
Lib/ctypes/test/test_pointers.py
Lib/ctypes/test/test_struct_fields.py
Lib/difflib.py
Lib/distutils/ccompiler.py
Lib/distutils/command/upload.py
Lib/distutils/tests/test_ccompiler.py
Lib/distutils/tests/test_upload.py
Lib/email/utils.py
Lib/ensurepip/__init__.py
Lib/ensurepip/__main__.py
Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl [deleted file]
Lib/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl [new file with mode: 0644]
Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl [deleted file]
Lib/ensurepip/_bundled/setuptools-39.0.1-py2.py3-none-any.whl [new file with mode: 0644]
Lib/ensurepip/_uninstall.py
Lib/fpformat.py
Lib/functools.py
Lib/json/tests/test_speedups.py
Lib/lib-tk/test/test_tkinter/test_widgets.py
Lib/lib-tk/test/test_ttk/test_extensions.py
Lib/lib-tk/test/test_ttk/test_widgets.py
Lib/lib-tk/ttk.py
Lib/lib2to3/patcomp.py
Lib/lib2to3/pgen2/driver.py
Lib/lib2to3/pgen2/grammar.py
Lib/lib2to3/pygram.py
Lib/lib2to3/tests/test_parser.py
Lib/logging/__init__.py
Lib/mimetypes.py
Lib/netrc.py
Lib/pkgutil.py
Lib/poplib.py
Lib/sqlite3/test/regression.py
Lib/ssl.py
Lib/subprocess.py
Lib/telnetlib.py
Lib/test/bisect.py
Lib/test/fork_wait.py
Lib/test/list_tests.py
Lib/test/mapping_tests.py
Lib/test/pythoninfo.py
Lib/test/regrtest.py
Lib/test/sha256.pem [deleted file]
Lib/test/support/__init__.py
Lib/test/test_abc.py
Lib/test/test_aifc.py
Lib/test/test_audioop.py
Lib/test/test_builtin.py
Lib/test/test_bytes.py
Lib/test/test_codecs.py
Lib/test/test_crypt.py
Lib/test/test_csv.py
Lib/test/test_curses.py
Lib/test/test_datetime.py
Lib/test/test_dict.py
Lib/test/test_dictviews.py
Lib/test/test_difflib.py
Lib/test/test_ensurepip.py
Lib/test/test_file2k.py
Lib/test/test_fpformat.py
Lib/test/test_ftplib.py
Lib/test/test_functools.py
Lib/test/test_gc.py
Lib/test/test_generators.py
Lib/test/test_glob.py
Lib/test/test_grammar.py
Lib/test/test_gzip.py
Lib/test/test_httplib.py
Lib/test/test_io.py
Lib/test/test_itertools.py
Lib/test/test_kqueue.py
Lib/test/test_mailbox.py
Lib/test/test_multiprocessing.py
Lib/test/test_netrc.py
Lib/test/test_ordered_dict.py
Lib/test/test_os.py
Lib/test/test_poll.py
Lib/test/test_poplib.py
Lib/test/test_pty.py
Lib/test/test_random.py
Lib/test/test_re.py
Lib/test/test_regrtest.py
Lib/test/test_socket.py
Lib/test/test_socketserver.py
Lib/test/test_ssl.py
Lib/test/test_strftime.py
Lib/test/test_strop.py
Lib/test/test_subprocess.py
Lib/test/test_syntax.py
Lib/test/test_sys.py
Lib/test/test_sys_settrace.py
Lib/test/test_tcl.py
Lib/test/test_test_support.py
Lib/test/test_time.py
Lib/test/test_urllib2_localnet.py
Lib/test/test_uuid.py
Lib/test/test_warnings.py
Lib/test/test_weakref.py
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree_c.py
Lib/test/xmltestdata/expat224_utf8_bug.xml [new file with mode: 0644]
Lib/tkinter/test/test_ttk/test_widgets.py [new file with mode: 0644]
Lib/tkinter/ttk.py [new file with mode: 0644]
Lib/unittest/case.py
Lib/uuid.py
Mac/BuildScript/README.txt
Mac/BuildScript/build-installer.py
Mac/BuildScript/issue19373_tk_8_5_15_source.patch [deleted file]
Mac/BuildScript/openssl_sdk_makedepend.patch [deleted file]
Mac/BuildScript/resources/Conclusion.rtf [new file with mode: 0644]
Mac/BuildScript/resources/ReadMe.rtf
Mac/BuildScript/resources/Welcome.rtf
Mac/BuildScript/resources/install_certificates.command [new file with mode: 0755]
Mac/BuildScript/scripts/postflight.documentation
Mac/BuildScript/tk868_on_10_8_10_9.patch [new file with mode: 0644]
Mac/IDLE/Makefile.in
Mac/PythonLauncher/Info.plist.in
Mac/README
Mac/Resources/app/Info.plist.in
Mac/Resources/framework/Info.plist.in
Makefile.pre.in
Misc/ACKS
Misc/NEWS
Misc/NEWS.d/2.7.14rc1.rst [deleted file]
Misc/NEWS.d/next/Build/README.rst [deleted file]
Misc/NEWS.d/next/C API/README.rst [deleted file]
Misc/NEWS.d/next/Core and Builtins/README.rst [deleted file]
Misc/NEWS.d/next/Documentation/README.rst [deleted file]
Misc/NEWS.d/next/IDLE/README.rst [deleted file]
Misc/NEWS.d/next/Library/2017-09-04-23-41-35.bpo-31170.QGmJ1t.rst [deleted file]
Misc/NEWS.d/next/Library/README.rst [deleted file]
Misc/NEWS.d/next/Security/README.rst [deleted file]
Misc/NEWS.d/next/Tests/README.rst [deleted file]
Misc/NEWS.d/next/Tools-Demos/README.rst [deleted file]
Misc/NEWS.d/next/Windows/README.rst [deleted file]
Misc/NEWS.d/next/macOS/README.rst [deleted file]
Modules/_collectionsmodule.c
Modules/_ctypes/_ctypes.c
Modules/_ctypes/cfield.c
Modules/_ctypes/ctypes.h
Modules/_ctypes/stgdict.c
Modules/_cursesmodule.c
Modules/_elementtree.c
Modules/_functoolsmodule.c
Modules/_hashopenssl.c
Modules/_io/bytesio.c
Modules/_io/fileio.c
Modules/_io/textio.c
Modules/_json.c
Modules/_lsprof.c
Modules/_randommodule.c
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sre.c
Modules/_ssl.c
Modules/_testcapimodule.c
Modules/_tkinter.c
Modules/arraymodule.c
Modules/audioop.c
Modules/datetimemodule.c
Modules/itertoolsmodule.c
Modules/mmapmodule.c
Modules/posixmodule.c
Modules/selectmodule.c
Modules/signalmodule.c
Modules/socketmodule.c
Modules/timemodule.c
Objects/bufferobject.c
Objects/bytearrayobject.c
Objects/bytesobject.c [new file with mode: 0644]
Objects/classobject.c
Objects/dictobject.c
Objects/enumobject.c
Objects/exceptions.c
Objects/fileobject.c
Objects/floatobject.c
Objects/frameobject.c
Objects/intobject.c
Objects/listobject.c
Objects/longobject.c
Objects/object.c
Objects/obmalloc.c
Objects/rangeobject.c
Objects/setobject.c
Objects/tupleobject.c
Objects/weakrefobject.c
PC/VS9.0/build.bat
PC/VS9.0/pyproject.vsprops
PC/_msi.c
PC/_subprocess.c
PCbuild/build.bat
PCbuild/find_msbuild.bat [new file with mode: 0644]
PCbuild/find_python.bat [new file with mode: 0644]
PCbuild/get_external.py [new file with mode: 0644]
PCbuild/get_externals.bat
PCbuild/python.props
PCbuild/python.vcxproj
PCbuild/readme.txt
PCbuild/tcltk.props
Python/_warnings.c
Python/bltinmodule.c
Python/ceval.c
Python/compile.c
Python/getcompiler.c
Python/getcopyright.c
Python/marshal.c
Python/pystate.c
Python/pythonrun.c
Python/symtable.c
README
Tools/i18n/pygettext.py
Tools/nuget/build.bat
Tools/nuget/make_pkg.proj
Tools/scripts/reindent.py
Tools/ssl/multissltests.py [new file with mode: 0755]
Tools/ssl/test_multiple_versions.py [deleted file]
aclocal.m4
configure
configure.ac
pyconfig.h.in
setup.py

index 050db556cbfe888f2dcf044311575bba4c0b199b..4e5a04397a358a77d77662cd71bb60db8ef1dbf3 100644 (file)
@@ -278,7 +278,7 @@ Buffer related functions
    (*fortran* is ``'A'``).  Return ``0`` otherwise.
 
 
-.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
+.. c:function:: void PyBuffer_FillContiguousStrides(int ndims, Py_ssize_t *shape, Py_ssize_t *strides, int itemsize, char fortran)
 
    Fill the *strides* array with byte-strides of a contiguous (C-style if
    *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'``) array of the
index 7643a3786c4b8310a0313dd498f401b16d50d61b..229cae5244abcfa44fe8008e8b595b413160c32d 100644 (file)
@@ -983,12 +983,12 @@ in previous versions.
    +------------------------------+--------------------------------------+
    | Value of *what*              | Meaning of *arg*                     |
    +==============================+======================================+
-   | :const:`PyTrace_CALL`        | Always *NULL*.                       |
+   | :const:`PyTrace_CALL`        | Always :c:data:`Py_None`.            |
    +------------------------------+--------------------------------------+
    | :const:`PyTrace_EXCEPTION`   | Exception information as returned by |
    |                              | :func:`sys.exc_info`.                |
    +------------------------------+--------------------------------------+
-   | :const:`PyTrace_LINE`        | Always *NULL*.                       |
+   | :const:`PyTrace_LINE`        | Always :c:data:`Py_None`.            |
    +------------------------------+--------------------------------------+
    | :const:`PyTrace_RETURN`      | Value being returned to the caller,  |
    |                              | or *NULL* if caused by an exception. |
@@ -1030,7 +1030,7 @@ in previous versions.
 .. c:var:: int PyTrace_RETURN
 
    The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a
-   call is returning without propagating an exception.
+   call is about to return.
 
 
 .. c:var:: int PyTrace_C_CALL
@@ -1057,15 +1057,19 @@ in previous versions.
    function as its first parameter, and may be any Python object, or *NULL*.  If
    the profile function needs to maintain state, using a different value for *obj*
    for each thread provides a convenient and thread-safe place to store it.  The
-   profile function is called for all monitored events except the line-number
-   events.
+   profile function is called for all monitored events except :const:`PyTrace_LINE`
+   and :const:`PyTrace_EXCEPTION`.
 
 
 .. c:function:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
 
    Set the tracing function to *func*.  This is similar to
    :c:func:`PyEval_SetProfile`, except the tracing function does receive line-number
-   events.
+   events and does not receive any event related to C function objects being called. Any
+   trace function registered using :c:func:`PyEval_SetTrace` will not receive
+   :const:`PyTrace_C_CALL`, :const:`PyTrace_C_EXCEPTION` or :const:`PyTrace_C_RETURN`
+   as a value for the *what* parameter.
+
 
 .. c:function:: PyObject* PyEval_GetCallStats(PyObject *self)
 
index 54655719045faa6564e217349aac7a059efc1ada..258898d87025410dd90ecf45b38d09ace23ed814 100644 (file)
@@ -155,6 +155,88 @@ versions and is therefore deprecated in extension modules.
 :c:func:`PyMem_NEW`, :c:func:`PyMem_RESIZE`, :c:func:`PyMem_DEL`.
 
 
+Object allocators
+=================
+
+The following function sets, modeled after the ANSI C standard, but specifying
+behavior when requesting zero bytes, are available for allocating and releasing
+memory from the Python heap.
+
+By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
+
+.. warning::
+
+   The :term:`GIL <global interpreter lock>` must be held when using these
+   functions.
+
+.. c:function:: void* PyObject_Malloc(size_t n)
+
+   Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the
+   allocated memory, or *NULL* if the request fails.
+
+   Requesting zero bytes returns a distinct non-*NULL* pointer if possible, as
+   if ``PyObject_Malloc(1)`` had been called instead. The memory will not have
+   been initialized in any way.
+
+
+.. c:function:: void* PyObject_Realloc(void *p, size_t n)
+
+   Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
+   unchanged to the minimum of the old and the new sizes.
+
+   If *p* is *NULL*, the call is equivalent to ``PyObject_Malloc(n)``; else if *n*
+   is equal to zero, the memory block is resized but is not freed, and the
+   returned pointer is non-*NULL*.
+
+   Unless *p* is *NULL*, it must have been returned by a previous call to
+   :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:`PyObject_Calloc`.
+
+   If the request fails, :c:func:`PyObject_Realloc` returns *NULL* and *p* remains
+   a valid pointer to the previous memory area.
+
+
+.. c:function:: void PyObject_Free(void *p)
+
+   Frees the memory block pointed to by *p*, which must have been returned by a
+   previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or
+   :c:func:`PyObject_Calloc`.  Otherwise, or if ``PyObject_Free(p)`` has been called
+   before, undefined behavior occurs.
+
+   If *p* is *NULL*, no operation is performed.
+
+
+In addition, the following macro sets are provided:
+
+* :c:func:`PyObject_MALLOC`: alias to :c:func:`PyObject_Malloc`
+* :c:func:`PyObject_REALLOC`: alias to :c:func:`PyObject_Realloc`
+* :c:func:`PyObject_FREE`: alias to :c:func:`PyObject_Free`
+* :c:func:`PyObject_Del`: alias to :c:func:`PyObject_Free`
+* :c:func:`PyObject_DEL`: alias to :c:func:`PyObject_FREE` (so finally an alias
+  to :c:func:`PyObject_Free`)
+
+
+.. _pymalloc:
+
+The pymalloc allocator
+======================
+
+Python has a *pymalloc* allocator optimized for small objects (smaller or equal
+to 512 bytes) with a short lifetime. It uses memory mappings called "arenas"
+with a fixed size of 256 KiB. It falls back to :c:func:`malloc` and
+:c:func:`realloc` for allocations larger than 512 bytes.
+
+*pymalloc* is the default allocator of :c:func:`PyObject_Malloc`.
+
+The arena allocator uses the following functions:
+
+* :c:func:`mmap` and :c:func:`munmap` if available,
+* :c:func:`malloc` and :c:func:`free` otherwise.
+
+.. versionchanged:: 2.7.7
+   The threshold changed from 256 to 512 bytes. The arena allocator now
+   uses :c:func:`mmap` if available.
+
+
 .. _memoryexamples:
 
 Examples
index d82a7b0556c0fc4fcaa98c31df412d183dac3889..d95ef2398cc5eb4b31ec88ae31b7189d20bf7445 100644 (file)
@@ -17,9 +17,8 @@ Sequence Protocol
 
    .. index:: builtin: len
 
-   Returns the number of objects in sequence *o* on success, and ``-1`` on failure.
-   For objects that do not provide sequence protocol, this is equivalent to the
-   Python expression ``len(o)``.
+   Returns the number of objects in sequence *o* on success, and ``-1`` on
+   failure.  This is equivalent to the Python expression ``len(o)``.
 
    .. versionchanged:: 2.5
       These functions returned an :c:type:`int` type. This might require
index 782cec29d836244f52c42788719177623373a315..af6a8c38cd031a4ede93632ac1d5d83597c6b424 100644 (file)
@@ -320,6 +320,46 @@ definition with the same method name.
    members can be deleted.  (They are set to *NULL*).
 
 
+.. c:type:: PyGetSetDef
+
+   Structure to define property-like access for a type. See also description of
+   the :c:member:`PyTypeObject.tp_getset` slot.
+
+   +-------------+------------------+-----------------------------------+
+   | Field       | C Type           | Meaning                           |
+   +=============+==================+===================================+
+   | name        | char \*          | attribute name                    |
+   +-------------+------------------+-----------------------------------+
+   | get         | getter           | C Function to get the attribute   |
+   +-------------+------------------+-----------------------------------+
+   | set         | setter           | optional C function to set or     |
+   |             |                  | delete the attribute, if omitted  |
+   |             |                  | the attribute is readonly         |
+   +-------------+------------------+-----------------------------------+
+   | doc         | char \*          | optional docstring                |
+   +-------------+------------------+-----------------------------------+
+   | closure     | void \*          | optional function pointer,        |
+   |             |                  | providing additional data for     |
+   |             |                  | getter and setter                 |
+   +-------------+------------------+-----------------------------------+
+
+   The ``get`` function takes one :c:type:`PyObject\*` parameter (the
+   instance) and a function pointer (the associated ``closure``)::
+
+      typedef PyObject *(*getter)(PyObject *, void *);
+
+   It should return a new reference on success or *NULL* with a set exception
+   on failure.
+
+   ``set`` functions take two :c:type:`PyObject\*` parameters (the instance and
+   the value to be set) and a function pointer (the associated ``closure``)::
+
+      typedef int (*setter)(PyObject *, PyObject *, void *);
+
+   In case the attribute should be deleted the second parameter is *NULL*.
+   Should return ``0`` on success or ``-1`` with a set exception on failure.
+
+
 .. c:function:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
 
    Return a bound method object for an extension type implemented in C.  This
index 2ebbd52a3819603b02fee554d6dd1ca5fc5943da..f0ccf2ea5fe94c1ac58e6fcbc24ea04e480b632c 100644 (file)
@@ -825,21 +825,6 @@ The next fields, up to and including :c:member:`~PyTypeObject.tp_weaklist`, only
    This field is not inherited by subtypes (computed attributes are inherited
    through a different mechanism).
 
-   .. XXX belongs elsewhere
-
-   Docs for PyGetSetDef::
-
-      typedef PyObject *(*getter)(PyObject *, void *);
-      typedef int (*setter)(PyObject *, PyObject *, void *);
-
-      typedef struct PyGetSetDef {
-          char *name;    /* attribute name */
-          getter get;    /* C function to get the attribute */
-          setter set;    /* C function to set or delete the attribute */
-          char *doc;     /* optional doc string */
-          void *closure; /* optional additional data for getter and setter */
-      } PyGetSetDef;
-
 
 .. c:member:: PyTypeObject* PyTypeObject.tp_base
 
@@ -1116,7 +1101,7 @@ The next fields, up to and including :c:member:`~PyTypeObject.tp_weaklist`, only
 The remaining fields are only defined if the feature test macro
 :const:`COUNT_ALLOCS` is defined, and are for internal use only. They are
 documented here for completeness.  None of these fields are inherited by
-subtypes.
+subtypes. See the :envvar:`PYTHONSHOWALLOCCOUNT` environment variable.
 
 
 .. c:member:: Py_ssize_t PyTypeObject.tp_allocs
index 14bb6419d32e3433c4ed23793f410339e81bf0ba..557fe1e72f277662057d2a39579e66e47acd0054 100644 (file)
@@ -83,13 +83,17 @@ html_split_index = True
 # ------------------------
 
 # Get LaTeX to handle Unicode correctly
-latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}', 'utf8extra': ''}
+latex_elements = {
+    'inputenc': r'\usepackage[utf8x]{inputenc}',
+    'utf8extra': '',
+    'fontenc': r'\usepackage[T1,T2A]{fontenc}',
+}
 
 # Additional stuff for the LaTeX preamble.
 latex_elements['preamble'] = r'''
 \authoraddress{
-  \strong{Python Software Foundation}\\
-  Email: \email{docs@python.org}
+  \sphinxstrong{Python Software Foundation}\\
+  Email: \sphinxemail{docs@python.org}
 }
 \let\Verbatim=\OriginalVerbatim
 \let\endVerbatim=\endOriginalVerbatim
@@ -99,7 +103,7 @@ latex_elements['preamble'] = r'''
 latex_elements['papersize'] = 'a4'
 
 # The font size ('10pt', '11pt' or '12pt').
-latex_elements['font_size'] = '10pt'
+latex_elements['pointsize'] = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, document class [howto/manual]).
index 22d7705846ea936e751bb78490f5445cda3aa62d..540ff5ef0593af71039f7b9fc384e4d3174620c1 100644 (file)
@@ -4,7 +4,7 @@ Copyright
 
 Python and this documentation is:
 
-Copyright © 2001-2016 Python Software Foundation. All rights reserved.
+Copyright © 2001-2018 Python Software Foundation. All rights reserved.
 
 Copyright © 2000 BeOpen.com. All rights reserved.
 
diff --git a/Doc/docutils.conf b/Doc/docutils.conf
new file mode 100644 (file)
index 0000000..bda4f5d
--- /dev/null
@@ -0,0 +1,2 @@
+[restructuredtext parser]
+smartquotes-locales: ja: ""''
index 32d30972f2e2c0c99f375eaceacd7a2b548db982..991289c14cf65d8c876b9e233e019b9db354b665 100644 (file)
@@ -40,7 +40,7 @@ A Simple Example
 
 Let's create an extension module called ``spam`` (the favorite food of Monty
 Python fans...) and let's say we want to create a Python interface to the C
-library function :c:func:`system`. [#]_ This function takes a null-terminated
+library function :c:func:`system` [#]_. This function takes a null-terminated
 character string as argument and returns an integer.  We want this function to
 be callable from Python as follows::
 
@@ -890,7 +890,7 @@ It is also possible to :dfn:`borrow` [#]_ a reference to an object.  The
 borrower of a reference should not call :c:func:`Py_DECREF`.  The borrower must
 not hold on to the object longer than the owner from which it was borrowed.
 Using a borrowed reference after the owner has disposed of it risks using freed
-memory and should be avoided completely. [#]_
+memory and should be avoided completely [#]_.
 
 The advantage of borrowing over owning a reference is that you don't need to
 take care of disposing of the reference on all possible paths through the code
@@ -1061,7 +1061,7 @@ checking.
 
 The C function calling mechanism guarantees that the argument list passed to C
 functions (``args`` in the examples) is never *NULL* --- in fact it guarantees
-that it is always a tuple. [#]_
+that it is always a tuple [#]_.
 
 It is a severe error to ever let a *NULL* pointer "escape" to the Python user.
 
index 5959e4f2b1ee6a6699d2a17315e3364b339b098d..a60c0244c22c32f08a3ae8e2715a69e88cb72d0f 100644 (file)
@@ -685,7 +685,7 @@ Fortunately, Python's cyclic-garbage collector will eventually figure out that
 the list is garbage and free it.
 
 In the second version of the :class:`Noddy` example, we allowed any kind of
-object to be stored in the :attr:`first` or :attr:`last` attributes. [#]_ This
+object to be stored in the :attr:`first` or :attr:`last` attributes [#]_. This
 means that :class:`Noddy` objects can participate in cycles::
 
    >>> import noddy2
@@ -748,8 +748,9 @@ simplified::
    uniformity across these boring implementations.
 
 We also need to provide a method for clearing any subobjects that can
-participate in cycles.  We implement the method and reimplement the deallocator
-to use it::
+participate in cycles.
+
+::
 
    static int
    Noddy_clear(Noddy *self)
@@ -767,13 +768,6 @@ to use it::
        return 0;
    }
 
-   static void
-   Noddy_dealloc(Noddy* self)
-   {
-       Noddy_clear(self);
-       self->ob_type->tp_free((PyObject*)self);
-   }
-
 Notice the use of a temporary variable in :c:func:`Noddy_clear`. We use the
 temporary variable so that we can set each member to *NULL* before decrementing
 its reference count.  We do this because, as was discussed earlier, if the
@@ -796,6 +790,23 @@ decrementing of reference counts.  With :c:func:`Py_CLEAR`, the
        return 0;
    }
 
+Note that :c:func:`Noddy_dealloc` may call arbitrary functions through
+``__del__`` method or weakref callback. It means circular GC can be
+triggered inside the function.  Since GC assumes reference count is not zero,
+we need to untrack the object from GC by calling :c:func:`PyObject_GC_UnTrack`
+before clearing members. Here is reimplemented deallocator which uses
+:c:func:`PyObject_GC_UnTrack` and :c:func:`Noddy_clear`.
+
+::
+
+   static void
+   Noddy_dealloc(Noddy* self)
+   {
+       PyObject_GC_UnTrack(self);
+       Noddy_clear(self);
+       Py_TYPE(self)->tp_free((PyObject*)self);
+   }
+
 Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::
 
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
index 0a8cfdd25d13a4811274f561f31502a7c745525c..15e4af57fee32ee3cc5ba840b1b6b3dac5159a43 100644 (file)
@@ -391,50 +391,11 @@ is exactly the same type of object that a lambda expression yields) is assigned!
 Can Python be compiled to machine code, C or some other language?
 -----------------------------------------------------------------
 
-Not easily.  Python's high level data types, dynamic typing of objects and
-run-time invocation of the interpreter (using :func:`eval` or :keyword:`exec`)
-together mean that a "compiled" Python program would probably consist mostly of
-calls into the Python run-time system, even for seemingly simple operations like
-``x+1``.
-
-Several projects described in the Python newsgroup or at past `Python
-conferences <https://www.python.org/community/workshops/>`_ have shown that this
-approach is feasible, although the speedups reached so far are only modest
-(e.g. 2x).  Jython uses the same strategy for compiling to Java bytecode.  (Jim
-Hugunin has demonstrated that in combination with whole-program analysis,
-speedups of 1000x are feasible for small demo programs.  See the proceedings
-from the `1997 Python conference
-<http://legacy.python.org/workshops/1997-10/proceedings/>`_ for more information.)
-
-Internally, Python source code is always translated into a bytecode
-representation, and this bytecode is then executed by the Python virtual
-machine.  In order to avoid the overhead of repeatedly parsing and translating
-modules that rarely change, this byte code is written into a file whose name
-ends in ".pyc" whenever a module is parsed.  When the corresponding .py file is
-changed, it is parsed and translated again and the .pyc file is rewritten.
-
-There is no performance difference once the .pyc file has been loaded, as the
-bytecode read from the .pyc file is exactly the same as the bytecode created by
-direct translation.  The only difference is that loading code from a .pyc file
-is faster than parsing and translating a .py file, so the presence of
-precompiled .pyc files improves the start-up time of Python scripts.  If
-desired, the Lib/compileall.py module can be used to create valid .pyc files for
-a given set of modules.
-
-Note that the main script executed by Python, even if its filename ends in .py,
-is not compiled to a .pyc file.  It is compiled to bytecode, but the bytecode is
-not saved to a file.  Usually main scripts are quite short, so this doesn't cost
-much speed.
-
-.. XXX check which of these projects are still alive
-
-There are also several programs which make it easier to intermingle Python and C
-code in various ways to increase performance.  See, for example, `Cython <http://cython.org/>`_ , `Psyco
-<http://psyco.sourceforge.net/>`_, `Pyrex
-<https://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/>`_, `PyInline
-<http://pyinline.sourceforge.net/>`_, `Py2Cmod
-<http://sourceforge.net/projects/py2cmod/>`_, and
-`Weave <https://docs.scipy.org/doc/scipy-dev/reference/tutorial/weave.html>`_.
+`Cython <http://cython.org/>`_ compiles a modified version of Python with
+optional annotations into C extensions.  `Nuitka <http://www.nuitka.net/>`_ is
+an up-and-coming compiler of Python into C++ code, aiming to support the full
+Python language. For compiling to Java you can consider
+`VOC <https://voc.readthedocs.io>`_.
 
 
 How does Python manage memory?
index c3806457b0302217f5834b62443dc4bcd8dee5ed..4be58d69714cf76512e55a08ab5d972cffa5b367 100644 (file)
@@ -56,7 +56,7 @@ with a tool such as `SWIG <http://www.swig.org>`_.  `SIP
 <https://riverbankcomputing.com/software/sip/intro>`__, `CXX
 <http://cxx.sourceforge.net/>`_ `Boost
 <http://www.boost.org/libs/python/doc/index.html>`_, or `Weave
-<https://scipy.github.io/devdocs/tutorial/weave.html>`_ are also
+<https://github.com/scipy/weave>`_ are also
 alternatives for wrapping C++ libraries.
 
 
index b9b5120f053d8f436de1036de038e392fc33c757..50ff76e79289f19aff319f764efd9f6c1d5e4293 100644 (file)
@@ -650,7 +650,7 @@ Using file rotation
 -------------------
 
 .. sectionauthor:: Doug Hellmann, Vinay Sajip (changes)
-.. (see <http://blog.doughellmann.com/2007/05/pymotw-logging.html>)
+.. (see <https://pymotw.com/3/logging/>)
 
 Sometimes you want to let a log file grow to a certain size, then open a new
 file and log to that. You may want to keep a certain number of these files, and
index 0d0e9f56093d67f3ace58040dedd440530416163..082fc012991525ca3ec7da994b1a69382d7f35d7 100644 (file)
@@ -840,7 +840,7 @@ backreferences in a RE.
 
 For example, the following RE detects doubled words in a string. ::
 
-   >>> p = re.compile(r'(\b\w+)\s+\1')
+   >>> p = re.compile(r'\b(\w+)\s+\1\b')
    >>> p.search('Paris in the the spring').group()
    'the the'
 
@@ -947,9 +947,9 @@ number of the group.  There's naturally a variant that uses the group name
 instead of the number. This is another Python extension: ``(?P=name)`` indicates
 that the contents of the group called *name* should again be matched at the
 current point.  The regular expression for finding doubled words,
-``(\b\w+)\s+\1`` can also be written as ``(?P<word>\b\w+)\s+(?P=word)``::
+``\b(\w+)\s+\1\b`` can also be written as ``\b(?P<word>\w+)\s+(?P=word)\b``::
 
-   >>> p = re.compile(r'(?P<word>\b\w+)\s+(?P=word)')
+   >>> p = re.compile(r'\b(?P<word>\w+)\s+(?P=word)\b')
    >>> p.search('Paris in the the spring').group()
    'the the'
 
index d697c216d8c36002692e72075bc81e445fef0a5a..ce6394859d57c1bcf42d386a81daf745b1e2f8fd 100644 (file)
@@ -203,7 +203,7 @@ e.g. ::
 
     >>> req = urllib2.Request('http://www.pretend_server.org')
     >>> try: urllib2.urlopen(req)
-    ... except URLError as e:
+    ... except urllib2.URLError as e:
     ...    print e.reason   #doctest: +SKIP
     ...
     (4, 'getaddrinfo failed')
index 9feb71aae3be5b0e9a62a45d7ce63067ac936f2e..0fd4dc378844cc23e089a480b45645300732f69a 100644 (file)
@@ -46,6 +46,7 @@ Noddy_clear(Noddy *self)
 static void
 Noddy_dealloc(Noddy* self)
 {
+    PyObject_GC_UnTrack(self);
     Noddy_clear(self);
     Py_TYPE(self)->tp_free((PyObject*)self);
 }
index 7f893c9286d636e5996bf40e7d29e0616bcf6f48..f1a92b3ef8c6e394522aa5744242d8c6dc0b8e9c 100644 (file)
@@ -11,7 +11,7 @@ con.execute("select load_extension('./fts3.so')")
 # alternatively you can load the extension using an API call:
 # con.load_extension("./fts3.so")
 
-# disable extension laoding again
+# disable extension loading again
 con.enable_load_extension(False)
 
 # example from SQLite wiki
index 1ea1f3fc1a564ad41face5c5f1e20588507ebae2..799336092a9edb8ae9c7ceb1fe300d58e0b6418d 100644 (file)
@@ -419,7 +419,9 @@ should not be line-wrapped::
     -h, --help  show this help message and exit
 
 :class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text,
-including argument descriptions.
+including argument descriptions. However, multiple new lines are replaced with
+one. If you wish to preserve multiple blank lines, add spaces between the
+newlines.
 
 The other formatter class available, :class:`ArgumentDefaultsHelpFormatter`,
 will add information about the default value of each of the arguments::
@@ -852,6 +854,8 @@ values are:
      usage: PROG [-h] foo [foo ...]
      PROG: error: too few arguments
 
+.. _`argparse.REMAINDER`:
+
 * ``argparse.REMAINDER``.  All the remaining command-line arguments are gathered
   into a list.  This is commonly useful for command line utilities that dispatch
   to other command line utilities::
@@ -1273,8 +1277,11 @@ The parse_args() method
    created and how they are assigned. See the documentation for
    :meth:`add_argument` for details.
 
-   By default, the argument strings are taken from :data:`sys.argv`, and a new empty
-   :class:`Namespace` object is created for the attributes.
+   * args_ - List of strings to parse.  The default is taken from
+     :data:`sys.argv`.
+
+   * namespace_ - An object to take the attributes.  The default is a new empty
+     :class:`Namespace` object.
 
 
 Option value syntax
@@ -1415,6 +1422,7 @@ a unique option)::
 
 An error is produced for arguments that could produce more than one options.
 
+.. _args:
 
 Beyond ``sys.argv``
 ^^^^^^^^^^^^^^^^^^^
@@ -1436,6 +1444,7 @@ interactive prompt::
    >>> parser.parse_args(['1', '2', '3', '4', '--sum'])
    Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])
 
+.. _namespace:
 
 The Namespace object
 ^^^^^^^^^^^^^^^^^^^^
@@ -1941,7 +1950,12 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
 * Replace ``(options, args) = parser.parse_args()`` with ``args =
   parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument`
   calls for the positional arguments. Keep in mind that what was previously
-  called ``options``, now in :mod:`argparse` context is called ``args``.
+  called ``options``, now in the :mod:`argparse` context is called ``args``.
+
+* Replace :meth:`optparse.OptionParser.disable_interspersed_args`
+  by setting ``nargs`` of a positional argument to `argparse.REMAINDER`_, or
+  use :meth:`~ArgumentParser.parse_known_args` to collect unparsed argument
+  strings in a separate list.
 
 * Replace callback actions and the ``callback_*`` keyword arguments with
   ``type`` or ``action`` arguments.
index 0b5e121fe630cb6ea4d63d9de926db5d150faef2..06bbf606a9af927cdf8db8cc6b34805ba1a4864a 100644 (file)
@@ -37,7 +37,7 @@ simplest way to convert code that sets ``sys.exitfunc`` is to import
 :mod:`atexit` and register the function that had been bound to ``sys.exitfunc``.
 
 
-.. function:: register(func[, *args[, **kargs]])
+.. function:: register(func[, *args[, **kwargs]])
 
    Register *func* as a function to be executed at termination.  Any optional
    arguments that are to be passed to *func* must be passed as arguments to
index 25e5e22fa37fdb3ed67e78e0351fe316d09e96a7..9610419f078e8ba8f8ed50defef27cc08c2976e4 100644 (file)
@@ -300,7 +300,7 @@ counts, but the output will exclude results with counts of zero or less.
 
    .. method:: remove(value)
 
-      Removed the first occurrence of *value*.  If not found, raises a
+      Remove the first occurrence of *value*.  If not found, raises a
       :exc:`ValueError`.
 
       .. versionadded:: 2.5
@@ -311,11 +311,14 @@ counts, but the output will exclude results with counts of zero or less.
 
       .. versionadded:: 2.7
 
-   .. method:: rotate(n)
+   .. method:: rotate(n=1)
 
       Rotate the deque *n* steps to the right.  If *n* is negative, rotate to
-      the left.  Rotating one step to the right is equivalent to:
-      ``d.appendleft(d.pop())``.
+      the left.
+
+      When the deque is not empty, rotating one step to the right is equivalent to
+      ``d.appendleft(d.pop())``, and rotating one step to the left is
+      equivalent to ``d.append(d.popleft())``.
 
 
    Deque objects also provide one read-only attribute:
index 0db83374811d3d9c437624b819b703583305eb66..a8b4c7a4ff714bd810597f576a1202406e19db0e 100644 (file)
@@ -73,9 +73,13 @@ should not be used in programs.
    specified exit code.
 
 .. data:: copyright
-          license
           credits
 
-   Objects that when printed, print a message like "Type license() to see the
-   full license text", and when called, display the corresponding text in a
+   Objects that when printed or called, print the text of copyright or
+   credits, respectively.
+
+.. data:: license
+
+   Object that when printed, prints the message "Type license() to see the
+   full license text", and when called, displays the full license text in a
    pager-like fashion (one screen at a time).
index dbef60f0a6b69701719991a65366798b39b05545..fedd370cf1cfe777ad11f97c0a816c1fde94dee6 100644 (file)
@@ -165,7 +165,7 @@ The :mod:`csv` module defines the following functions:
 The :mod:`csv` module defines the following classes:
 
 
-.. class:: DictReader(csvfile, fieldnames=None, restkey=None, restval=None, \
+.. class:: DictReader(f, fieldnames=None, restkey=None, restval=None, \
                       dialect='excel', *args, **kwds)
 
    Create an object which operates like a regular reader but maps the
@@ -174,7 +174,7 @@ The :mod:`csv` module defines the following classes:
    <collections-abstract-base-classes>` whose elements are associated with the
    fields of the input data in order. These elements become the keys of the
    resulting dictionary.  If the *fieldnames* parameter is omitted, the values
-   in the first row of the *csvfile* will be used as the fieldnames.  If the
+   in the first row of the file *f* will be used as the fieldnames.  If the
    row read has more fields than the fieldnames sequence, the remaining data is
    added as a sequence keyed by the value of *restkey*.  If the row read has
    fewer fields than the fieldnames sequence, the remaining keys take the value
@@ -194,14 +194,14 @@ The :mod:`csv` module defines the following classes:
        Wonderful Spam
 
 
-.. class:: DictWriter(csvfile, fieldnames, restval='', extrasaction='raise', \
+.. class:: DictWriter(f, fieldnames, restval='', extrasaction='raise', \
                       dialect='excel', *args, **kwds)
 
    Create an object which operates like a regular writer but maps dictionaries
    onto output rows.  The *fieldnames* parameter is a :ref:`sequence
    <collections-abstract-base-classes>` of keys that identify the order in
    which values in the dictionary passed to the :meth:`writerow` method are
-   written to the *csvfile*.  The optional *restval* parameter specifies the
+   written to the file *f*.  The optional *restval* parameter specifies the
    value to be written if the dictionary is missing a key in *fieldnames*.  If
    the dictionary passed to the :meth:`writerow` method contains a key not
    found in *fieldnames*, the optional *extrasaction* parameter indicates what
@@ -213,7 +213,7 @@ The :mod:`csv` module defines the following classes:
    Note that unlike the :class:`DictReader` class, the *fieldnames* parameter
    of the :class:`DictWriter` is not optional.  Since Python's :class:`dict`
    objects are not ordered, there is not enough information available to deduce
-   the order in which the row should be written to the *csvfile*.
+   the order in which the row should be written to the file *f*.
 
    A short usage example::
 
index 7b56ad7c25d58b73a1ad80e39157c1354a15b675..5ea246b83fe20922cd78a7cbe6a505dc281c1f34 100644 (file)
@@ -663,6 +663,12 @@ the following methods:
    character previously painter at that location.  By default, the character
    position and attributes are the current settings for the window object.
 
+   .. note::
+
+      Writing outside the window, subwindow, or pad raises a :exc:`curses.error`.
+      Attempting to write to the lower right corner of a window, subwindow,
+      or pad will cause an exception to be raised after the character is printed.
+
 
 .. method:: window.addnstr(str, n[, attr])
             window.addnstr(y, x, str, n[, attr])
@@ -677,6 +683,12 @@ the following methods:
    Paint the string *str* at ``(y, x)`` with attributes *attr*, overwriting
    anything previously on the display.
 
+   .. note::
+
+      Writing outside the window, subwindow, or pad raises :exc:`curses.error`.
+      Attempting to write to the lower right corner of a window, subwindow,
+      or pad will cause an exception to be raised after the string is printed.
+
 
 .. method:: window.attroff(attr)
 
@@ -765,11 +777,11 @@ the following methods:
             window.chgat(y, x, num, attr)
 
    Set the attributes of *num* characters at the current cursor position, or at
-   position ``(y, x)`` if supplied. If no value of *num* is given or *num* = -1,
-   the attribute will  be set on all the characters to the end of the line.  This
-   function does not move the cursor. The changed line will be touched using the
-   :meth:`touchline` method so that the contents will be redisplayed by the next
-   window refresh.
+   position ``(y, x)`` if supplied. If *num* is not given or is ``-1``,
+   the attribute will be set on all the characters to the end of the line.  This
+   function moves cursor to position ``(y, x)`` if supplied. The changed line
+   will be touched using the :meth:`touchline` method so that the contents will
+   be redisplayed by the next window refresh.
 
 
 .. method:: window.clear()
index a6358e44b15d96cc0b079437e74b79f6168968b3..b6f7120947c4a5a3d924616f250cd733ddf58890 100644 (file)
@@ -76,6 +76,9 @@ options:
 * ``--no-default-pip``: if a non-default installation is request, the ``pip``
   script will *not* be installed.
 
+.. versionchanged:: 2.7.15
+   The exit status is non-zero if the command fails.
+
 
 Module API
 ----------
index f885afb5befdd2651d451fdca5a65c759b7719ba..4b4883a7e332bb711554b5759a6ac1493f6656cf 100644 (file)
@@ -149,7 +149,7 @@ Class-based API
 
 The class-based API of the :mod:`gettext` module gives you more flexibility and
 greater convenience than the GNU :program:`gettext` API.  It is the recommended
-way of localizing your Python applications and modules.  :mod:`gettext` defines
+way of localizing your Python applications and modules.  :mod:`!gettext` defines
 a "translations" class which implements the parsing of GNU :file:`.mo` format
 files, and has methods for returning either standard 8-bit strings or Unicode
 strings. Instances of this "translations" class can also install themselves  in
@@ -239,7 +239,7 @@ Translation classes are what actually implement the translation of original
 source file message strings to translated message strings. The base class used
 by all translation classes is :class:`NullTranslations`; this provides the basic
 interface you can use to write your own specialized translation classes.  Here
-are the methods of :class:`NullTranslations`:
+are the methods of :class:`!NullTranslations`:
 
 
 .. class:: NullTranslations([fp])
@@ -268,14 +268,14 @@ are the methods of :class:`NullTranslations`:
 
    .. method:: gettext(message)
 
-      If a fallback has been set, forward :meth:`gettext` to the
+      If a fallback has been set, forward :meth:`!gettext` to the
       fallback. Otherwise, return the translated message.  Overridden in derived
       classes.
 
 
    .. method:: lgettext(message)
 
-      If a fallback has been set, forward :meth:`lgettext` to the
+      If a fallback has been set, forward :meth:`!lgettext` to the
       fallback. Otherwise, return the translated message.  Overridden in derived
       classes.
 
@@ -284,14 +284,14 @@ are the methods of :class:`NullTranslations`:
 
    .. method:: ugettext(message)
 
-      If a fallback has been set, forward :meth:`ugettext` to the
+      If a fallback has been set, forward :meth:`!ugettext` to the
       fallback. Otherwise, return the translated message as a Unicode
       string. Overridden in derived classes.
 
 
    .. method:: ngettext(singular, plural, n)
 
-      If a fallback has been set, forward :meth:`ngettext` to the
+      If a fallback has been set, forward :meth:`!ngettext` to the
       fallback. Otherwise, return the translated message.  Overridden in derived
       classes.
 
@@ -300,7 +300,7 @@ are the methods of :class:`NullTranslations`:
 
    .. method:: lngettext(singular, plural, n)
 
-      If a fallback has been set, forward :meth:`lngettext` to the
+      If a fallback has been set, forward :meth:`!lngettext` to the
       fallback. Otherwise, return the translated message.  Overridden in derived
       classes.
 
@@ -309,7 +309,7 @@ are the methods of :class:`NullTranslations`:
 
    .. method:: ungettext(singular, plural, n)
 
-      If a fallback has been set, forward :meth:`ungettext` to the fallback.
+      If a fallback has been set, forward :meth:`!ungettext` to the fallback.
       Otherwise, return the translated message as a Unicode string. Overridden
       in derived classes.
 
index 57ba4d45e9b2674a8ff2b3629aee774f93a57e54..17303dd01cef0639c42e99441008332dbc22663d 100644 (file)
@@ -411,12 +411,24 @@ loops that truncate the stream.
           # islice('ABCDEFG', 2, None) --> C D E F G
           # islice('ABCDEFG', 0, None, 2) --> A C E G
           s = slice(*args)
-          it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1))
-          nexti = next(it)
-          for i, element in enumerate(iterable):
-              if i == nexti:
-                  yield element
-                  nexti = next(it)
+          start, stop, step = s.start or 0, s.stop or sys.maxint, s.step or 1
+          it = iter(xrange(start, stop, step)))
+          try:
+              nexti = next(it)
+          except StopIteration:
+              # Consume *iterable* up to the *start* position.
+              for i, element in izip(xrange(start), iterable):
+                  pass
+              return
+          try:
+              for i, element in enumerate(iterable):
+                  if i == nexti:
+                      yield element
+                      nexti = next(it)
+          except StopIteration:
+              # Consume to *stop*.
+              for i, element in izip(xrange(i + 1, stop), iterable):
+                  pass
 
    If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
    then the step defaults to one.
@@ -681,8 +693,8 @@ which incur interpreter overhead.
        "Return function(0), function(1), ..."
        return imap(function, count(start))
 
-   def consume(iterator, n):
-       "Advance the iterator n-steps ahead. If n is none, consume entirely."
+   def consume(iterator, n=None):
+       "Advance the iterator n-steps ahead. If n is None, consume entirely."
        # Use functions that consume iterators at C speed.
        if n is None:
            # feed the entire iterator into a zero-length deque
index 0b0268537a47ea0b685251101e57fd91d16710ba..e16f131b57d2969448900c09c4524ea287ba10e0 100644 (file)
@@ -552,17 +552,23 @@ library.
 Access to message catalogs
 --------------------------
 
+.. function:: gettext(msg)
+.. function:: dgettext(domain, msg)
+.. function:: dcgettext(domain, msg, category)
+.. function:: textdomain(domain)
+.. function:: bindtextdomain(domain, dir)
+
 The locale module exposes the C library's gettext interface on systems that
-provide this interface.  It consists of the functions :func:`gettext`,
-:func:`dgettext`, :func:`dcgettext`, :func:`textdomain`, :func:`bindtextdomain`,
-and :func:`bind_textdomain_codeset`.  These are similar to the same functions in
+provide this interface.  It consists of the functions :func:`!gettext`,
+:func:`!dgettext`, :func:`!dcgettext`, :func:`!textdomain`, :func:`!bindtextdomain`,
+and :func:`!bind_textdomain_codeset`.  These are similar to the same functions in
 the :mod:`gettext` module, but use the C library's binary format for message
 catalogs, and the C library's search algorithms for locating message catalogs.
 
 Python applications should normally find no need to invoke these functions, and
 should use :mod:`gettext` instead.  A known exception to this rule are
 applications that link with additional C libraries which internally invoke
-:c:func:`gettext` or :func:`dcgettext`.  For these applications, it may be
+:c:func:`gettext` or :c:func:`dcgettext`.  For these applications, it may be
 necessary to bind the text domain, so that the libraries can properly locate
 their message catalogs.
 
index ba2ab835fd4a66cc5d1edc49077b99b4a179896f..0f568aaa97604be5e6e22e2418fe8be79b1e3fdb 100644 (file)
@@ -95,10 +95,10 @@ is the module's name in the Python package namespace.
       scenario is to attach handlers only to the root logger, and to let
       propagation take care of the rest.
 
-.. method:: Logger.setLevel(lvl)
+.. method:: Logger.setLevel(level)
 
-   Sets the threshold for this logger to *lvl*. Logging messages which are less
-   severe than *lvl* will be ignored. When a logger is created, the level is set to
+   Sets the threshold for this logger to *level*. Logging messages which are less
+   severe than *level* will be ignored. When a logger is created, the level is set to
    :const:`NOTSET` (which causes all messages to be processed when the logger is
    the root logger, or delegation to the parent when the logger is a non-root
    logger). Note that the root logger is created with level :const:`WARNING`.
@@ -232,14 +232,14 @@ is the module's name in the Python package namespace.
    should only be called from an exception handler.
 
 
-.. method:: Logger.addFilter(filt)
+.. method:: Logger.addFilter(filter)
 
-   Adds the specified filter *filt* to this logger.
+   Adds the specified filter *filter* to this logger.
 
 
-.. method:: Logger.removeFilter(filt)
+.. method:: Logger.removeFilter(filter)
 
-   Removes the specified filter *filt* from this logger.
+   Removes the specified filter *filter* from this logger.
 
 
 .. method:: Logger.filter(record)
@@ -349,27 +349,27 @@ subclasses. However, the :meth:`__init__` method in subclasses needs to call
    Releases the thread lock acquired with :meth:`acquire`.
 
 
-.. method:: Handler.setLevel(lvl)
+.. method:: Handler.setLevel(level)
 
-   Sets the threshold for this handler to *lvl*. Logging messages which are less
-   severe than *lvl* will be ignored. When a handler is created, the level is set
+   Sets the threshold for this handler to *level*. Logging messages which are less
+   severe than *level* will be ignored. When a handler is created, the level is set
    to :const:`NOTSET` (which causes all messages to be processed).
 
    See :ref:`levels` for a list of levels.
 
-.. method:: Handler.setFormatter(form)
+.. method:: Handler.setFormatter(fmt)
 
-   Sets the :class:`Formatter` for this handler to *form*.
+   Sets the :class:`Formatter` for this handler to *fmt*.
 
 
-.. method:: Handler.addFilter(filt)
+.. method:: Handler.addFilter(filter)
 
-   Adds the specified filter *filt* to this handler.
+   Adds the specified filter *filter* to this handler.
 
 
-.. method:: Handler.removeFilter(filt)
+.. method:: Handler.removeFilter(filter)
 
-   Removes the specified filter *filt* from this handler.
+   Removes the specified filter *filter* from this handler.
 
 
 .. method:: Handler.filter(record)
index 9f894cae1df2abe9a77e96c73d21fff1e250d6e4..9c9452f92b1b913f3db4c0d80de75cca4a2e1b7b 100644 (file)
@@ -474,7 +474,7 @@ Maildir, mbox, MH, Babyl, and MMDF.
    `Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad <https://www.jwz.org/doc/content-length.html>`_
       An argument for using the original mbox format rather than a variation.
 
-   `"mbox" is a family of several mutually incompatible mailbox formats <http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html>`_
+   `"mbox" is a family of several mutually incompatible mailbox formats <https://www.loc.gov/preservation/digital/formats/fdd/fdd000383.shtml>`_
       A history of mbox variations.
 
 
index a4d382c15a98c0f3a828c6ce0ae1993d01181a7c..55785bd3e495ad5a4b8907b019fe5d2c916748b5 100644 (file)
@@ -311,7 +311,7 @@ Record Objects
 Errors
 ------
 
-All wrappers around MSI functions raise :exc:`MsiError`; the string inside the
+All wrappers around MSI functions raise :exc:`MSIError`; the string inside the
 exception will contain more detail.
 
 
index d0798b78f2ec77a2ae3229f3e79261b21f6c43a0..c424230e13a4191e5d03a3efe8f6fca08215bade 100644 (file)
@@ -532,7 +532,8 @@ form.
    This flag allows you to write regular expressions that look nicer and are
    more readable by allowing you to visually separate logical sections of the
    pattern and add comments. Whitespace within the pattern is ignored, except
-   when in a character class or when preceded by an unescaped backslash.
+   when in a character class, or when preceded by an unescaped backslash,
+   or within tokens like ``*?``, ``(?:`` or ``(?P<...>``.
    When a line contains a ``#`` that is not in a character class and is not
    preceded by an unescaped backslash, all characters from the leftmost such
    ``#`` through the end of the line are ignored.
@@ -610,14 +611,21 @@ form.
       Added the optional flags argument.
 
 
+
 .. function:: findall(pattern, string, flags=0)
 
    Return all non-overlapping matches of *pattern* in *string*, as a list of
    strings.  The *string* is scanned left-to-right, and matches are returned in
    the order found.  If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern has more than
-   one group.  Empty matches are included in the result unless they touch the
-   beginning of another match.
+   one group.  Empty matches are included in the result.
+
+   .. note::
+
+      Due to the limitation of the current implementation the character
+      following an empty match is not included in a next match, so
+      ``findall(r'^|\w+', 'two words')`` returns ``['', 'wo', 'words']``
+      (note missed "t").  This is changed in Python 3.7.
 
    .. versionadded:: 1.5.2
 
@@ -630,8 +638,7 @@ form.
    Return an :term:`iterator` yielding :class:`MatchObject` instances over all
    non-overlapping matches for the RE *pattern* in *string*.  The *string* is
    scanned left-to-right, and matches are returned in the order found.  Empty
-   matches are included in the result unless they touch the beginning of another
-   match.
+   matches are included in the result.  See also the note about :func:`findall`.
 
    .. versionadded:: 2.2
 
index ebe6c0a80c50cc2ddf8a04432d227bf089b2f555..1fba8ba6e519b262ca44e891e6a1a2d98a01b71e 100644 (file)
@@ -84,7 +84,7 @@ Scheduler Objects
    Schedule a new event. The *time* argument should be a numeric type compatible
    with the return value of the *timefunc* function passed  to the constructor.
    Events scheduled for the same *time* will be executed in the order of their
-   *priority*.
+   *priority*. A lower number represents a higher priority.
 
    Executing the event means executing ``action(*argument)``.  *argument* must be a
    sequence holding the parameters for *action*.
index a81214e906c5dcbd6f4ee3c91415dd09992c8c7f..1ad4b682ae6ce32b76b6f36c72ddd0eaec67b967 100644 (file)
@@ -284,7 +284,7 @@ Server Objects
    .. XXX should the default implementations of these be documented, or should
       it be assumed that the user will look at SocketServer.py?
 
-   .. method:: finish_request()
+   .. method:: finish_request(request, client_address)
 
       Actually processes the request by instantiating :attr:`RequestHandlerClass` and
       calling its :meth:`~BaseRequestHandler.handle` method.
index 183c17bb560d8271d64fccb273a0b7bb3203cfaa..89b9ff3621f7b7e19879d8a80547960cb96e27c9 100644 (file)
@@ -192,12 +192,17 @@ instead.
        ------------------------  ---------  ---------  ----------  ---------  -----------  -----------
         *SSLv2*                    yes        no         yes         no         no         no
         *SSLv3*                    no         yes        yes         no         no         no
-        *SSLv23*                   no         yes        yes         yes        yes        yes
+        *SSLv23* [1]_              no         yes        yes         yes        yes        yes
         *TLSv1*                    no         no         yes         yes        no         no
         *TLSv1.1*                  no         no         yes         no         yes        no
         *TLSv1.2*                  no         no         yes         no         no         yes
        ========================  =========  =========  ==========  =========  ===========  ===========
 
+   .. rubric:: Footnotes
+   .. [1] TLS 1.3 protocol will be available with :data:`PROTOCOL_SSLv23` in
+      OpenSSL >= 1.1.1. There is no dedicated PROTOCOL constant for just
+      TLS 1.3.
+
    .. note::
 
       Which connections succeed will vary depending on the version of
@@ -206,7 +211,7 @@ instead.
 
    The *ciphers* parameter sets the available ciphers for this SSL object.
    It should be a string in the `OpenSSL cipher list format
-   <https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT>`_.
+   <https://wiki.openssl.org/index.php/Manual:Ciphers(1)#CIPHER_LIST_FORMAT>`_.
 
    The parameter ``do_handshake_on_connect`` specifies whether to do the SSL
    handshake automatically after doing a :meth:`socket.connect`, or whether the
@@ -286,6 +291,11 @@ purposes.
 
      3DES was dropped from the default cipher string.
 
+   .. versionchanged:: 2.7.15
+
+     TLS 1.3 cipher suites TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384,
+     and TLS_CHACHA20_POLY1305_SHA256 were added to the default cipher string.
+
 .. function:: _https_verify_certificates(enable=True)
 
    Specifies whether or not server certificates are verified when creating
@@ -701,6 +711,16 @@ Constants
 
    .. versionadded:: 2.7.9
 
+.. data:: OP_NO_TLSv1_3
+
+   Prevents a TLSv1.3 connection. This option is only applicable in conjunction
+   with :const:`PROTOCOL_TLS`. It prevents the peers from choosing TLSv1.3 as
+   the protocol version. TLS 1.3 is available with OpenSSL 1.1.1 or later.
+   When Python has been compiled against an older version of OpenSSL, the
+   flag defaults to *0*.
+
+   .. versionadded:: 2.7.15
+
 .. data:: OP_CIPHER_SERVER_PREFERENCE
 
    Use the server's cipher ordering preference, rather than the client's.
@@ -765,6 +785,12 @@ Constants
 
    .. versionadded:: 2.7.9
 
+.. data:: HAS_TLSv1_3
+
+   Whether the OpenSSL library has built-in support for the TLS 1.3 protocol.
+
+   .. versionadded:: 2.7.15
+
 .. data:: CHANNEL_BINDING_TYPES
 
    List of supported TLS channel binding types.  Strings in this list
@@ -1108,7 +1134,7 @@ to speed up repeated connections from the same clients.
    The *capath* string, if present, is
    the path to a directory containing several CA certificates in PEM format,
    following an `OpenSSL specific layout
-   <https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html>`_.
+   <https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_load_verify_locations.html>`_.
 
    The *cadata* object, if present, is either an ASCII string of one or more
    PEM-encoded certificates or a bytes-like object of DER-encoded
@@ -1141,7 +1167,7 @@ to speed up repeated connections from the same clients.
 
    Set the available ciphers for sockets created with this context.
    It should be a string in the `OpenSSL cipher list format
-   <https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT>`_.
+   <https://wiki.openssl.org/index.php/Manual:Ciphers(1)#CIPHER_LIST_FORMAT>`_.
    If no cipher can be selected (because compile-time options or other
    configuration forbids use of all the specified ciphers), an
    :class:`SSLError` will be raised.
@@ -1284,7 +1310,7 @@ to speed up repeated connections from the same clients.
 
    Get statistics about the SSL sessions created or managed by this context.
    A dictionary is returned which maps the names of each `piece of information
-   <https://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html>`_ to their
+   <https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_sess_number.html>`_ to their
    numeric values.  For example, here is the total number of hits and misses
    in the session cache since the context was created::
 
@@ -1304,7 +1330,7 @@ to speed up repeated connections from the same clients.
 
       import socket, ssl
 
-      context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+      context = ssl.SSLContext(ssl.PROTOCOL_TLS)
       context.verify_mode = ssl.CERT_REQUIRED
       context.check_hostname = True
       context.load_default_certs()
@@ -1510,7 +1536,7 @@ If you prefer to tune security settings yourself, you might create
 a context from scratch (but beware that you might not get the settings
 right)::
 
-   >>> context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+   >>> context = ssl.SSLContext(ssl.PROTOCOL_TLS)
    >>> context.verify_mode = ssl.CERT_REQUIRED
    >>> context.check_hostname = True
    >>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")
@@ -1782,6 +1808,23 @@ successful call of :func:`~ssl.RAND_add`, :func:`~ssl.RAND_bytes` or
 :func:`~ssl.RAND_pseudo_bytes` is sufficient.
 
 
+.. ssl-libressl:
+
+LibreSSL support
+----------------
+
+LibreSSL is a fork of OpenSSL 1.0.1. The ssl module has limited support for
+LibreSSL. Some features are not available when the ssl module is compiled
+with LibreSSL.
+
+* LibreSSL >= 2.6.1 no longer supports NPN. The methods
+  :meth:`SSLContext.set_npn_protocols` and
+  :meth:`SSLSocket.selected_npn_protocol` are not available.
+* :meth:`SSLContext.set_default_verify_paths` ignores the env vars
+  :envvar:`SSL_CERT_FILE` and :envvar:`SSL_CERT_PATH` although
+  :func:`get_default_verify_paths` still reports them.
+
+
 .. seealso::
 
    Class :class:`socket.socket`
@@ -1810,3 +1853,9 @@ successful call of :func:`~ssl.RAND_add`, :func:`~ssl.RAND_bytes` or
 
    `IANA TLS: Transport Layer Security (TLS) Parameters <https://www.iana.org/assignments/tls-parameters/tls-parameters.xml>`_
        IANA
+
+   `RFC 7525: Recommendations for Secure Use of Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) <https://tools.ietf.org/html/rfc7525>`_
+       IETF
+
+   `Mozilla's Server Side TLS recommendations <https://wiki.mozilla.org/Security/Server_Side_TLS>`_
+       Mozilla
index bc7411c809a7ef4a730f177cbf41fc8d3b0686fa..e16bd77188fa21007c4403a18cf8111c391dcd41 100644 (file)
@@ -1071,9 +1071,10 @@ string functions based on regular expressions.
 .. method:: str.join(iterable)
 
    Return a string which is the concatenation of the strings in *iterable*.
-   A :exc:`TypeError` will be raised if there are any non-string values in
-   *iterable*, including :class:`bytes` objects.  The separator between
-   elements is the string providing this method.
+   If there is any Unicode object in *iterable*, return a Unicode instead.
+   A :exc:`TypeError` will be raised if there are any non-string or non Unicode
+   object values in *iterable*.  The separator between elements is the string
+   providing this method.
 
 
 .. method:: str.ljust(width[, fillchar])
index 31e644e394781d3b3d9c57cbcf6c18403553547d..5a7647b7e99d61d6565c6aed1f2e8a6a94d7b909 100644 (file)
@@ -857,13 +857,38 @@ always available.
    Set the system's profile function, which allows you to implement a Python source
    code profiler in Python.  See chapter :ref:`profile` for more information on the
    Python profiler.  The system's profile function is called similarly to the
-   system's trace function (see :func:`settrace`), but it isn't called for each
-   executed line of code (only on call and return, but the return event is reported
-   even when an exception has been set).  The function is thread-specific, but
-   there is no way for the profiler to know about context switches between threads,
-   so it does not make sense to use this in the presence of multiple threads. Also,
+   system's trace function (see :func:`settrace`), but it is called with different events,
+   for example it isn't called for each executed line of code (only on call and return,
+   but the return event is reported even when an exception has been set). The function is
+   thread-specific, but there is no way for the profiler to know about context switches between
+   threads, so it does not make sense to use this in the presence of multiple threads. Also,
    its return value is not used, so it can simply return ``None``.
 
+   Profile functions should have three arguments: *frame*, *event*, and
+   *arg*. *frame* is the current stack frame.  *event* is a string: ``'call'``,
+   ``'return'``, ``'c_call'``, ``'c_return'``, or ``'c_exception'``. *arg* depends
+   on the event type.
+
+   The events have the following meaning:
+
+   ``'call'``
+      A function is called (or some other code block entered).  The
+      profile function is called; *arg* is ``None``.
+
+   ``'return'``
+      A function (or other code block) is about to return.  The profile
+      function is called; *arg* is the value that will be returned, or ``None``
+      if the event is caused by an exception being raised.
+
+   ``'c_call'``
+      A C function is about to be called.  This may be an extension function or
+      a built-in.  *arg* is the C function object.
+
+   ``'c_return'``
+      A C function has returned. *arg* is the C function object.
+
+   ``'c_exception'``
+      A C function has raised an exception.  *arg* is the C function object.
 
 .. function:: setrecursionlimit(limit)
 
@@ -890,8 +915,8 @@ always available.
 
    Trace functions should have three arguments: *frame*, *event*, and
    *arg*. *frame* is the current stack frame.  *event* is a string: ``'call'``,
-   ``'line'``, ``'return'``, ``'exception'``, ``'c_call'``, ``'c_return'``, or
-   ``'c_exception'``. *arg* depends on the event type.
+   ``'line'``, ``'return'`` or ``'exception'``.  *arg* depends on
+   the event type.
 
    The trace function is invoked (with *event* set to ``'call'``) whenever a new
    local scope is entered; it should return a reference to a local trace
@@ -926,16 +951,6 @@ always available.
       tuple ``(exception, value, traceback)``; the return value specifies the
       new local trace function.
 
-   ``'c_call'``
-      A C function is about to be called.  This may be an extension function or
-      a built-in.  *arg* is the C function object.
-
-   ``'c_return'``
-      A C function has returned. *arg* is the C function object.
-
-   ``'c_exception'``
-      A C function has raised an exception.  *arg* is the C function object.
-
    Note that as an exception is propagated down the chain of callers, an
    ``'exception'`` event is generated at each level.
 
@@ -1078,4 +1093,3 @@ always available.
 .. rubric:: Citations
 
 .. [C99] ISO/IEC 9899:1999.  "Programming languages -- C."  A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\ .
-
index ab1da5243773eba1908ad4dd8cc9dc5bc7c2670f..ce5e63a717b3eed0a8b99f14ab0dec2da394e233 100644 (file)
@@ -161,7 +161,7 @@ background material, while the second half can be taken to the keyboard as a
 handy reference.
 
 When trying to answer questions of the form "how do I do blah", it is often best
-to find out how to do"blah" in straight Tk, and then convert this back into the
+to find out how to do "blah" in straight Tk, and then convert this back into the
 corresponding :mod:`Tkinter` call. Python programmers can often guess at the
 correct Python command by looking at the Tk documentation. This means that in
 order to use Tkinter, you will have to know a little bit about Tk. This document
index 15765f5ed58892074b5d2289423fc3f122efa648..b36126e1cc6587b96d56fb9cfd66a8993eb5c899 100644 (file)
@@ -2038,7 +2038,7 @@ handling functionality within test frameworks.
 
    When called without arguments this function removes the control-c handler
    if it has been installed. This function can also be used as a test decorator
-   to temporarily remove the handler whilst the test is being executed::
+   to temporarily remove the handler while the test is being executed::
 
       @unittest.removeHandler
       def test_signal_handling(self):
index 39d811be6d7f01158a2350c53df5f87f82e0cd94..e13da105cf51ec05bebc19e6dbb0d77ab3b161dd 100644 (file)
@@ -274,7 +274,7 @@ If the XML input has `namespaces
 with prefixes in the form ``prefix:sometag`` get expanded to
 ``{uri}sometag`` where the *prefix* is replaced by the full *URI*.
 Also, if there is a `default namespace
-<https://www.w3.org/TR/2006/REC-xml-names-20060816/#defaulting>`__,
+<https://www.w3.org/TR/xml-names/#defaulting>`__,
 that full URI gets prepended to all of the non-prefixed tags.
 
 Here is an XML example that incorporates two namespaces, one with the
index 942ad20e47bfadf720b4bfbb899a7a9975a77faf..f33495ab1ef9433ff81b55f76f9d4d2a4d95f04c 100644 (file)
@@ -87,7 +87,7 @@ PSF LICENSE AGREEMENT FOR PYTHON |release|
       analyze, test, perform and/or display publicly, prepare derivative works,
       distribute, and otherwise use Python |release| alone or in any derivative
       version, provided, however, that PSF's License Agreement and PSF's notice of
-      copyright, i.e., "Copyright © 2001-2017 Python Software Foundation; All Rights
+      copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights
       Reserved" are retained in Python |release| alone or in any derivative version
       prepared by Licensee.
 
index ef0e412c6c72339473b722c04e09eb6e7d334f9c..d8e8df00d8afdbd8c988611b9f6dbdc49c7d24f8 100644 (file)
@@ -5,8 +5,19 @@ pushd %~dp0
 \r
 set this=%~n0\r
 \r
-if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build\r
-if "%PYTHON%" EQU "" set PYTHON=py\r
+call ..\PCBuild\find_python.bat %PYTHON%\r
+if not defined SPHINXBUILD if defined PYTHON (\r
+    %PYTHON% -c "import sphinx" > nul 2> nul\r
+    if errorlevel 1 (\r
+        echo Installing sphinx with %PYTHON%\r
+        %PYTHON% -m pip install sphinx\r
+        if errorlevel 1 exit /B\r
+    )\r
+    set SPHINXBUILD=%PYTHON% -c "import sphinx, sys; sys.argv[0] = 'sphinx-build'; sphinx.main()"\r
+)\r
+\r
+if not defined PYTHON set PYTHON=py\r
+if not defined SPHINXBUILD set SPHINXBUILD=sphinx-build\r
 \r
 if DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles(x86)%\r
 if NOT DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles%\r
@@ -73,7 +84,7 @@ goto end
 if NOT "%PAPER%" == "" (\r
     set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%\r
 )\r
-cmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*\r
+cmd /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*"\r
 \r
 if "%1" EQU "htmlhelp" (\r
     if  not exist "%HTMLHELP%" (\r
index bd31faca4c60589c7856b60101d8e41b5d479c40..8e0c5ea0092a9fe53e1bdbb22f045b073ddaf91e 100644 (file)
     '(?:release/\\d.\\d[\\x\\d\\.]*)'];
 
   var all_versions = {
-    '3.7': 'dev (3.7)',
+    '3.8': 'dev (3.8)',
+    '3.7': 'pre (3.7)',
     '3.6': '3.6',
     '3.5': '3.5',
-    '3.4': '3.4',
-    '3.3': '3.3',
     '2.7': '2.7',
   };
 
index 76071e85d796c593bff85d4ef2b2242ffc716509..ddd8d75432ce1bbba510d5d97e28be2667aeabba 100644 (file)
@@ -2,9 +2,10 @@
 <p><a href="{{ pathto('download') }}">{% trans %}Download these documents{% endtrans %}</a></p>
 <h3>{% trans %}Docs for other versions{% endtrans %}</h3>
 <ul>
-  <li><a href="https://docs.python.org/3.5/">{% trans %}Python 3.5 (stable){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.8/">{% trans %}Python 3.8 (in development){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.7/">{% trans %}Python 3.7 (pre-release){% endtrans %}</a></li>
   <li><a href="https://docs.python.org/3.6/">{% trans %}Python 3.6 (stable){% endtrans %}</a></li>
-  <li><a href="https://docs.python.org/3.7/">{% trans %}Python 3.7 (in development){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.5/">{% trans %}Python 3.5 (stable){% endtrans %}</a></li>
   <li><a href="https://www.python.org/doc/versions/">{% trans %}Old versions{% endtrans %}</a></li>
 </ul>
 
index 216dcae6b60e4d9eb8e2dda785ae93be32e05873..7f45c7632d5a9287521b03c8bd18be8ba3f544ea 100644 (file)
@@ -873,9 +873,9 @@ Generator Expressions
 =====================
 
 Some simple generators can be coded succinctly as expressions using a syntax
-similar to list comprehensions but with parentheses instead of brackets.  These
-expressions are designed for situations where the generator is used right away
-by an enclosing function.  Generator expressions are more compact but less
+similar to list comprehensions but with parentheses instead of square brackets.
+These expressions are designed for situations where the generator is used right
+away by an enclosing function.  Generator expressions are more compact but less
 versatile than full generator definitions and tend to be more memory friendly
 than equivalent list comprehensions.
 
index d6c3cb6ac81bafc859d41d0214d5faa0de545c0e..78d6ba31e0ba3a9a52d83752680d3906e37768c8 100644 (file)
@@ -101,7 +101,7 @@ Here are two ways to write a table of squares and cubes::
    10 100 1000
 
 (Note that in the first example, one space between each column was added by the
-way :keyword:`print` works: it always adds spaces between its arguments.)
+way :keyword:`print` works: by default it adds spaces between its arguments.)
 
 This example demonstrates the :meth:`str.rjust` method of string
 objects, which right-justifies a string in a field of a given width by padding
index 3bf9c62ca87cc1d77940160e73c7bc72814d04a1..6c8609fabaeb52362ff439632c07ff8f170eecca 100644 (file)
@@ -126,14 +126,7 @@ The Interpreter and Its Environment
 Source Code Encoding
 --------------------
 
-By default, Python source files are treated as encoded in UTF-8.  In that
-encoding, characters of most languages in the world can be used simultaneously
-in string literals, identifiers and comments --- although the standard library
-only uses ASCII characters for identifiers, a convention that any portable code
-should follow.  To display all these characters properly, your editor must
-recognize that the file is UTF-8, and it must use a font that supports all the
-characters in the file.
-
+By default, Python source files are treated as encoded in ASCII.
 To declare an encoding other than the default one, a special comment line
 should be added as the *first* line of the file.  The syntax is as follows::
 
index b7be00ed7ad3273364a8dffb900f2c5f725f33b0..be9aa834748087631ff194a60170dde038a47888 100644 (file)
@@ -218,6 +218,13 @@ to each other are automatically concatenated. ::
    >>> 'Py' 'thon'
    'Python'
 
+This feature is particularly useful when you want to break long strings::
+
+   >>> text = ('Put several strings within parentheses '
+   ...         'to have them joined together.')
+   >>> text
+   'Put several strings within parentheses to have them joined together.'
+
 This only works with two literals though, not with variables or expressions::
 
    >>> prefix = 'Py'
@@ -233,13 +240,6 @@ If you want to concatenate variables or a variable and a literal, use ``+``::
    >>> prefix + 'thon'
    'Python'
 
-This feature is particularly useful when you want to break long strings::
-
-   >>> text = ('Put several strings within parentheses '
-   ...         'to have them joined together.')
-   >>> text
-   'Put several strings within parentheses to have them joined together.'
-
 Strings can be *indexed* (subscripted), with the first character having index 0.
 There is no separate character type; a character is simply a string of size
 one::
index 6fb4ffda2b84e0081760f39322118db3b073b7b8..ec3bd9c53d2ec6ce03bd49c2f2fb018267ba146f 100644 (file)
@@ -108,6 +108,25 @@ Note that in general the practice of importing ``*`` from a module or package is
 frowned upon, since it often causes poorly readable code. However, it is okay to
 use it to save typing in interactive sessions.
 
+If the module name is followed by :keyword:`as`, then the name
+following :keyword:`as` is bound directly to the imported module.
+
+::
+
+   >>> import fibo as fib
+   >>> fib.fib(500)
+   0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
+
+This is effectively importing the module in the same way that ``import fibo``
+will do, with the only difference of it being available as ``fib``.
+
+It can also be used when utilising :keyword:`from` with similar effects::
+
+   >>> from fibo import fib as fibonacci
+   >>> fibonacci(500)
+   0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
+
+
 .. note::
 
    For efficiency reasons, each module is only imported once per interpreter
index f00f7f6026a0febad21ea2ee559b35ce52433eab..c27ec4f3e634a5cdc4fc87b49fa1e333b360ee7c 100644 (file)
@@ -411,8 +411,6 @@ Miscellaneous options
    Skip the first line of the source, allowing use of non-Unix forms of
    ``#!cmd``.  This is intended for a DOS specific hack only.
 
-   .. note:: The line numbers in error messages will be off by one.
-
 .. cmdoption:: -3
 
    Warn about Python 3.x possible incompatibilities by emitting a
@@ -663,3 +661,17 @@ if Python was configured with the ``--with-pydebug`` build option.
 
    If set, Python will print memory allocation statistics every time a new
    object arena is created, and on shutdown.
+
+.. envvar:: PYTHONSHOWALLOCCOUNT
+
+   If set and Python was compiled with ``COUNT_ALLOCS`` defined, Python will
+   dump allocations counts into stderr on shutdown.
+
+   .. versionadded:: 2.7.15
+
+.. envvar:: PYTHONSHOWREFCOUNT
+
+   If set, Python will print the total reference count when the program
+   finishes or after each statement in the interactive interpreter.
+
+   .. versionadded:: 2.7.15
index 2da26d87a5b8b6a26621699cffd08f34c5f3e22b..7719baa8cdebbba3dbf4b7a9c7c5af300eab1d37 100644 (file)
@@ -41,9 +41,11 @@ On FreeBSD and OpenBSD
 
 * FreeBSD users, to add the package use::
 
-     pkg_add -r python
+     pkg install python3
+
+* OpenBSD users, to add the package use::
 
-* OpenBSD users use::
+     pkg_add -r python
 
      pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz
 
index 7c430094d831b93fa6e238aa397dedc5f6dfdb55..f4c742e1d91d5ea3b6fd1fb53bfd02e20dcafb67 100644 (file)
@@ -2607,7 +2607,7 @@ changes, or look through the Subversion logs for all the details.
 
 * The XML-RPC :class:`~SimpleXMLRPCServer.SimpleXMLRPCServer` and :class:`~DocXMLRPCServer.DocXMLRPCServer`
   classes can now be prevented from immediately opening and binding to
-  their socket by passing True as the ``bind_and_activate``
+  their socket by passing ``False`` as the *bind_and_activate*
   constructor parameter.  This can be used to modify the instance's
   :attr:`allow_reuse_address` attribute before calling the
   :meth:`server_bind` and :meth:`server_activate` methods to
index 28a8d4be47b0dd66ad067c834851113421ce5ee3..53333ebf7c1a3a06d3bc08099ad056c9cfa29592 100644 (file)
@@ -1218,6 +1218,11 @@ changes, or look through the Subversion logs for all the details.
   created some new files that should be included.
   (Fixed by Tarek Ziadé; :issue:`8688`.)
 
+  The ``upload`` command now longer tries to change CR end-of-line characters
+  to CRLF.  This fixes a corruption issue with sdists that ended with a byte
+  equivalent to CR.
+  (Contributed by Bo Bayles in :issue:`32304`.)
+
 * The :mod:`doctest` module's :const:`IGNORE_EXCEPTION_DETAIL` flag
   will now ignore the name of the module containing the exception
   being tested.  (Patch by Lennart Regebro; :issue:`7490`.)
@@ -2540,6 +2545,21 @@ exemption allowing new ``-3`` warnings to be added in any Python 2.7
 maintenance release.
 
 
+Two new environment variables for debug mode
+--------------------------------------------
+
+In debug mode, the ``[xxx refs]`` statistic is not written by default, the
+:envvar:`PYTHONSHOWREFCOUNT` environment variable now must also be set.
+(Contributed by Victor Stinner; :issue:`31733`.)
+
+When Python is compiled with ``COUNT_ALLOC`` defined, allocation counts are no
+longer dumped by default anymore: the :envvar:`PYTHONSHOWALLOCCOUNT` environment
+variable must now also be set. Moreover, allocation counts are now dumped into
+stderr, rather than stdout. (Contributed by Victor Stinner; :issue:`31692`.)
+
+.. versionadded:: 2.7.15
+
+
 PEP 434: IDLE Enhancement Exception for All Branches
 ----------------------------------------------------
 
index 775412b8c4ef188aa1984752c80b58e4465ddd2b..a9327b02c81f0926ee83c89ebac59d4ff9b1015d 100644 (file)
@@ -43,6 +43,9 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
 
 /* For size_t? */
 #ifdef HAVE_STDDEF_H
index 17e7679ac870f0cabe67d05b85fc5a42e230f1d1..843908159ddb8f2241673ce5d35591e515550baa 100644 (file)
@@ -54,7 +54,7 @@ typedef struct _frame {
 
 PyAPI_DATA(PyTypeObject) PyFrame_Type;
 
-#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
+#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type)
 #define PyFrame_IsRestricted(f) \
        ((f)->f_builtins != (f)->f_tstate->interp->builtins)
 
index 252eea9fd92ffa4106a381c2149e2c18714224d0..59d061629e25cfa447a32edfa5dd63029822d584 100644 (file)
@@ -28,8 +28,8 @@ typedef struct {
 PyAPI_DATA(PyTypeObject) PyInt_Type;
 
 #define PyInt_Check(op) \
-                PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS)
-#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
+                PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_INT_SUBCLASS)
+#define PyInt_CheckExact(op) (Py_TYPE(op) == &PyInt_Type)
 
 PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
 #ifdef Py_USING_UNICODE
index 55e83eced6a26538a1215f64f6bcd2349e4c9be5..cbf6bc3f87634c4b67d5f840d5447a1bbb1e56c7 100644 (file)
@@ -56,7 +56,7 @@ must use the platform malloc heap(s), or shared memory, or C++ local storage or
 operator new), you must first allocate the object with your custom allocator,
 then pass its pointer to PyObject_{Init, InitVar} for filling in its Python-
 specific fields:  reference count, type pointer, possibly others.  You should
-be aware that Python no control over these objects because they don't
+be aware that Python has no control over these objects because they don't
 cooperate with the Python memory manager.  Such objects may not be eligible
 for automatic garbage collection and you have to make sure that they are
 released accordingly whenever their destructor gets called (cf. the specific
@@ -248,6 +248,20 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
 /* for source compatibility with 2.2 */
 #define _PyObject_GC_Del PyObject_GC_Del
 
+/*
+ * Former over-aligned definition of PyGC_Head, used to compute the size of the
+ * padding for the new version below.
+ */
+union _gc_head;
+union _gc_head_old {
+    struct {
+        union _gc_head_old *gc_next;
+        union _gc_head_old *gc_prev;
+        Py_ssize_t gc_refs;
+    } gc;
+    long double dummy;
+};
+
 /* GC information is stored BEFORE the object structure. */
 typedef union _gc_head {
     struct {
@@ -255,7 +269,8 @@ typedef union _gc_head {
         union _gc_head *gc_prev;
         Py_ssize_t gc_refs;
     } gc;
-    long double dummy;  /* force worst-case alignment */
+    double dummy; /* Force at least 8-byte alignment. */
+    char dummy_padding[sizeof(union _gc_head_old)];
 } PyGC_Head;
 
 extern PyGC_Head *_PyGC_generation0;
index 8d05b91f012cce11ca5141022f0461226d69999b..99e837024ab4f0a3d119e78289da9e198df62e56 100644 (file)
 /*--start constants--*/
 #define PY_MAJOR_VERSION       2
 #define PY_MINOR_VERSION       7
-#define PY_MICRO_VERSION       14
+#define PY_MICRO_VERSION       15
 #define PY_RELEASE_LEVEL       PY_RELEASE_LEVEL_FINAL
 #define PY_RELEASE_SERIAL      0
 
 /* Version as a string */
-#define PY_VERSION             "2.7.14"
+#define PY_VERSION             "2.7.15"
 /*--end constants--*/
 
 /* Subversion Revision number of this file (not of the repository). Empty
index 657816cbd32681c400a6b8fd75736174fa66d8d5..eb77e35d8be7567a0713521771749e5dfeb252e2 100644 (file)
@@ -7,14 +7,9 @@
 ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
 ** against multiple definition of wchar_t.
 */
-#ifdef _BSD_WCHAR_T_DEFINED_
+#ifdef _BSD_WCHAR_T_DEFINED_
 #define _WCHAR_T
 #endif
-
-/* the following define is necessary for OS X 10.6; without it, the
-   Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
-   can't get at the WINDOW flags field. */
-#define NCURSES_OPAQUE 0
 #endif /* __APPLE__ */
 
 #ifdef __FreeBSD__
@@ -22,7 +17,7 @@
 ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
 ** against multiple definition of wchar_t and wint_t.
 */
-#ifdef _XOPEN_SOURCE_EXTENDED
+#ifdef _XOPEN_SOURCE_EXTENDED
 #ifndef __FreeBSD_version
 #include <osreldate.h>
 #endif
 #endif
 #endif
 
+#if !defined(HAVE_CURSES_IS_PAD) && defined(WINDOW_HAS_FLAGS)
+/* The following definition is necessary for ncurses 5.7; without it,
+   some of [n]curses.h set NCURSES_OPAQUE to 1, and then Python
+   can't get at the WINDOW flags field. */
+#define NCURSES_OPAQUE 0
+#endif
+
 #ifdef HAVE_NCURSES_H
 #include <ncurses.h>
 #else
 #include <curses.h>
-#ifdef HAVE_TERM_H
-/* for tigetstr, which is not declared in SysV curses */
-#include <term.h>
-#endif
 #endif
 
 #ifdef HAVE_NCURSES_H
 /* configure was checking <curses.h>, but we will
-   use <ncurses.h>, which has all these features. */
-#ifndef WINDOW_HAS_FLAGS
+   use <ncurses.h>, which has some or all these features. */
+#if !defined(WINDOW_HAS_FLAGS) && !(NCURSES_OPAQUE+0)
 #define WINDOW_HAS_FLAGS 1
 #endif
+#if !defined(HAVE_CURSES_IS_PAD) && NCURSES_VERSION_PATCH+0 >= 20090906
+#define HAVE_CURSES_IS_PAD 1
+#endif
 #ifndef MVWDELCH_IS_EXPRESSION
 #define MVWDELCH_IS_EXPRESSION 1
 #endif
@@ -74,11 +75,11 @@ extern "C" {
 /* Type declarations */
 
 typedef struct {
-       PyObject_HEAD
-       WINDOW *win;
+    PyObject_HEAD
+    WINDOW *win;
 } PyCursesWindowObject;
 
-#define PyCursesWindow_Check(v)         (Py_TYPE(v) == &PyCursesWindow_Type)
+#define PyCursesWindow_Check(v)  (Py_TYPE(v) == &PyCursesWindow_Type)
 
 #define PyCurses_CAPSULE_NAME "_curses._C_API"
 
index 10b5bea5eb892914c9d2b647ddbb8a06d5585c88..2c239df590d7a5dd3dd5393977da25f68538c148 100644 (file)
@@ -72,9 +72,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
 /* Returns NULL to indicate error if a negative size or size larger than
    Py_ssize_t can represent is supplied.  Helps prevents security holes. */
 #define PyMem_MALLOC(n)                ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
-                               : malloc((n) ? (n) : 1))
+                               : malloc(((n) != 0) ? (n) : 1))
 #define PyMem_REALLOC(p, n)    ((size_t)(n) > (size_t)PY_SSIZE_T_MAX  ? NULL \
-                               : realloc((p), (n) ? (n) : 1))
+                               : realloc((p), ((n) != 0) ? (n) : 1))
 #define PyMem_FREE             free
 
 #endif /* PYMALLOC_DEBUG */
diff --git a/LICENSE b/LICENSE
index 529349e4b38c0500290a8ff5513d3cd5336fdb85..1afbedba92b33c6b418c343f7b4c6948318eb197 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -73,9 +73,9 @@ analyze, test, perform and/or display publicly, prepare derivative works,
 distribute, and otherwise use Python alone or in any derivative version,
 provided, however, that PSF's License Agreement and PSF's notice of copyright,
 i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-2011, 2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation; All Rights
-Reserved" are retained in Python alone or in any derivative version prepared by
-Licensee.
+2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Python Software Foundation; All
+Rights Reserved" are retained in Python alone or in any derivative version
+prepared by Licensee.
 
 3. In the event Licensee prepares a derivative work that is based on
 or incorporates Python or any part thereof, and wants to make
index 09a3515bdb92b40b1e43caa0cca25f0da5981aae..1480329fde8b1ef19169e0c52c429f592fd01b60 100644 (file)
@@ -57,11 +57,7 @@ You can create custom local objects by subclassing the local class:
 
   >>> class MyLocal(local):
   ...     number = 2
-  ...     initialized = False
   ...     def __init__(self, **kw):
-  ...         if self.initialized:
-  ...             raise SystemError('__init__ called too many times')
-  ...         self.initialized = True
   ...         self.__dict__.update(kw)
   ...     def squared(self):
   ...         return self.number ** 2
@@ -98,7 +94,7 @@ As before, we can access the data in a separate thread:
   >>> thread.start()
   >>> thread.join()
   >>> log
-  [[('color', 'red'), ('initialized', True)], 11]
+  [[('color', 'red')], 11]
 
 without affecting this thread's data:
 
index e6783277a471c1adcb50a3c5515743076c7fc842..981f8010690e00e75f1b4605f456edf41d32527a 100644 (file)
@@ -308,6 +308,7 @@ class Aifc_read:
         else:
             raise Error, 'not an AIFF or AIFF-C file'
         self._comm_chunk_read = 0
+        self._ssnd_chunk = None
         while 1:
             self._ssnd_seek_needed = 1
             try:
index 590238ec502bfb6466e85b9177e6c31bd51ce1cb..e120d636bcb28bf5410c6e4f192e1ecaf89237f5 100644 (file)
@@ -472,15 +472,17 @@ class StreamReader(Codec):
             self.charbuffer = "".join(self.linebuffer)
             self.linebuffer = None
 
+        if chars < 0:
+            # For compatibility with other read() methods that take a
+            # single argument
+            chars = size
+
         # read until we get the required number of characters (if available)
         while True:
             # can the request be satisfied from the character buffer?
             if chars >= 0:
                 if len(self.charbuffer) >= chars:
                     break
-            elif size >= 0:
-                if len(self.charbuffer) >= size:
-                    break
             # we need more data
             if size < 0:
                 newdata = self.stream.read()
index c155ada794a606f26fb105d8227d100bbd986e1a..70c53ae7791e34a33ea1b276d4d9741d187d8a12 100644 (file)
@@ -217,7 +217,7 @@ class Sniffer:
         matches = []
         for restr in ('(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)', # ,".*?",
                       '(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?P<delim>[^\w\n"\'])(?P<space> ?)',   #  ".*?",
-                      '(?P<delim>>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?:$|\n)',  # ,".*?"
+                      '(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?:$|\n)',   # ,".*?"
                       '(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?:$|\n)'):                            #  ".*?" (no delim, no space)
             regexp = re.compile(restr, re.DOTALL | re.MULTILINE)
             matches = regexp.findall(data)
index d892b59898589fc8981c8cba7fc34e31683770ca..2c28b7f44ae8bb637439963ac96a7a72cf20f041 100644 (file)
@@ -1,4 +1,5 @@
 import unittest
+from test.support import cpython_only
 from ctypes import *
 
 class AnonTest(unittest.TestCase):
@@ -35,6 +36,18 @@ class AnonTest(unittest.TestCase):
                                                       {"_fields_": [],
                                                        "_anonymous_": ["x"]}))
 
+    @cpython_only
+    def test_issue31490(self):
+        # There shouldn't be an assertion failure in case the class has an
+        # attribute whose name is specified in _anonymous_ but not in _fields_.
+
+        # AttributeError: 'x' is specified in _anonymous_ but not in _fields_
+        with self.assertRaises(AttributeError):
+            class Name(Structure):
+                _fields_ = []
+                _anonymous_ = ["x"]
+                x = 42
+
     def test_nested(self):
         class ANON_S(Structure):
             _fields_ = [("a", c_int)]
index d708ed6906fe435b7690fc53a254af8e8f513ddd..99c32e095b8d37cc8240efe0256c13047656a32e 100644 (file)
@@ -78,12 +78,21 @@ class Test(unittest.TestCase):
                           (c_int * 1).from_buffer_copy, a, 16 * sizeof(c_int))
 
     def test_abstract(self):
+        from ctypes import _Pointer, _SimpleCData, _CFuncPtr
+
         self.assertRaises(TypeError, Array.from_buffer, bytearray(10))
         self.assertRaises(TypeError, Structure.from_buffer, bytearray(10))
         self.assertRaises(TypeError, Union.from_buffer, bytearray(10))
+        self.assertRaises(TypeError, _CFuncPtr.from_buffer, bytearray(10))
+        self.assertRaises(TypeError, _Pointer.from_buffer, bytearray(10))
+        self.assertRaises(TypeError, _SimpleCData.from_buffer, bytearray(10))
+
         self.assertRaises(TypeError, Array.from_buffer_copy, b"123")
         self.assertRaises(TypeError, Structure.from_buffer_copy, b"123")
         self.assertRaises(TypeError, Union.from_buffer_copy, b"123")
+        self.assertRaises(TypeError, _CFuncPtr.from_buffer_copy, b"123")
+        self.assertRaises(TypeError, _Pointer.from_buffer_copy, b"123")
+        self.assertRaises(TypeError, _SimpleCData.from_buffer_copy, b"123")
 
 if __name__ == '__main__':
     unittest.main()
index 58cbb47af49085902cfc5311e3a2ad1721672aa4..575030327e0a68d82fa07cf447169696137fba16 100644 (file)
@@ -123,5 +123,10 @@ class CFuncPtrTestCase(unittest.TestCase):
         self.assertEqual(strtok(None, "\n"), "c")
         self.assertEqual(strtok(None, "\n"), None)
 
+    def test_abstract(self):
+        from ctypes import _CFuncPtr
+
+        self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
+
 if __name__ == '__main__':
     unittest.main()
index 192d9ed4acfacc782e46bae7191a2554b95a469f..23c1b6e2259efe7087f2f31b0c0eb1229b936028 100644 (file)
@@ -1,5 +1,6 @@
 import unittest, sys
 from ctypes.test import need_symbol
+import test.support
 
 class SimpleTypesTestCase(unittest.TestCase):
 
@@ -174,6 +175,36 @@ class SimpleTypesTestCase(unittest.TestCase):
         # ArgumentError: argument 1: ValueError: 99
         self.assertRaises(ArgumentError, func, 99)
 
+    def test_abstract(self):
+        from ctypes import (Array, Structure, Union, _Pointer,
+                            _SimpleCData, _CFuncPtr)
+
+        self.assertRaises(TypeError, Array.from_param, 42)
+        self.assertRaises(TypeError, Structure.from_param, 42)
+        self.assertRaises(TypeError, Union.from_param, 42)
+        self.assertRaises(TypeError, _CFuncPtr.from_param, 42)
+        self.assertRaises(TypeError, _Pointer.from_param, 42)
+        self.assertRaises(TypeError, _SimpleCData.from_param, 42)
+
+    @test.support.cpython_only
+    def test_issue31311(self):
+        # __setstate__ should neither raise a SystemError nor crash in case
+        # of a bad __dict__.
+        from ctypes import Structure
+
+        class BadStruct(Structure):
+            @property
+            def __dict__(self):
+                pass
+        with self.assertRaises(TypeError):
+            BadStruct().__setstate__({}, b'foo')
+
+        class WorseStruct(Structure):
+            @property
+            def __dict__(self):
+                1/0.0
+        with self.assertRaises(ZeroDivisionError):
+            WorseStruct().__setstate__({}, b'foo')
 
 ################################################################
 
index 3e007e1b41d5b6beb34499eaeae1f578161a6df7..49a1356a2c4424088e2e8bdf11bb402d37ffc2a5 100644 (file)
@@ -109,6 +109,34 @@ Complete._fields_ = [("a", c_long)]
 # This table contains format strings as they look on little endian
 # machines.  The test replaces '<' with '>' on big endian machines.
 #
+
+# Platform-specific type codes
+s_bool = {1: '?', 2: 'H', 4: 'L', 8: 'Q'}[sizeof(c_bool)]
+s_short = {2: 'h', 4: 'l', 8: 'q'}[sizeof(c_short)]
+s_ushort = {2: 'H', 4: 'L', 8: 'Q'}[sizeof(c_ushort)]
+s_int = {2: 'h', 4: 'i', 8: 'q'}[sizeof(c_int)]
+s_uint = {2: 'H', 4: 'I', 8: 'Q'}[sizeof(c_uint)]
+s_long = {4: 'l', 8: 'q'}[sizeof(c_long)]
+s_ulong = {4: 'L', 8: 'Q'}[sizeof(c_ulong)]
+s_longlong = "q"
+s_ulonglong = "Q"
+s_float = "f"
+s_double = "d"
+s_longdouble = "g"
+
+# Alias definitions in ctypes/__init__.py
+if c_int is c_long:
+    s_int = s_long
+if c_uint is c_ulong:
+    s_uint = s_ulong
+if c_longlong is c_long:
+    s_longlong = s_long
+if c_ulonglong is c_ulong:
+    s_ulonglong = s_ulong
+if c_longdouble is c_double:
+    s_longdouble = s_double
+
+
 native_types = [
     # type                      format                  shape           calc itemsize
 
@@ -117,52 +145,51 @@ native_types = [
     (c_char,                    "<c",                   None,           c_char),
     (c_byte,                    "<b",                   None,           c_byte),
     (c_ubyte,                   "<B",                   None,           c_ubyte),
-    (c_short,                   "<h",                   None,           c_short),
-    (c_ushort,                  "<H",                   None,           c_ushort),
+    (c_short,                   "<" + s_short,          None,           c_short),
+    (c_ushort,                  "<" + s_ushort,         None,           c_ushort),
 
-    # c_int and c_uint may be aliases to c_long
-    #(c_int,                     "<i",                   None,           c_int),
-    #(c_uint,                    "<I",                   None,           c_uint),
+    (c_int,                     "<" + s_int,            None,           c_int),
+    (c_uint,                    "<" + s_uint,           None,           c_uint),
 
-    (c_long,                    "<l",                   None,           c_long),
-    (c_ulong,                   "<L",                   None,           c_ulong),
+    (c_long,                    "<" + s_long,           None,           c_long),
+    (c_ulong,                   "<" + s_ulong,          None,           c_ulong),
 
-    # c_longlong and c_ulonglong are aliases on 64-bit platforms
-    #(c_longlong,                "<q",                   None,           c_longlong),
-    #(c_ulonglong,               "<Q",                   None,           c_ulonglong),
+    (c_longlong,                "<" + s_longlong,       None,           c_longlong),
+    (c_ulonglong,               "<" + s_ulonglong,      None,           c_ulonglong),
 
     (c_float,                   "<f",                   None,           c_float),
     (c_double,                  "<d",                   None,           c_double),
-    # c_longdouble may be an alias to c_double
 
-    (c_bool,                    "<?",                   None,           c_bool),
+    (c_longdouble,              "<" + s_longdouble,     None,           c_longdouble),
+
+    (c_bool,                    "<" + s_bool,           None,           c_bool),
     (py_object,                 "<O",                   None,           py_object),
 
     ## pointers
 
     (POINTER(c_byte),           "&<b",                  None,           POINTER(c_byte)),
-    (POINTER(POINTER(c_long)),  "&&<l",                 None,           POINTER(POINTER(c_long))),
+    (POINTER(POINTER(c_long)),  "&&<" + s_long,         None,           POINTER(POINTER(c_long))),
 
     ## arrays and pointers
 
     (c_double * 4,              "<d",                   (4,),           c_double),
     (c_float * 4 * 3 * 2,       "<f",                   (2,3,4),        c_float),
-    (POINTER(c_short) * 2,      "&<h",                  (2,),           POINTER(c_short)),
-    (POINTER(c_short) * 2 * 3,  "&<h",                  (3,2,),         POINTER(c_short)),
-    (POINTER(c_short * 2),      "&(2)<h",               None,           POINTER(c_short)),
+    (POINTER(c_short) * 2,      "&<" + s_short,         (2,),           POINTER(c_short)),
+    (POINTER(c_short) * 2 * 3,  "&<" + s_short,         (3,2,),         POINTER(c_short)),
+    (POINTER(c_short * 2),      "&(2)<" + s_short,      None,             POINTER(c_short)),
 
     ## structures and unions
 
-    (Point,                     "T{<l:x:<l:y:}",        None,           Point),
+    (Point,                     "T{<l:x:<l:y:}".replace('l', s_long),  None,  Point),
     # packed structures do not implement the pep
-    (PackedPoint,               "B",                    None,           PackedPoint),
-    (Point2,                    "T{<l:x:<l:y:}",        None,           Point2),
-    (EmptyStruct,               "T{}",                  None,           EmptyStruct),
+    (PackedPoint,               "B",                                   None,  PackedPoint),
+    (Point2,                    "T{<l:x:<l:y:}".replace('l', s_long),  None,  Point2),
+    (EmptyStruct,               "T{}",                                 None,  EmptyStruct),
     # the pep does't support unions
-    (aUnion,                    "B",                    None,           aUnion),
+    (aUnion,                    "B",                                   None,  aUnion),
     # structure with sub-arrays
-    (StructWithArrays,          "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}", None,  StructWithArrays),
-    (StructWithArrays * 3,      "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}", (3,),  StructWithArrays),
+    (StructWithArrays, "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}".replace('l', s_long), None, StructWithArrays),
+    (StructWithArrays * 3, "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}".replace('l', s_long), (3,), StructWithArrays),
 
     ## pointer to incomplete structure
     (Incomplete,                "B",                    None,           Incomplete),
@@ -170,7 +197,7 @@ native_types = [
 
     # 'Complete' is a structure that starts incomplete, but is completed after the
     # pointer type to it has been created.
-    (Complete,                  "T{<l:a:}",             None,           Complete),
+    (Complete,                  "T{<l:a:}".replace('l', s_long), None, Complete),
     # Unfortunately the pointer format string is not fixed...
     (POINTER(Complete),         "&B",                   None,           POINTER(Complete)),
 
@@ -193,10 +220,10 @@ class LEPoint(LittleEndianStructure):
 # and little endian machines.
 #
 endian_types = [
-    (BEPoint,                   "T{>l:x:>l:y:}",        None,           BEPoint),
-    (LEPoint,                   "T{<l:x:<l:y:}",        None,           LEPoint),
-    (POINTER(BEPoint),          "&T{>l:x:>l:y:}",       None,           POINTER(BEPoint)),
-    (POINTER(LEPoint),          "&T{<l:x:<l:y:}",       None,           POINTER(LEPoint)),
+    (BEPoint, "T{>l:x:>l:y:}".replace('l', s_long), None, BEPoint),
+    (LEPoint, "T{<l:x:<l:y:}".replace('l', s_long), None, LEPoint),
+    (POINTER(BEPoint), "&T{>l:x:>l:y:}".replace('l', s_long), None, POINTER(BEPoint)),
+    (POINTER(LEPoint), "&T{<l:x:<l:y:}".replace('l', s_long), None, POINTER(LEPoint)),
     ]
 
 if __name__ == "__main__":
index 24b0546c89bf747f07f52d385038b3d9e46adcb1..4a8887c1dee60ef3bd8c010e251ed967c903cd9c 100644 (file)
@@ -210,6 +210,11 @@ class PointersTestCase(unittest.TestCase):
         from ctypes import _pointer_type_cache
         del _pointer_type_cache[id(P)]
 
+    def test_abstract(self):
+        from ctypes import _Pointer
+
+        self.assertRaises(TypeError, _Pointer.set_type, 42)
+
 
 if __name__ == '__main__':
     unittest.main()
index 22eb3b0cd7b8b9171ee20b3fc79bc59a930cfb20..8045cc82679cc1e10c2a4a0723f6da64ea9abd7d 100644 (file)
@@ -46,5 +46,29 @@ class StructFieldsTestCase(unittest.TestCase):
         Y._fields_ = []
         self.assertRaises(AttributeError, setattr, X, "_fields_", [])
 
+    # __set__ and __get__ should raise a TypeError in case their self
+    # argument is not a ctype instance.
+    def test___set__(self):
+        class MyCStruct(Structure):
+            _fields_ = (("field", c_int),)
+        self.assertRaises(TypeError,
+                          MyCStruct.field.__set__, 'wrong type self', 42)
+
+        class MyCUnion(Union):
+            _fields_ = (("field", c_int),)
+        self.assertRaises(TypeError,
+                          MyCUnion.field.__set__, 'wrong type self', 42)
+
+    def test___get__(self):
+        class MyCStruct(Structure):
+            _fields_ = (("field", c_int),)
+        self.assertRaises(TypeError,
+                          MyCStruct.field.__get__, 'wrong type self', 42)
+
+        class MyCUnion(Union):
+            _fields_ = (("field", c_int),)
+        self.assertRaises(TypeError,
+                          MyCUnion.field.__get__, 'wrong type self', 42)
+
 if __name__ == "__main__":
     unittest.main()
index 1c6fbdbedcb7dc1d74d8bfb99d0971d2175321a1..788a92df3f89af589da0a38a9d53535e7bae2bab 100644 (file)
@@ -1103,7 +1103,7 @@ class Differ:
 
 import re
 
-def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match):
+def IS_LINE_JUNK(line, pat=re.compile(r"\s*(?:#\s*)?$").match):
     r"""
     Return 1 for ignorable line: iff `line` is blank or contains a single '#'.
 
index 62506a6e6ff8246d1a9a0146af0c953db51015f5..88a910c6810ffd5817bfa93136a81febcef486ee 100644 (file)
@@ -160,7 +160,7 @@ class CCompiler:
             self.set_executable(key, args[key])
 
     def set_executable(self, key, value):
-        if isinstance(value, str):
+        if isinstance(value, basestring):
             setattr(self, key, split_quoted(value))
         else:
             setattr(self, key, value)
index b773f47f76845252a9343c2cfc37a6d70d404b2e..ff043d2e125223fcdfc1ecdb7165c84f8cae4efe 100644 (file)
@@ -55,7 +55,9 @@ class upload(PyPIRCCommand):
 
     def run(self):
         if not self.distribution.dist_files:
-            raise DistutilsOptionError("No dist file created in earlier command")
+            msg = ("Must create and upload files in one command "
+                   "(e.g. setup.py sdist upload)")
+            raise DistutilsOptionError(msg)
         for command, pyversion, filename in self.distribution.dist_files:
             self.upload_file(command, pyversion, filename)
 
@@ -155,8 +157,6 @@ class upload(PyPIRCCommand):
                 body.write(fn)
                 body.write("\r\n\r\n")
                 body.write(value)
-                if value and value[-1] == '\r':
-                    body.write('\n')  # write an extra newline (lurve Macs)
         body.write(end_boundary)
         body = body.getvalue()
 
index 446eac2cda4e2078a9415552e8ec609c5196628e..4976098b8d8027332149f4b449f6ec46d03e4bb5 100644 (file)
@@ -24,6 +24,30 @@ class FakeCompiler(object):
 
 class CCompilerTestCase(support.EnvironGuard, unittest.TestCase):
 
+    def test_set_executables(self):
+        class MyCCompiler(CCompiler):
+            executables = {'compiler': '', 'compiler_cxx': '', 'linker': ''}
+
+        compiler = MyCCompiler()
+
+        # set executable as list
+        compiler.set_executables(compiler=['env', 'OMPI_MPICC=clang', 'mpicc'])
+        self.assertEqual(compiler.compiler, ['env',
+                                             'OMPI_MPICC=clang',
+                                             'mpicc'])
+
+        # set executable as string
+        compiler.set_executables(compiler_cxx='env OMPI_MPICXX=clang++ mpicxx')
+        self.assertEqual(compiler.compiler_cxx, ['env',
+                                                 'OMPI_MPICXX=clang++',
+                                                 'mpicxx'])
+
+        # set executable as unicode string
+        compiler.set_executables(linker=u'env OMPI_MPICXX=clang++ mpiCC')
+        self.assertEqual(compiler.linker, [u'env',
+                                           u'OMPI_MPICXX=clang++',
+                                           u'mpiCC'])
+
     def test_gen_lib_options(self):
         compiler = FakeCompiler()
         libdirs = ['lib1', 'lib2']
index 3d4f30504e8d285c99a3827fdcc666a8b19a4ef5..d2257545875304d9367431873e61b68ca951e512 100644 (file)
@@ -128,6 +128,32 @@ class uploadTestCase(PyPIRCCommandTestCase):
         auth = self.last_open.req.headers['Authorization']
         self.assertNotIn('\n', auth)
 
+    # bpo-32304: archives whose last byte was b'\r' were corrupted due to
+    # normalization intended for Mac OS 9.
+    def test_upload_correct_cr(self):
+        # content that ends with \r should not be modified.
+        tmp = self.mkdtemp()
+        path = os.path.join(tmp, 'xxx')
+        self.write_file(path, content='yy\r')
+        command, pyversion, filename = 'xxx', '2.6', path
+        dist_files = [(command, pyversion, filename)]
+        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
+
+        # other fields that ended with \r used to be modified, now are
+        # preserved.
+        pkg_dir, dist = self.create_dist(
+            dist_files=dist_files,
+            description='long description\r'
+        )
+        cmd = upload(dist)
+        cmd.ensure_finalized()
+        cmd.run()
+
+        headers = dict(self.last_open.req.headers)
+        self.assertEqual(headers['Content-length'], '2170')
+        self.assertIn(b'long description\r', self.last_open.req.data)
+        self.assertNotIn(b'long description\r\n', self.last_open.req.data)
+
     def test_upload_fails(self):
         self.next_msg = "Not Found"
         self.next_code = 404
index ac13f49d599df9b63c7ca5a205eea5491b14d7cb..5b22521e5814dae163c3e15acb70dd511b8074ec 100644 (file)
@@ -211,6 +211,12 @@ def parsedate_tz(data):
 
 
 def parseaddr(addr):
+    """
+    Parse addr into its constituent realname and email address parts.
+
+    Return a tuple of realname and email address, unless the parse fails, in
+    which case return a 2-tuple of ('', '').
+    """
     addrs = _AddressList(addr).addresslist
     if not addrs:
         return '', ''
index c2abed84ef0c5d917779512f1df31d59dd5808a3..89ed1efdaf2bee5578ecf0d342ab9777014e8bb8 100644 (file)
@@ -12,9 +12,9 @@ import tempfile
 __all__ = ["version", "bootstrap"]
 
 
-_SETUPTOOLS_VERSION = "28.8.0"
+_SETUPTOOLS_VERSION = "39.0.1"
 
-_PIP_VERSION = "9.0.1"
+_PIP_VERSION = "9.0.3"
 
 _PROJECTS = [
     ("setuptools", _SETUPTOOLS_VERSION),
@@ -29,7 +29,7 @@ def _run_pip(args, additional_paths=None):
 
     # Install the bundled software
     import pip
-    pip.main(args)
+    return pip.main(args)
 
 
 def version():
@@ -58,6 +58,21 @@ def bootstrap(root=None, upgrade=False, user=False,
     Bootstrap pip into the current Python installation (or the given root
     directory).
 
+    Note that calling this function will alter both sys.path and os.environ.
+    """
+    # Discard the return value
+    _bootstrap(root=root, upgrade=upgrade, user=user,
+               altinstall=altinstall, default_pip=default_pip,
+               verbosity=verbosity)
+
+
+def _bootstrap(root=None, upgrade=False, user=False,
+               altinstall=False, default_pip=True,
+               verbosity=0):
+    """
+    Bootstrap pip into the current Python installation (or the given root
+    directory). Returns pip command status code.
+
     Note that calling this function will alter both sys.path and os.environ.
     """
     if altinstall and default_pip:
@@ -105,11 +120,10 @@ def bootstrap(root=None, upgrade=False, user=False,
         if verbosity:
             args += ["-" + "v" * verbosity]
 
-        _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
+        return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
     finally:
         shutil.rmtree(tmpdir, ignore_errors=True)
 
-
 def _uninstall_helper(verbosity=0):
     """Helper to support a clean default uninstall process on Windows
 
@@ -135,7 +149,7 @@ def _uninstall_helper(verbosity=0):
     if verbosity:
         args += ["-" + "v" * verbosity]
 
-    _run_pip(args + [p[0] for p in reversed(_PROJECTS)])
+    return _run_pip(args + [p[0] for p in reversed(_PROJECTS)])
 
 
 def _main(argv=None):
@@ -196,7 +210,7 @@ def _main(argv=None):
 
     args = parser.parse_args(argv)
 
-    bootstrap(
+    return _bootstrap(
         root=args.root,
         upgrade=args.upgrade,
         user=args.user,
index 77527d7a3513596852d1eb0ff8d8935a98e0cc26..03eef0dd94d0b77764cbd737f69945d04e4b1bc6 100644 (file)
@@ -1,4 +1,5 @@
 import ensurepip
+import sys
 
 if __name__ == "__main__":
-    ensurepip._main()
+    sys.exit(ensurepip._main())
diff --git a/Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl
deleted file mode 100644 (file)
index 4b8ecc6..0000000
Binary files a/Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl and /dev/null 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
new file mode 100644 (file)
index 0000000..5d33bba
Binary files /dev/null and b/Lib/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl differ
diff --git a/Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl
deleted file mode 100644 (file)
index 502e3cb..0000000
Binary files a/Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl and /dev/null differ
diff --git a/Lib/ensurepip/_bundled/setuptools-39.0.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-39.0.1-py2.py3-none-any.whl
new file mode 100644 (file)
index 0000000..edc3ca2
Binary files /dev/null and b/Lib/ensurepip/_bundled/setuptools-39.0.1-py2.py3-none-any.whl differ
index 750365ec4d04da980399c94c35668935482b9cce..b257904328d2f5dc3b5f07e7d6c883fb9e2055a9 100644 (file)
@@ -2,6 +2,7 @@
 
 import argparse
 import ensurepip
+import sys
 
 
 def _main(argv=None):
@@ -23,8 +24,8 @@ def _main(argv=None):
 
     args = parser.parse_args(argv)
 
-    ensurepip._uninstall_helper(verbosity=args.verbosity)
+    return ensurepip._uninstall_helper(verbosity=args.verbosity)
 
 
 if __name__ == "__main__":
-    _main()
+    sys.exit(_main())
index 71cbb25f3c8b9eb861415eca88358aeb049202ff..0537a27b88207cb815d844a5763f6abbbe483f00 100644 (file)
@@ -19,7 +19,7 @@ import re
 __all__ = ["fix","sci","NotANumber"]
 
 # Compiled regular expression to "decode" a number
-decoder = re.compile(r'^([-+]?)0*(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$')
+decoder = re.compile(r'^([-+]?)(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$')
 # \0 the whole thing
 # \1 leading sign or empty
 # \2 digits left of decimal point
@@ -41,6 +41,7 @@ def extract(s):
     res = decoder.match(s)
     if res is None: raise NotANumber, s
     sign, intpart, fraction, exppart = res.group(1,2,3,4)
+    intpart = intpart.lstrip('0');
     if sign == '+': sign = ''
     if fraction: fraction = fraction[1:]
     if exppart: expo = int(exppart[1:])
index 53680b894660774d5c460c0198221d9444d23923..5d755d4726274f3b2ac81d7753c808c47371da9d 100644 (file)
@@ -55,23 +55,28 @@ def total_ordering(cls):
     convert = {
         '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
                    ('__le__', lambda self, other: self < other or self == other),
+                   ('__ne__', lambda self, other: not self == other),
                    ('__ge__', lambda self, other: not self < other)],
         '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
                    ('__lt__', lambda self, other: self <= other and not self == other),
+                   ('__ne__', lambda self, other: not self == other),
                    ('__gt__', lambda self, other: not self <= other)],
         '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
                    ('__ge__', lambda self, other: self > other or self == other),
+                   ('__ne__', lambda self, other: not self == other),
                    ('__le__', lambda self, other: not self > other)],
         '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
                    ('__gt__', lambda self, other: self >= other and not self == other),
+                   ('__ne__', lambda self, other: not self == other),
                    ('__lt__', lambda self, other: not self >= other)]
     }
-    roots = set(dir(cls)) & set(convert)
+    defined_methods = set(dir(cls))
+    roots = defined_methods & set(convert)
     if not roots:
         raise ValueError('must define at least one ordering operation: < > <= >=')
     root = max(roots)       # prefer __lt__ to __le__ to __gt__ to __ge__
     for opname, opfunc in convert[root]:
-        if opname not in roots:
+        if opname not in defined_methods:
             opfunc.__name__ = opname
             opfunc.__doc__ = getattr(int, opname).__doc__
             setattr(cls, opname, opfunc)
index 6ff8401a0c77cfcd26609033662361c51f6e18c5..a6b7c38ddf67fc94ef20cd897ec6791aae3448bd 100644 (file)
@@ -3,7 +3,7 @@ from json.tests import CTest
 
 class BadBool:
     def __nonzero__(self):
-        1/0
+        1/0.0
 
 
 class TestSpeedups(CTest):
index 1c4c4f3f6e33de2c62dfec4cbdac45ed84f23488..1f60204d4a0a85938e847054f9e221a050c56a14 100644 (file)
@@ -88,7 +88,8 @@ class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
         widget = self.create()
         self.assertEqual(widget['use'], '')
         parent = self.create(container=True)
-        wid = hex(parent.winfo_id())
+        # hex() adds the 'L' suffix for longs
+        wid = '%#x' % parent.winfo_id()
         widget2 = self.create(use=wid)
         self.assertEqual(widget2['use'], wid)
 
index 57ffdddb7d8119fdc146b1bd73175ee0cb009bbf..70b2f9c6b12461fca815337c1e87623b29a69b0b 100644 (file)
@@ -284,6 +284,31 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
 
         optmenu.destroy()
 
+    def test_unique_radiobuttons(self):
+        # check that radiobuttons are unique across instances (bpo25684)
+        items = ('a', 'b', 'c')
+        default = 'a'
+        optmenu = ttk.OptionMenu(self.root, self.textvar, default, *items)
+        textvar2 = tkinter.StringVar(self.root)
+        optmenu2 = ttk.OptionMenu(self.root, textvar2, default, *items)
+        optmenu.pack()
+        optmenu.wait_visibility()
+        optmenu2.pack()
+        optmenu2.wait_visibility()
+        optmenu['menu'].invoke(1)
+        optmenu2['menu'].invoke(2)
+        optmenu_stringvar_name = optmenu['menu'].entrycget(0, 'variable')
+        optmenu2_stringvar_name = optmenu2['menu'].entrycget(0, 'variable')
+        self.assertNotEqual(optmenu_stringvar_name,
+                            optmenu2_stringvar_name)
+        self.assertEqual(self.root.tk.globalgetvar(optmenu_stringvar_name),
+                         items[1])
+        self.assertEqual(self.root.tk.globalgetvar(optmenu2_stringvar_name),
+                         items[2])
+
+        optmenu.destroy()
+        optmenu2.destroy()
+
 
 tests_gui = (LabeledScaleTest, OptionMenuTest)
 
index a84960d241aa89e052a578cb2a9aa1da777fe3d5..3d5683cc4f5f065261c9ff8ebe83fafbb2566de6 100644 (file)
@@ -1485,6 +1485,15 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
             self.tv.insert('', 'end', text=value), text=None),
             value)
 
+        # test for values which are not None
+        itemid = self.tv.insert('', 'end', 0)
+        self.assertEqual(itemid, '0')
+        itemid = self.tv.insert('', 'end', 0.0)
+        self.assertEqual(itemid, '0.0')
+        # this is because False resolves to 0 and element with 0 iid is already present
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', False)
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', '')
+
 
     def test_selection(self):
         # item 'none' doesn't exist
index 77c93b12ae753b461375bcd379daed6c71e58909..d4df408e477f66b903654213bb0a84b2e39378d7 100644 (file)
@@ -1332,7 +1332,7 @@ class Treeview(Widget, Tkinter.XView, Tkinter.YView):
         already exist in the tree. Otherwise, a new unique identifier
         is generated."""
         opts = _format_optdict(kw)
-        if iid:
+        if iid is not None:
             res = self.tk.call(self._w, "insert", parent, index,
                 "-id", iid, *opts)
         else:
@@ -1614,7 +1614,8 @@ class OptionMenu(Menubutton):
         menu.delete(0, 'end')
         for val in values:
             menu.add_radiobutton(label=val,
-                command=Tkinter._setit(self._variable, val, self._callback))
+                command=Tkinter._setit(self._variable, val, self._callback),
+                variable=self._variable)
 
         if default:
             self._variable.set(default)
index d31a9dad9a524eda3757d9a6e384e3045d73bb3d..49ed6680b6a70b2fa86b910b3b36e5181333006d 100644 (file)
@@ -11,7 +11,6 @@ The compiler compiles a pattern to a pytree.*Pattern instance.
 __author__ = "Guido van Rossum <guido@python.org>"
 
 # Python imports
-import os
 import StringIO
 
 # Fairly local imports
@@ -21,10 +20,6 @@ from .pgen2 import driver, literals, token, tokenize, parse, grammar
 from . import pytree
 from . import pygram
 
-# The pattern grammar file
-_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
-                                     "PatternGrammar.txt")
-
 
 class PatternSyntaxError(Exception):
     pass
@@ -42,13 +37,17 @@ def tokenize_wrapper(input):
 
 class PatternCompiler(object):
 
-    def __init__(self, grammar_file=_PATTERN_GRAMMAR_FILE):
+    def __init__(self, grammar_file=None):
         """Initializer.
 
         Takes an optional alternative filename for the pattern grammar.
         """
-        self.grammar = driver.load_grammar(grammar_file)
-        self.syms = pygram.Symbols(self.grammar)
+        if grammar_file is None:
+            self.grammar = pygram.pattern_grammar
+            self.syms = pygram.pattern_symbols
+        else:
+            self.grammar = driver.load_grammar(grammar_file)
+            self.syms = pygram.Symbols(self.grammar)
         self.pygrammar = pygram.python_grammar
         self.pysyms = pygram.python_symbols
         self.driver = driver.Driver(self.grammar, convert=pattern_convert)
index ce601bb04f9589619848b2fc035b5655b37626a1..a5133309c6c1eaa4afdc74e81eec76cde436561c 100644 (file)
@@ -19,6 +19,7 @@ __all__ = ["Driver", "load_grammar"]
 import codecs
 import os
 import logging
+import pkgutil
 import StringIO
 import sys
 
@@ -143,6 +144,26 @@ def _newer(a, b):
     return os.path.getmtime(a) >= os.path.getmtime(b)
 
 
+def load_packaged_grammar(package, grammar_source):
+    """Normally, loads a pickled grammar by doing
+        pkgutil.get_data(package, pickled_grammar)
+    where *pickled_grammar* is computed from *grammar_source* by adding the
+    Python version and using a ``.pickle`` extension.
+
+    However, if *grammar_source* is an extant file, load_grammar(grammar_source)
+    is called instead. This facilitates using a packaged grammar file when needed
+    but preserves load_grammar's automatic regeneration behavior when possible.
+
+    """
+    if os.path.isfile(grammar_source):
+        return load_grammar(grammar_source)
+    pickled_name = _generate_pickle_name(os.path.basename(grammar_source))
+    data = pkgutil.get_data(package, pickled_name)
+    g = grammar.Grammar()
+    g.loads(data)
+    return g
+
+
 def main(*args):
     """Main program, when run as a script: produce grammar pickle files.
 
index 75255e9c013827dd3b740eae4c883db01f12abdb..0b6d86b67997b43e239b746c566e9ab8b201616c 100644 (file)
@@ -109,6 +109,10 @@ class Grammar(object):
         f.close()
         self.__dict__.update(d)
 
+    def loads(self, pkl):
+        """Load the grammar tables from a pickle bytes object."""
+        self.__dict__.update(pickle.loads(pkl))
+
     def copy(self):
         """
         Copy the grammar.
index 621ff24c95471b967333f27c1055b8fd6ff2a4ba..7e67e4a8678841ef09c438a55b719dcfd2d7a70e 100644 (file)
@@ -29,12 +29,12 @@ class Symbols(object):
             setattr(self, name, symbol)
 
 
-python_grammar = driver.load_grammar(_GRAMMAR_FILE)
+python_grammar = driver.load_packaged_grammar("lib2to3", _GRAMMAR_FILE)
 
 python_symbols = Symbols(python_grammar)
 
 python_grammar_no_print_statement = python_grammar.copy()
 del python_grammar_no_print_statement.keywords["print"]
 
-pattern_grammar = driver.load_grammar(_PATTERN_GRAMMAR_FILE)
+pattern_grammar = driver.load_packaged_grammar("lib2to3", _PATTERN_GRAMMAR_FILE)
 pattern_symbols = Symbols(pattern_grammar)
index ebf84418fe60348a53464b5331ff1c903b432848..d2254f13e09e6ac00057ec1a917accd1871a5845 100644 (file)
@@ -11,11 +11,14 @@ from . import support
 from .support import driver, test_dir
 
 # Python imports
+import operator
 import os
+import pickle
 import shutil
 import subprocess
 import sys
 import tempfile
+import types
 import unittest
 
 # Local imports
@@ -97,6 +100,18 @@ pgen2_driver.load_grammar(%r, save=True, force=True)
         finally:
             shutil.rmtree(tmpdir)
 
+    def test_load_packaged_grammar(self):
+        modname = __name__ + '.load_test'
+        class MyLoader:
+            def get_data(self, where):
+                return pickle.dumps({'elephant': 19})
+        class MyModule(types.ModuleType):
+            __file__ = 'parsertestmodule'
+            __loader__ = MyLoader()
+        sys.modules[modname] = MyModule(modname)
+        self.addCleanup(operator.delitem, sys.modules, modname)
+        g = pgen2_driver.load_packaged_grammar(modname, 'Grammar.txt')
+        self.assertEqual(g.elephant, 19)
 
 
 class GrammarTest(support.TestCase):
index 22205825f3f38a12b02431e9b1986596742df431..cc24b309009300bd2f386f1d877c3700330c25dc 100644 (file)
@@ -636,12 +636,19 @@ def _removeHandlerRef(wr):
     # to prevent race conditions and failures during interpreter shutdown.
     acquire, release, handlers = _acquireLock, _releaseLock, _handlerList
     if acquire and release and handlers:
-        acquire()
         try:
-            if wr in handlers:
-                handlers.remove(wr)
-        finally:
-            release()
+            acquire()
+            try:
+                if wr in handlers:
+                    handlers.remove(wr)
+            finally:
+                release()
+        except TypeError:
+            # https://bugs.python.org/issue21149 - If the RLock object behind
+            # acquire() and release() has been partially finalized you may see
+            # an error about NoneType not being callable.  Absolutely nothing
+            # we can do in this GC during process shutdown situation.  Eat it.
+            pass
 
 def _addHandlerRef(handler):
     """
index 157d455521d1874e251e5f445599ba26afb23cbb..caecc11c37cb4c0c05437b867e167ecacf663e4e 100644 (file)
@@ -442,6 +442,7 @@ def _default_mime_types():
         '.jpeg'   : 'image/jpeg',
         '.jpg'    : 'image/jpeg',
         '.js'     : 'application/javascript',
+        '.json'   : 'application/json',
         '.ksh'    : 'text/plain',
         '.latex'  : 'application/x-latex',
         '.m1v'    : 'video/mpeg',
index 4b18973d51e344958d62d9125379fcb53cf20af5..16bc347023a84773e598cf4833b936be78a901df 100644 (file)
@@ -130,15 +130,15 @@ class netrc:
         rep = ""
         for host in self.hosts.keys():
             attrs = self.hosts[host]
-            rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n"
+            rep += "machine {host}\n\tlogin {attrs[0]}\n".format(host=host, attrs=attrs)
             if attrs[1]:
-                rep = rep + "account " + repr(attrs[1])
-            rep = rep + "\tpassword " + repr(attrs[2]) + "\n"
+                rep += "\taccount {attrs[1]}\n".format(attrs=attrs)
+            rep += "\tpassword {attrs[2]}\n".format(attrs=attrs)
         for macro in self.macros.keys():
-            rep = rep + "macdef " + macro + "\n"
+            rep += "macdef {macro}\n".format(macro=macro)
             for line in self.macros[macro]:
-                rep = rep + line
-            rep = rep + "\n"
+                rep += line
+            rep += "\n"
         return rep
 
 if __name__ == '__main__':
index ce072ec9ef75dcc1eede38e8dc870ae4aac417fe..68ca72b0e40fd718982886962a3c36f1d1d0adc1 100644 (file)
@@ -1,8 +1,5 @@
 """Utilities to support packages."""
 
-# NOTE: This module must remain compatible with Python 2.3, as it is shared
-# by setuptools for distribution with Python 2.3 and up.
-
 import os
 import sys
 import imp
@@ -252,7 +249,8 @@ class ImpLoader:
         return mod
 
     def get_data(self, pathname):
-        return open(pathname, "rb").read()
+        with open(pathname, "rb") as file:
+            return file.read()
 
     def _reopen(self):
         if self.file and self.file.closed:
index b91e5f72d2ca26f718eecdcd0385457f5f5055eb..a238510b38fc6a2ddc120d390ce41d6d1caeeb8c 100644 (file)
@@ -274,7 +274,7 @@ class POP3:
         return self._shortcmd('RPOP %s' % user)
 
 
-    timestamp = re.compile(r'\+OK.*(<[^>]+>)')
+    timestamp = re.compile(br'\+OK.[^<]*(<.*>)')
 
     def apop(self, user, secret):
         """Authorisation
index 36fec59f1131d857e7a9253c1f1364aae53465b8..7eeac324d272b989a31a1738b3ab25d40852238c 100644 (file)
@@ -24,6 +24,8 @@
 import datetime
 import unittest
 import sqlite3 as sqlite
+import weakref
+from test import support
 
 class RegressionTests(unittest.TestCase):
     def setUp(self):
@@ -175,6 +177,9 @@ class RegressionTests(unittest.TestCase):
             pass
         except:
             self.fail("should have raised ProgrammingError")
+        with self.assertRaisesRegexp(sqlite.ProgrammingError,
+                                     r'^Base Cursor\.__init__ not called\.$'):
+            cur.close()
 
     def CheckConnectionConstructorCallCheck(self):
         """
@@ -358,6 +363,22 @@ class RegressionTests(unittest.TestCase):
             counter += 1
         self.assertEqual(counter, 3, "should have returned exactly three rows")
 
+    def CheckBpo31770(self):
+        """
+        The interpreter shouldn't crash in case Cursor.__init__() is called
+        more than once.
+        """
+        def callback(*args):
+            pass
+        con = sqlite.connect(":memory:")
+        cur = sqlite.Cursor(con)
+        ref = weakref.ref(cur, callback)
+        cur.__init__(con)
+        del cur
+        # The interpreter shouldn't crash when ref is collected.
+        del ref
+        support.gc_collect()
+
 
 def suite():
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
index f28c863811fd9810988d107a9f24a3c8678aa284..22d478b56871b48fd5fdd17136bfb1faec1ebdec 100644 (file)
@@ -123,7 +123,7 @@ _import_symbols('SSL_ERROR_')
 _import_symbols('PROTOCOL_')
 _import_symbols('VERIFY_')
 
-from _ssl import HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN
+from _ssl import HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_TLSv1_3
 
 from _ssl import _OPENSSL_API_VERSION
 
@@ -157,6 +157,7 @@ else:
 # (OpenSSL's default setting is 'DEFAULT:!aNULL:!eNULL')
 # Enable a better set of ciphers by default
 # This list has been explicitly chosen to:
+#   * TLS 1.3 ChaCha20 and AES-GCM cipher suites
 #   * Prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE)
 #   * Prefer ECDHE over DHE for better performance
 #   * Prefer AEAD over CBC for better performance and security
@@ -168,6 +169,8 @@ else:
 #   * Disable NULL authentication, NULL encryption, 3DES and MD5 MACs
 #     for security reasons
 _DEFAULT_CIPHERS = (
+    'TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:'
+    'TLS13-AES-128-GCM-SHA256:'
     'ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:DH+CHACHA20:ECDH+AES256:DH+AES256:'
     'ECDH+AES128:DH+AES:ECDH+HIGH:DH+HIGH:RSA+AESGCM:RSA+AES:RSA+HIGH:'
     '!aNULL:!eNULL:!MD5:!3DES'
@@ -175,6 +178,7 @@ _DEFAULT_CIPHERS = (
 
 # Restricted and more secure ciphers for the server side
 # This list has been explicitly chosen to:
+#   * TLS 1.3 ChaCha20 and AES-GCM cipher suites
 #   * Prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE)
 #   * Prefer ECDHE over DHE for better performance
 #   * Prefer AEAD over CBC for better performance and security
@@ -185,6 +189,8 @@ _DEFAULT_CIPHERS = (
 #   * Disable NULL authentication, NULL encryption, MD5 MACs, DSS, RC4, and
 #     3DES for security reasons
 _RESTRICTED_SERVER_CIPHERS = (
+    'TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:'
+    'TLS13-AES-128-GCM-SHA256:'
     'ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:DH+CHACHA20:ECDH+AES256:DH+AES256:'
     'ECDH+AES128:DH+AES:ECDH+HIGH:DH+HIGH:RSA+AESGCM:RSA+AES:RSA+HIGH:'
     '!aNULL:!eNULL:!MD5:!DSS:!RC4:!3DES'
index 4b41f5ec5c7eb2cc9bd38b6a273b5c7bff1d172b..1f2da0ffbe854e69c181d19e54303138dae15825 100644 (file)
@@ -71,6 +71,10 @@ if mswindows:
 else:
     import select
     _has_poll = hasattr(select, 'poll')
+    try:
+        import threading
+    except ImportError:
+        threading = None
     import fcntl
     import pickle
 
@@ -878,6 +882,21 @@ class Popen(object):
                         pass
 
 
+        # Used as a bandaid workaround for https://bugs.python.org/issue27448
+        # to prevent multiple simultaneous subprocess launches from interfering
+        # with one another and leaving gc disabled.
+        if threading:
+            _disabling_gc_lock = threading.Lock()
+        else:
+            class _noop_context_manager(object):
+                # A dummy context manager that does nothing for the rare
+                # user of a --without-threads build.
+                def __enter__(self): pass
+                def __exit__(self, *args): pass
+
+            _disabling_gc_lock = _noop_context_manager()
+
+
         def _execute_child(self, args, executable, preexec_fn, close_fds,
                            cwd, env, universal_newlines,
                            startupinfo, creationflags, shell, to_close,
@@ -909,10 +928,12 @@ class Popen(object):
             errpipe_read, errpipe_write = self.pipe_cloexec()
             try:
                 try:
-                    gc_was_enabled = gc.isenabled()
-                    # Disable gc to avoid bug where gc -> file_dealloc ->
-                    # write to stderr -> hang.  http://bugs.python.org/issue1336
-                    gc.disable()
+                    with self._disabling_gc_lock:
+                        gc_was_enabled = gc.isenabled()
+                        # Disable gc to avoid bug where gc -> file_dealloc ->
+                        # write to stderr -> hang.
+                        # https://bugs.python.org/issue1336
+                        gc.disable()
                     try:
                         self.pid = os.fork()
                     except:
@@ -986,9 +1007,10 @@ class Popen(object):
                             exc_value.child_traceback = ''.join(exc_lines)
                             os.write(errpipe_write, pickle.dumps(exc_value))
 
-                        # This exitcode won't be reported to applications, so it
-                        # really doesn't matter what we return.
-                        os._exit(255)
+                        finally:
+                            # This exitcode won't be reported to applications, so it
+                            # really doesn't matter what we return.
+                            os._exit(255)
 
                     # Parent
                     if gc_was_enabled:
index 2eaa8e3709861acfda572b12810b9b4bdd3678f0..d0246c0aea7d8ca10fa9ae06924c41e996c5e7ab 100644 (file)
@@ -317,7 +317,7 @@ class Telnet:
                     ready = poller.poll(None if timeout is None
                                         else 1000 * call_timeout)
                 except select.error as e:
-                    if e.errno == errno.EINTR:
+                    if e[0] == errno.EINTR:
                         if timeout is not None:
                             elapsed = time() - time_start
                             call_timeout = timeout-elapsed
@@ -688,7 +688,7 @@ class Telnet:
                     ready = poller.poll(None if timeout is None
                                         else 1000 * call_timeout)
                 except select.error as e:
-                    if e.errno == errno.EINTR:
+                    if e[0] == errno.EINTR:
                         if timeout is not None:
                             elapsed = time() - time_start
                             call_timeout = timeout-elapsed
index 6fc5618902622f0ac5822263985446be8289414c..1bf32ef06dd9521eb1b0cd1fef7f96572e6f4c48 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python2
 """
 Command line tool to bisect failing CPython tests.
 
index 2646cbd58167bf57f6dd5dd1813d06c775d938b9..b900463da6061e35a2640d78390df10dac4ede9e 100644 (file)
@@ -13,8 +13,9 @@ the same application, the present example should work just fine.  DC
 """
 
 import os, sys, time, unittest
-import test.test_support as test_support
-thread = test_support.import_module('thread')
+import test.support as support
+
+threading = support.import_module('threading')
 
 LONGSLEEP = 2
 SHORTSLEEP = 0.5
@@ -23,8 +24,19 @@ NUM_THREADS = 4
 class ForkWait(unittest.TestCase):
 
     def setUp(self):
+        self._threading_key = support.threading_setup()
         self.alive = {}
         self.stop = 0
+        self.threads = []
+
+    def tearDown(self):
+        # Stop threads
+        self.stop = 1
+        for thread in self.threads:
+            thread.join()
+        thread = None
+        del self.threads[:]
+        support.threading_cleanup(*self._threading_key)
 
     def f(self, id):
         while not self.stop:
@@ -48,7 +60,9 @@ class ForkWait(unittest.TestCase):
 
     def test_wait(self):
         for i in range(NUM_THREADS):
-            thread.start_new(self.f, (i,))
+            thread = threading.Thread(target=self.f, args=(i,))
+            thread.start()
+            self.threads.append(thread)
 
         time.sleep(LONGSLEEP)
 
@@ -74,6 +88,3 @@ class ForkWait(unittest.TestCase):
         else:
             # Parent
             self.wait_impl(cpid)
-            # Tell threads to die
-            self.stop = 1
-            time.sleep(2*SHORTSLEEP) # Wait for threads to die
index ed606db0d11dbcc39e8578a8799f6d84f0c21d2f..54cfb97ccb8ec9b3454c12a0d19746e1effc41ac 100644 (file)
@@ -45,10 +45,11 @@ class CommonTest(seq_tests.CommonTest):
         self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
         self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
 
-        l0 = []
-        for i in xrange(sys.getrecursionlimit() + 100):
-            l0 = [l0]
-        self.assertRaises(RuntimeError, repr, l0)
+    def test_repr_deep(self):
+        a = self.type2test([])
+        for i in range(sys.getrecursionlimit() + 100):
+            a = self.type2test([a])
+        self.assertRaises(RuntimeError, repr, a)
 
     def test_print(self):
         d = self.type2test(xrange(200))
index f43750bb83f62c2962b157241a54fc4232a0c150..248dee2fed18b123094d818b4ac6a81910c8dfe7 100644 (file)
@@ -2,6 +2,7 @@
 import unittest
 import UserDict
 import test_support
+import sys
 
 
 class BasicTestMappingProtocol(unittest.TestCase):
@@ -645,6 +646,14 @@ class TestHashMappingProtocol(TestMappingProtocol):
         d = self._full_mapping({1: BadRepr()})
         self.assertRaises(Exc, repr, d)
 
+    def test_repr_deep(self):
+        d = self._empty_mapping()
+        for i in range(sys.getrecursionlimit() + 100):
+            d0 = d
+            d = self._empty_mapping()
+            d[1] = d0
+        self.assertRaises(RuntimeError, repr, d)
+
     def test_le(self):
         self.assertTrue(not (self._empty_mapping() < self._empty_mapping()))
         self.assertTrue(not (self._full_mapping({1: 2}) < self._full_mapping({1L: 2L})))
index 83b1ec726e4a1031c7bb849fcfac38fa83ace5c9..f40ff8d0eba1fe1e43c2d5822416ae5b12db7e14 100644 (file)
@@ -1,7 +1,8 @@
 """
-Collect various informations about Python to help debugging test failures.
+Collect various information about Python to help debugging test failures.
 """
 from __future__ import print_function
+import errno
 import re
 import sys
 import traceback
@@ -26,8 +27,8 @@ class PythonInfo:
         if value is None:
             return
 
-        if not isinstance(value, (int, long)):
-            if not isinstance(value, basestring):
+        if not isinstance(value, int):
+            if not isinstance(value, str):
                 # convert other objects like sys.flags to string
                 value = str(value)
 
@@ -39,7 +40,7 @@ class PythonInfo:
 
     def get_infos(self):
         """
-        Get informations as a key:value dictionary where values are strings.
+        Get information as a key:value dictionary where values are strings.
         """
         return {key: str(value) for key, value in self.info.items()}
 
@@ -55,6 +56,14 @@ def copy_attributes(info_add, obj, name_fmt, attributes, formatter=None):
         info_add(name, value)
 
 
+def copy_attr(info_add, name, mod, attr_name):
+    try:
+        value = getattr(mod, attr_name)
+    except AttributeError:
+        return
+    info_add(name, value)
+
+
 def call_func(info_add, name, mod, func_name, formatter=None):
     try:
         func = getattr(mod, func_name)
@@ -68,6 +77,8 @@ def call_func(info_add, name, mod, func_name, formatter=None):
 
 def collect_sys(info_add):
     attributes = (
+        '_framework',
+        'abiflags',
         'api_version',
         'builtin_module_names',
         'byteorder',
@@ -76,20 +87,28 @@ def collect_sys(info_add):
         'flags',
         'float_info',
         'float_repr_style',
+        'hash_info',
         'hexversion',
-        'maxint',
+        'implementation',
+        'int_info',
         'maxsize',
         'maxunicode',
         'path',
         'platform',
         'prefix',
+        'thread_info',
         'version',
         'version_info',
         'winver',
     )
     copy_attributes(info_add, sys, 'sys.%s', attributes)
 
+    call_func(info_add, 'sys.androidapilevel', sys, 'getandroidapilevel')
+    call_func(info_add, 'sys.windowsversion', sys, 'getwindowsversion')
+
     encoding = sys.getfilesystemencoding()
+    if hasattr(sys, 'getfilesystemencodeerrors'):
+        encoding = '%s/%s' % (encoding, sys.getfilesystemencodeerrors())
     info_add('sys.filesystem_encoding', encoding)
 
     for name in ('stdin', 'stdout', 'stderr'):
@@ -104,6 +123,14 @@ def collect_sys(info_add):
             encoding = '%s/%s' % (encoding, errors)
         info_add('sys.%s.encoding' % name, encoding)
 
+    # Were we compiled --with-pydebug or with #define Py_DEBUG?
+    Py_DEBUG = hasattr(sys, 'gettotalrefcount')
+    if Py_DEBUG:
+        text = 'Yes (sys.gettotalrefcount() present)'
+    else:
+        text = 'No (sys.gettotalrefcount() missing)'
+    info_add('Py_DEBUG', text)
+
 
 def collect_platform(info_add):
     import platform
@@ -121,26 +148,43 @@ def collect_platform(info_add):
 def collect_locale(info_add):
     import locale
 
-    info_add('locale.encoding', locale.getpreferredencoding(True))
+    info_add('locale.encoding', locale.getpreferredencoding(False))
+
+
+def collect_builtins(info_add):
+    info_add('builtins.float.float_format', float.__getformat__("float"))
+    info_add('builtins.float.double_format', float.__getformat__("double"))
 
 
 def collect_os(info_add):
     import os
 
-    attributes = ('name',)
-    copy_attributes(info_add, os, 'os.%s', attributes)
+    def format_attr(attr, value):
+        if attr in ('supports_follow_symlinks', 'supports_fd',
+                    'supports_effective_ids'):
+            return str(sorted(func.__name__ for func in value))
+        else:
+            return value
+
+    attributes = (
+        'name',
+        'supports_bytes_environ',
+        'supports_effective_ids',
+        'supports_fd',
+        'supports_follow_symlinks',
+    )
+    copy_attributes(info_add, os, 'os.%s', attributes, formatter=format_attr)
 
-    info_add("os.cwd", os.getcwd())
+    call_func(info_add, 'os.cwd', os, 'getcwd')
 
     call_func(info_add, 'os.uid', os, 'getuid')
     call_func(info_add, 'os.gid', os, 'getgid')
     call_func(info_add, 'os.uname', os, 'uname')
 
-    if hasattr(os, 'getgroups'):
-        groups = os.getgroups()
-        groups = map(str, groups)
-        groups = ', '.join(groups)
-        info_add("os.groups", groups)
+    def format_groups(groups):
+        return ', '.join(map(str, groups))
+
+    call_func(info_add, 'os.groups', os, 'getgroups', formatter=format_groups)
 
     if hasattr(os, 'getlogin'):
         try:
@@ -152,6 +196,7 @@ def collect_os(info_add):
         else:
             info_add("os.login", login)
 
+    call_func(info_add, 'os.cpu_count', os, 'cpu_count')
     call_func(info_add, 'os.loadavg', os, 'getloadavg')
 
     # Get environment variables: filter to list
@@ -182,7 +227,9 @@ def collect_os(info_add):
     )
     for name, value in os.environ.items():
         uname = name.upper()
-        if (uname in ENV_VARS or uname.startswith(("PYTHON", "LC_"))
+        if (uname in ENV_VARS
+           # Copy PYTHON* and LC_* variables
+           or uname.startswith(("PYTHON", "LC_"))
            # Visual Studio: VS140COMNTOOLS
            or (uname.startswith("VS") and uname.endswith("COMNTOOLS"))):
             info_add('os.environ[%s]' % name, value)
@@ -192,13 +239,20 @@ def collect_os(info_add):
         os.umask(mask)
         info_add("os.umask", '%03o' % mask)
 
-    try:
-        cpu_count = os.sysconf('SC_NPROCESSORS_ONLN')
-    except (AttributeError, ValueError):
-        pass
-    else:
-        if cpu_count:
-            info_add('os.sysconf(SC_NPROCESSORS_ONLN)', cpu_count)
+    if hasattr(os, 'getrandom'):
+        # PEP 524: Check if system urandom is initialized
+        try:
+            try:
+                os.getrandom(1, os.GRND_NONBLOCK)
+                state = 'ready (initialized)'
+            except BlockingIOError as exc:
+                state = 'not seeded yet (%s)' % exc
+            info_add('os.getrandom', state)
+        except OSError as exc:
+            # Python was compiled on a more recent Linux version
+            # than the current Linux kernel: ignore OSError(ENOSYS)
+            if exc.errno != errno.ENOSYS:
+                raise
 
 
 def collect_readline(info_add):
@@ -208,7 +262,7 @@ def collect_readline(info_add):
         return
 
     def format_attr(attr, value):
-        if isinstance(value, (int, long)):
+        if isinstance(value, int):
             return "%#x" % value
         else:
             return value
@@ -216,6 +270,7 @@ def collect_readline(info_add):
     attributes = (
         "_READLINE_VERSION",
         "_READLINE_RUNTIME_VERSION",
+        "_READLINE_LIBRARY_VERSION",
     )
     copy_attributes(info_add, readline, 'readline.%s', attributes,
                     formatter=format_attr)
@@ -248,11 +303,11 @@ def collect_tkinter(info_add):
         copy_attributes(info_add, _tkinter, 'tkinter.%s', attributes)
 
     try:
-        import Tkinter
+        import tkinter
     except ImportError:
         pass
     else:
-        tcl = Tkinter.Tcl()
+        tcl = tkinter.Tcl()
         patchlevel = tcl.call('info', 'patchlevel')
         info_add('tkinter.info_patchlevel', patchlevel)
 
@@ -260,6 +315,8 @@ def collect_tkinter(info_add):
 def collect_time(info_add):
     import time
 
+    info_add('time.time', time.time())
+
     attributes = (
         'altzone',
         'daylight',
@@ -268,6 +325,20 @@ def collect_time(info_add):
     )
     copy_attributes(info_add, time, 'time.%s', attributes)
 
+    if hasattr(time, 'get_clock_info'):
+        for clock in ('time', 'perf_counter'):
+            tinfo = time.get_clock_info(clock)
+            info_add('time.get_clock_info(%s)' % clock, tinfo)
+
+
+def collect_datetime(info_add):
+    try:
+        import datetime
+    except ImportError:
+        return
+
+    info_add('datetime.datetime.now', datetime.datetime.now())
+
 
 def collect_sysconfig(info_add):
     import sysconfig
@@ -279,7 +350,6 @@ def collect_sysconfig(info_add):
         'CCSHARED',
         'CFLAGS',
         'CFLAGSFORSHARED',
-        'PY_LDFLAGS',
         'CONFIG_ARGS',
         'HOST_GNU_TYPE',
         'MACHDEP',
@@ -287,6 +357,7 @@ def collect_sysconfig(info_add):
         'OPT',
         'PY_CFLAGS',
         'PY_CFLAGS_NODIST',
+        'PY_LDFLAGS',
         'Py_DEBUG',
         'Py_ENABLE_SHARED',
         'SHELL',
@@ -360,15 +431,62 @@ def collect_expat(info_add):
     copy_attributes(info_add, expat, 'expat.%s', attributes)
 
 
-def collect_multiprocessing(info_add):
+def collect_decimal(info_add):
     try:
-        import multiprocessing
+        import _decimal
     except ImportError:
         return
 
-    cpu_count = multiprocessing.cpu_count()
-    if cpu_count:
-        info_add('multiprocessing.cpu_count', cpu_count)
+    attributes = ('__libmpdec_version__',)
+    copy_attributes(info_add, _decimal, '_decimal.%s', attributes)
+
+
+def collect_testcapi(info_add):
+    try:
+        import _testcapi
+    except ImportError:
+        return
+
+    call_func(info_add, 'pymem.allocator', _testcapi, 'pymem_getallocatorsname')
+    copy_attr(info_add, 'pymem.with_pymalloc', _testcapi, 'WITH_PYMALLOC')
+
+
+def collect_resource(info_add):
+    try:
+        import resource
+    except ImportError:
+        return
+
+    limits = [attr for attr in dir(resource) if attr.startswith('RLIMIT_')]
+    for name in limits:
+        key = getattr(resource, name)
+        value = resource.getrlimit(key)
+        info_add('resource.%s' % name, value)
+
+
+def collect_test_socket(info_add):
+    try:
+        from test import test_socket
+    except ImportError:
+        return
+
+    # all check attributes like HAVE_SOCKET_CAN
+    attributes = [name for name in dir(test_socket)
+                  if name.startswith('HAVE_')]
+    copy_attributes(info_add, test_socket, 'test_socket.%s', attributes)
+
+
+def collect_test_support(info_add):
+    try:
+        from test import support
+    except ImportError:
+        return
+
+    attributes = ('IPV6_ENABLED',)
+    copy_attributes(info_add, support, 'test_support.%s', attributes)
+
+    call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
+    call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
 
 
 def collect_info(info):
@@ -376,10 +494,12 @@ def collect_info(info):
     info_add = info.add
 
     for collect_func in (
-        collect_expat,
+        # collect_os() should be the first, to check the getrandom() status
+        collect_os,
+
+        collect_builtins,
         collect_gdb,
         collect_locale,
-        collect_os,
         collect_platform,
         collect_readline,
         collect_socket,
@@ -388,9 +508,17 @@ def collect_info(info):
         collect_sys,
         collect_sysconfig,
         collect_time,
+        collect_datetime,
         collect_tkinter,
         collect_zlib,
-        collect_multiprocessing,
+        collect_expat,
+        collect_decimal,
+        collect_testcapi,
+        collect_resource,
+
+        # Collecting from tests should be last as they have side effects.
+        collect_test_socket,
+        collect_test_support,
     ):
         try:
             collect_func(info_add)
index d836468852f17242c23fdbb4e22d3989b35943a5..6df8f86d95799ad395d6ab953d0a9595f7ed4a33 100755 (executable)
@@ -1037,7 +1037,7 @@ def runtest(test, verbose, quiet,
     if use_resources is not None:
         test_support.use_resources = use_resources
     try:
-        test_support.match_tests = match_tests
+        test_support.set_match_tests(match_tests)
         if failfast:
             test_support.failfast = True
         return runtest_inner(test, verbose, quiet, huntrleaks, pgo, testdir)
@@ -1580,12 +1580,12 @@ def _list_cases(suite):
         if isinstance(test, unittest.TestSuite):
             _list_cases(test)
         elif isinstance(test, unittest.TestCase):
-            if test_support._match_test(test):
+            if test_support.match_test(test):
                 print(test.id())
 
 def list_cases(testdir, selected, match_tests):
     test_support.verbose = False
-    test_support.match_tests = match_tests
+    test_support.set_match_tests(match_tests)
 
     save_modules = set(sys.modules)
     skipped = []
diff --git a/Lib/test/sha256.pem b/Lib/test/sha256.pem
deleted file mode 100644 (file)
index d3db4b8..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-# Certificate chain for https://sha256.tbs-internet.com
- 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com
-   i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC
------BEGIN CERTIFICATE-----
-MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw
-gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl
-bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u
-ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv
-cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg
-Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV
-BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV
-BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM
-VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS
-c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0
-LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m
-PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf
-PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E
-LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo
-qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49
-IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU
-xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf
-2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC
-BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG
-CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw
-MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D
-UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv
-bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv
-bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw
-AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw
-NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH
-Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV
-HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt
-aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX
-ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0
-UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN
-21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun
-aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT
-XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q
------END CERTIFICATE-----
- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC
-   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
------BEGIN CERTIFICATE-----
-MIIFVjCCBD6gAwIBAgIQXpDZ0ETJMV02WTx3GTnhhTANBgkqhkiG9w0BAQUFADBv
-MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
-ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
-eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDYyNDE5MDYzMFow
-gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl
-bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u
-ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv
-cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg
-Q0EgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgOkO3f7wzN6
-rOjg45tR5vjBfzK7qmV9IBxb/QW9EEXxG+E7FNhZqQLtwGBKoSsHTnQqV75wWMk0
-9tinWvftBkSpj5sTi/8cbzJfUvTSVYh3Qxv6AVVjMMH/ruLjE6y+4PoaPs8WoYAQ
-ts5R4Z1g8c/WnTepLst2x0/Wv7GmuoQi+gXvHU6YrBiu7XkeYhzc95QdviWSJRDk
-owhb5K43qhcvjRmBfO/paGlCliDGZp8mHwrI21mwobWpVjTxZRwYO3bd4+TGcI4G
-Ie5wmHwE8F7SK1tgSqbBacKjDa93j7txKkfz/Yd2n7TGqOXiHPsJpG655vrKtnXk
-9vs1zoDeJQIDAQABo4IBljCCAZIwHQYDVR0OBBYEFAdEdoWTKLx/bXjSCuv6TEvf
-2YIfMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMCAGA1UdJQQZ
-MBcGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAYBgNVHSAEETAPMA0GCysGAQQBgOU3
-AgQBMHsGA1UdHwR0MHIwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL0Fk
-ZFRydXN0RXh0ZXJuYWxDQVJvb3QuY3JsMDagNKAyhjBodHRwOi8vY3JsLmNvbW9k
-by5uZXQvQWRkVHJ1c3RFeHRlcm5hbENBUm9vdC5jcmwwgYAGCCsGAQUFBwEBBHQw
-cjA4BggrBgEFBQcwAoYsaHR0cDovL2NydC5jb21vZG9jYS5jb20vQWRkVHJ1c3RV
-VE5TR0NDQS5jcnQwNgYIKwYBBQUHMAKGKmh0dHA6Ly9jcnQuY29tb2RvLm5ldC9B
-ZGRUcnVzdFVUTlNHQ0NBLmNydDARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcN
-AQEFBQADggEBAK2zEzs+jcIrVK9oDkdDZNvhuBYTdCfpxfFs+OAujW0bIfJAy232
-euVsnJm6u/+OrqKudD2tad2BbejLLXhMZViaCmK7D9nrXHx4te5EP8rL19SUVqLY
-1pTnv5dhNgEgvA7n5lIzDSYs7yRLsr7HJsYPr6SeYSuZizyX1SNz7ooJ32/F3X98
-RB0Mlc/E0OyOrkQ9/y5IrnpnaSora8CnUrV5XNOg+kyCz9edCyx4D5wXYcwZPVWz
-8aDqquESrezPyjtfi4WRO4s/VD3HLZvOxzMrWAVYCDG9FxaOhF0QGuuG1F7F3GKV
-v6prNyCl016kRl2j1UT+a7gLd8fA25A4C9E=
------END CERTIFICATE-----
- 2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
-   i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
------BEGIN CERTIFICATE-----
-MIIEZjCCA06gAwIBAgIQUSYKkxzif5zDpV954HKugjANBgkqhkiG9w0BAQUFADCB
-kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
-Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
-dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw
-IFNHQzAeFw0wNTA2MDcwODA5MTBaFw0xOTA2MjQxOTA2MzBaMG8xCzAJBgNVBAYT
-AlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0
-ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB
-IFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39xoz5vIABC05
-4E5b7R+8bA/Ntfojts7emxEzl6QpTH2Tn71KvJPtAxrjj8/lbVBa1pcplFqAsEl6
-2y6V/bjKvzc4LR4+kUGtcFbH8E8/6DKedMrIkFTpxl8PeJ2aQDwOrGGqXhSPnoeh
-alDc15pOrwWzpnGUnHGzUGAKxxOdOAeGAqjpqGkmGJCrTLBPI6s6T4TY386f4Wlv
-u9dC12tE5Met7m1BX3JacQg3s3llpFmglDf3AC8NwpJy2tA4ctsUqEXEXSp9t7TW
-xO6szRNEt8kr3UMAJfphuWlqWCMRt6czj1Z1WfXNKddGtworZbbTQm8Vsrh7++/p
-XVPVNFonAgMBAAGjgdgwgdUwHwYDVR0jBBgwFoAUUzLRs89/+uDxoF2FTpLSnkUd
-tE8wHQYDVR0OBBYEFK29mHo0tCb3+sQmVO8DveAky1QaMA4GA1UdDwEB/wQEAwIB
-BjAPBgNVHRMBAf8EBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIBAjAgBgNVHSUEGTAX
-BgorBgEEAYI3CgMDBglghkgBhvhCBAEwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDov
-L2NybC51c2VydHJ1c3QuY29tL1VUTi1EQVRBQ29ycFNHQy5jcmwwDQYJKoZIhvcN
-AQEFBQADggEBAMbuUxdoFLJRIh6QWA2U/b3xcOWGLcM2MY9USEbnLQg3vGwKYOEO
-rVE04BKT6b64q7gmtOmWPSiPrmQH/uAB7MXjkesYoPF1ftsK5p+R26+udd8jkWjd
-FwBaS/9kbHDrARrQkNnHptZt9hPk/7XJ0h4qy7ElQyZ42TCbTg0evmnv3+r+LbPM
-+bDdtRTKkdSytaX7ARmjR3mfnYyVhzT4HziS2jamEfpr62vp3EV4FTkG101B5CHI
-3C+H0be/SGB1pWLLJN47YaApIKa+xWycxOkKaSLvkTr6Jq/RW0GnOuL4OAdCq8Fb
-+M5tug8EPzI0rNwEKNdwMBQmBsTkm5jVz3g=
------END CERTIFICATE-----
- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
-   i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
------BEGIN CERTIFICATE-----
-MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB
-kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
-Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
-dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw
-IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG
-EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD
-VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu
-dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN
-BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6
-E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ
-D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK
-4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq
-lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW
-bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB
-o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT
-MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js
-LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr
-BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB
-AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft
-Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj
-j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH
-KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv
-2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3
-mfnGV/TJVTl4uix5yaaIK/QI
------END CERTIFICATE-----
index ef474e00b68cc3b6c174cc07eb98625b745d8d6e..1e0f14eb3a18888a6a28d876b188310b054b05df 100644 (file)
@@ -179,7 +179,6 @@ max_memuse = 0           # Disable bigmem tests (they will still be run with
                          # small sizes, to make sure they work.)
 real_max_memuse = 0
 failfast = False
-match_tests = None
 
 # _original_stdout is meant to hold stdout at the time regrtest began.
 # This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
@@ -754,10 +753,14 @@ def temp_dir(path=None, quiet=False):
                 raise
             warnings.warn('tests may fail, unable to create temp dir: ' + path,
                           RuntimeWarning, stacklevel=3)
+    if dir_created:
+        pid = os.getpid()
     try:
         yield path
     finally:
-        if dir_created:
+        # In case the process forks, let only the parent remove the
+        # directory. The child has a diffent process id. (bpo-30028)
+        if dir_created and pid == os.getpid():
             rmtree(path)
 
 @contextlib.contextmanager
@@ -848,8 +851,8 @@ def make_bad_fd():
         file.close()
         unlink(TESTFN)
 
-def check_syntax_error(testcase, statement, lineno=None, offset=None):
-    with testcase.assertRaises(SyntaxError) as cm:
+def check_syntax_error(testcase, statement, errtext='', lineno=None, offset=None):
+    with testcase.assertRaisesRegexp(SyntaxError, errtext) as cm:
         compile(statement, '<test string>', 'exec')
     err = cm.exception
     if lineno is not None:
@@ -1542,21 +1545,67 @@ def _run_suite(suite):
         raise TestFailed(err)
 
 
-def _match_test(test):
-    global match_tests
+# By default, don't filter tests
+_match_test_func = None
+_match_test_patterns = None
 
-    if match_tests is None:
+
+def match_test(test):
+    # Function used by support.run_unittest() and regrtest --list-cases
+    if _match_test_func is None:
         return True
-    test_id = test.id()
+    else:
+        return _match_test_func(test.id())
 
-    for match_test in match_tests:
-        if fnmatch.fnmatchcase(test_id, match_test):
-            return True
 
-        for name in test_id.split("."):
-            if fnmatch.fnmatchcase(name, match_test):
+def _is_full_match_test(pattern):
+    # If a pattern contains at least one dot, it's considered
+    # as a full test identifier.
+    # Example: 'test.test_os.FileTests.test_access'.
+    #
+    # Reject patterns which contain fnmatch patterns: '*', '?', '[...]'
+    # or '[!...]'. For example, reject 'test_access*'.
+    return ('.' in pattern) and (not re.search(r'[?*\[\]]', pattern))
+
+
+def set_match_tests(patterns):
+    global _match_test_func, _match_test_patterns
+
+    if patterns == _match_test_patterns:
+        # No change: no need to recompile patterns.
+        return
+
+    if not patterns:
+        func = None
+        # set_match_tests(None) behaves as set_match_tests(())
+        patterns = ()
+    elif all(map(_is_full_match_test, patterns)):
+        # Simple case: all patterns are full test identifier.
+        # The test.bisect utility only uses such full test identifiers.
+        func = set(patterns).__contains__
+    else:
+        regex = '|'.join(map(fnmatch.translate, patterns))
+        # The search *is* case sensitive on purpose:
+        # don't use flags=re.IGNORECASE
+        regex_match = re.compile(regex).match
+
+        def match_test_regex(test_id):
+            if regex_match(test_id):
+                # The regex matchs the whole identifier like
+                # 'test.test_os.FileTests.test_access'
                 return True
-    return False
+            else:
+                # Try to match parts of the test identifier.
+                # For example, split 'test.test_os.FileTests.test_access'
+                # into: 'test', 'test_os', 'FileTests' and 'test_access'.
+                return any(map(regex_match, test_id.split(".")))
+
+        func = match_test_regex
+
+    # Create a copy since patterns can be mutable and so modified later
+    _match_test_patterns = tuple(patterns)
+    _match_test_func = func
+
 
 
 def run_unittest(*classes):
@@ -1573,7 +1622,7 @@ def run_unittest(*classes):
             suite.addTest(cls)
         else:
             suite.addTest(unittest.makeSuite(cls))
-    _filter_suite(suite, _match_test)
+    _filter_suite(suite, match_test)
     _run_suite(suite)
 
 #=======================================================================
@@ -1795,6 +1844,9 @@ def py3k_bytes(b):
         except TypeError:
             return bytes(b)
 
+requires_type_collecting = unittest.skipIf(hasattr(sys, 'getcounts'),
+                        'types are immortal if COUNT_ALLOCS is defined')
+
 def args_from_interpreter_flags():
     """Return a list of command-line arguments reproducing the current
     settings in sys.flags."""
@@ -1960,6 +2012,45 @@ def _crash_python():
     Use SuppressCrashReport() to prevent a crash report from popping up.
     """
 
-    import ctypes
+    import _testcapi
     with SuppressCrashReport():
-        ctypes.string_at(0)
+        _testcapi._read_null()
+
+
+class SaveSignals:
+    """
+    Save an restore signal handlers.
+
+    This class is only able to save/restore signal handlers registered
+    by the Python signal module: see bpo-13285 for "external" signal
+    handlers.
+    """
+
+    def __init__(self):
+        import signal
+        self.signal = signal
+        self.signals = list(range(1, signal.NSIG))
+        # SIGKILL and SIGSTOP signals cannot be ignored nor catched
+        for signame in ('SIGKILL', 'SIGSTOP'):
+            try:
+                signum = getattr(signal, signame)
+            except AttributeError:
+                continue
+            self.signals.remove(signum)
+        self.handlers = {}
+
+    def save(self):
+        for signum in self.signals:
+            handler = self.signal.getsignal(signum)
+            if handler is None:
+                # getsignal() returns None if a signal handler was not
+                # registered by the Python signal module,
+                # and the handler is not SIG_DFL nor SIG_IGN.
+                #
+                # Ignore the signal: we cannot restore the handler.
+                continue
+            self.handlers[signum] = handler
+
+    def restore(self):
+        for signum, handler in self.handlers.items():
+            self.signal.signal(signum, handler)
index 6a8c3a132742720c0bb1aef35ecbecb79f30f18d..dbba37cdb6fff8b27caac5649d4ec057f3521241 100644 (file)
@@ -208,6 +208,7 @@ class TestABC(unittest.TestCase):
         C()
         self.assertEqual(B.counter, 1)
 
+    @test_support.requires_type_collecting
     def test_cache_leak(self):
         # See issue #2521.
         class A(object):
index d1b7dd0432579cf84039fb08e68580cb2a0eddc3..92bbe7bc75da93f2648f18fe4ec6ce5cb535ef72 100644 (file)
@@ -214,6 +214,14 @@ class AIFCLowLevelTest(unittest.TestCase):
         b = io.BytesIO('FORM' + struct.pack('>L', 4) + 'AIFF')
         self.assertRaises(aifc.Error, aifc.open, b)
 
+    def test_read_no_ssnd_chunk(self):
+        b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
+        b += b'COMM' + struct.pack('>LhlhhLL', 38, 0, 0, 0, 0, 0, 0)
+        b += b'NONE' + struct.pack('B', 14) + b'not compressed' + b'\x00'
+        with self.assertRaisesRegexp(aifc.Error, 'COMM chunk and/or SSND chunk'
+                                                 ' missing'):
+            aifc.open(io.BytesIO(b))
+
     def test_read_wrong_compression_type(self):
         b = 'FORM' + struct.pack('>L', 4) + 'AIFC'
         b += 'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0)
index 4af73500ea41aa0d613d4d3dea277e4144e64665..5f1deb5776148855aaa9fdc5f78353c9ebcc72c7 100644 (file)
@@ -325,6 +325,10 @@ class TestAudioop(unittest.TestCase):
             self.assertEqual(audioop.ratecv(datas[w], w, 1, 8000, 8000, None, 30, 10)[0],
                              expected[w])
 
+        self.assertRaises(TypeError, audioop.ratecv, b'', 1, 1, 8000, 8000, 42)
+        self.assertRaises(TypeError, audioop.ratecv,
+                          b'', 1, 1, 8000, 8000, (1, (42,)))
+
     def test_reverse(self):
         for w in 1, 2, 4:
             self.assertEqual(audioop.reverse(b'', w), b'')
index c9347e96aa1f34e7420845594d59058b10d54168..5396838f3d26be17ee38fcef9a37b2cb80382a2d 100644 (file)
@@ -1593,18 +1593,28 @@ class BuiltinTest(unittest.TestCase):
         self.assertRaises(ValueError, x.translate, "1", 1)
         self.assertRaises(TypeError, x.translate, "1"*256, 1)
 
+
+def create_exec_script(filename):
+    with open(filename, 'w') as f:
+        f.write('z = z+1\n')
+        f.write('z = z*2\n')
+
+
 class TestExecFile(unittest.TestCase):
     # Done outside of the method test_z to get the correct scope
     z = 0
-    f = open(TESTFN, 'w')
-    f.write('z = z+1\n')
-    f.write('z = z*2\n')
-    f.close()
-    with check_py3k_warnings(("execfile.. not supported in 3.x",
-                              DeprecationWarning)):
-        execfile(TESTFN)
+    try:
+        create_exec_script(TESTFN)
+        with check_py3k_warnings(("execfile.. not supported in 3.x",
+                                  DeprecationWarning)):
+            execfile(TESTFN)
+    finally:
+        unlink(TESTFN)
 
     def test_execfile(self):
+        self.addCleanup(unlink, TESTFN)
+        create_exec_script(TESTFN)
+
         globals = {'a': 1, 'b': 2}
         locals = {'b': 200, 'c': 300}
 
index 4a70b33bc0b9e37b4ba377c551f3a33e6f7a2140..ce2c5b21ee3fb6fc9e460d8cab11b5952db5e6d7 100644 (file)
@@ -336,8 +336,16 @@ class BaseBytesTest(unittest.TestCase):
         self.assertEqual(b.replace(b'i', b'a'), b'massassappa')
         self.assertEqual(b.replace(b'ss', b'x'), b'mixixippi')
 
+    def test_replace_int_error(self):
+        self.assertRaises(TypeError, self.type2test(b'a b').replace, 32, b'')
+
     def test_split_string_error(self):
         self.assertRaises(TypeError, self.type2test(b'a b').split, u' ')
+        self.assertRaises(TypeError, self.type2test(b'a b').rsplit, u' ')
+
+    def test_split_int_error(self):
+        self.assertRaises(TypeError, self.type2test(b'a b').split, 32)
+        self.assertRaises(TypeError, self.type2test(b'a b').rsplit, 32)
 
     def test_split_unicodewhitespace(self):
         for b in (b'a\x1Cb', b'a\x1Db', b'a\x1Eb', b'a\x1Fb'):
@@ -346,9 +354,6 @@ class BaseBytesTest(unittest.TestCase):
         b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
         self.assertEqual(b.split(), [b'\x1c\x1d\x1e\x1f'])
 
-    def test_rsplit_string_error(self):
-        self.assertRaises(TypeError, self.type2test(b'a b').rsplit, u' ')
-
     def test_rsplit_unicodewhitespace(self):
         b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
         self.assertEqual(b.rsplit(), [b'\x1c\x1d\x1e\x1f'])
@@ -364,6 +369,14 @@ class BaseBytesTest(unittest.TestCase):
         self.assertEqual(b.rpartition(b'i'), (b'mississipp', b'i', b''))
         self.assertEqual(b.rpartition(b'w'), (b'', b'', b'mississippi'))
 
+    def test_partition_string_error(self):
+        self.assertRaises(TypeError, self.type2test(b'a b').partition, u' ')
+        self.assertRaises(TypeError, self.type2test(b'a b').rpartition, u' ')
+
+    def test_partition_int_error(self):
+        self.assertRaises(TypeError, self.type2test(b'a b').partition, 32)
+        self.assertRaises(TypeError, self.type2test(b'a b').rpartition, 32)
+
     def test_pickling(self):
         for proto in range(pickle.HIGHEST_PROTOCOL + 1):
             for b in b"", b"a", b"abc", b"\xffab\x80", b"\0\0\377\0\0":
@@ -378,9 +391,19 @@ class BaseBytesTest(unittest.TestCase):
         self.assertEqual(self.type2test(b'abc').rstrip(memoryview(b'ac')), b'ab')
 
     def test_strip_string_error(self):
-        self.assertRaises(TypeError, self.type2test(b'abc').strip, u'b')
-        self.assertRaises(TypeError, self.type2test(b'abc').lstrip, u'b')
-        self.assertRaises(TypeError, self.type2test(b'abc').rstrip, u'b')
+        self.assertRaises(TypeError, self.type2test(b'abc').strip, u'ac')
+        self.assertRaises(TypeError, self.type2test(b'abc').lstrip, u'ac')
+        self.assertRaises(TypeError, self.type2test(b'abc').rstrip, u'ac')
+
+    def test_strip_int_error(self):
+        self.assertRaises(TypeError, self.type2test(b' abc ').strip, 32)
+        self.assertRaises(TypeError, self.type2test(b' abc ').lstrip, 32)
+        self.assertRaises(TypeError, self.type2test(b' abc ').rstrip, 32)
+
+    def test_xjust_int_error(self):
+        self.assertRaises(TypeError, self.type2test(b'abc').center, 7, 32)
+        self.assertRaises(TypeError, self.type2test(b'abc').ljust, 7, 32)
+        self.assertRaises(TypeError, self.type2test(b'abc').rjust, 7, 32)
 
     def test_ord(self):
         b = self.type2test(b'\0A\x7f\x80\xff')
index efc40cf2c23f903fd13a270677a628e8217374e6..0ec8bf5a4b4f2689d6fca609caad5c456b25b544 100644 (file)
@@ -149,19 +149,33 @@ class ReadTest(unittest.TestCase):
         self.assertEqual(f.read(), ''.join(lines[1:]))
         self.assertEqual(f.read(), '')
 
+        # Issue #32110: Test readline() followed by read(n)
+        f = getreader()
+        self.assertEqual(f.readline(), lines[0])
+        self.assertEqual(f.read(1), lines[1][0])
+        self.assertEqual(f.read(0), '')
+        self.assertEqual(f.read(100), data[len(lines[0]) + 1:][:100])
+
         # Issue #16636: Test readline() followed by readlines()
         f = getreader()
         self.assertEqual(f.readline(), lines[0])
         self.assertEqual(f.readlines(), lines[1:])
         self.assertEqual(f.read(), '')
 
-        # Test read() followed by read()
+        # Test read(n) followed by read()
         f = getreader()
         self.assertEqual(f.read(size=40, chars=5), data[:5])
         self.assertEqual(f.read(), data[5:])
         self.assertEqual(f.read(), '')
 
-        # Issue #12446: Test read() followed by readlines()
+        # Issue #32110: Test read(n) followed by read(n)
+        f = getreader()
+        self.assertEqual(f.read(size=40, chars=5), data[:5])
+        self.assertEqual(f.read(1), data[5])
+        self.assertEqual(f.read(0), '')
+        self.assertEqual(f.read(100), data[6:106])
+
+        # Issue #12446: Test read(n) followed by readlines()
         f = getreader()
         self.assertEqual(f.read(size=40, chars=5), data[:5])
         self.assertEqual(f.readlines(), [lines[0][5:]] + lines[1:])
index 4db200d4031b740764867b62bffe184dc99ed0ba..7cd9c71981a67e185c0a3dac998159b21f7d3764 100644 (file)
@@ -1,14 +1,20 @@
+import sys
 from test import test_support
 import unittest
 
 crypt = test_support.import_module('crypt')
 
+if sys.platform.startswith('openbsd'):
+    raise unittest.SkipTest('The only supported method on OpenBSD is Blowfish')
+
 class CryptTestCase(unittest.TestCase):
 
     def test_crypt(self):
-        c = crypt.crypt('mypassword', 'ab')
-        if test_support.verbose:
-            print 'Test encryption: ', c
+        cr = crypt.crypt('mypassword', 'ab')
+        if cr is not None:
+            cr2 = crypt.crypt('mypassword', cr)
+            self.assertEqual(cr2, cr)
+
 
 def test_main():
     test_support.run_unittest(CryptTestCase)
index d4567590cb1d8e4289352f73d1cb0e80abd59673..88d5af7c130d5dbac4f57747d612769fad26b994 100644 (file)
@@ -1036,6 +1036,15 @@ Stonecutters Seafood and Chop House+ Lemont+ IL+ 12/19/02+ Week Back
         self.assertEqual(sniffer.has_header(self.header2 + self.sample8),
                          True)
 
+    def test_guess_quote_and_delimiter(self):
+        sniffer = csv.Sniffer()
+        for header in (";'123;4';", "'123;4';", ";'123;4'", "'123;4'"):
+            dialect = sniffer.sniff(header, ",;")
+            self.assertEqual(dialect.delimiter, ';')
+            self.assertEqual(dialect.quotechar, "'")
+            self.assertIs(dialect.doublequote, False)
+            self.assertIs(dialect.skipinitialspace, False)
+
     def test_sniff(self):
         sniffer = csv.Sniffer()
         dialect = sniffer.sniff(self.sample1)
index 84b6bfddca533c5b3a541fbabeef7e2c19677f0d..c7e5b4abd36f98d6306ef5bce2a323f44fd47e37 100644 (file)
@@ -15,7 +15,9 @@ import sys
 import tempfile
 import unittest
 
-from test.test_support import requires, import_module, verbose, run_unittest
+from test.support import (requires, import_module, verbose, run_unittest,
+                          SaveSignals)
+
 
 # Optionally test curses module.  This currently requires that the
 # 'curses' resource be given on the regrtest command line using the -u
@@ -24,9 +26,12 @@ requires('curses')
 
 # If either of these don't exist, skip the tests.
 curses = import_module('curses')
-import_module('curses.panel')
 import_module('curses.ascii')
 import_module('curses.textpad')
+try:
+    import curses.panel
+except ImportError:
+    pass
 
 def requires_curses_func(name):
     return unittest.skipUnless(hasattr(curses, name),
@@ -62,6 +67,8 @@ class TestCurses(unittest.TestCase):
             del cls.tmp
 
     def setUp(self):
+        self.save_signals = SaveSignals()
+        self.save_signals.save()
         if verbose:
             # just to make the test output a little more readable
             print('')
@@ -71,6 +78,7 @@ class TestCurses(unittest.TestCase):
     def tearDown(self):
         curses.resetty()
         curses.endwin()
+        self.save_signals.restore()
 
     def test_window_funcs(self):
         "Test the methods of windows"
@@ -84,7 +92,7 @@ class TestCurses(unittest.TestCase):
                          (4,4, 'a'), (5,5, 'a', curses.A_BOLD)]:
                 meth(*args)
 
-        for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot,
+        for meth in [stdscr.clear, stdscr.clrtobot,
                      stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch,
                      stdscr.deleteln, stdscr.erase, stdscr.getbegyx,
                      stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx,
@@ -117,6 +125,13 @@ class TestCurses(unittest.TestCase):
             win.border(65, 66, 67, 68,
                        69, [], 71, 72)
 
+        win.box(65, 67)
+        win.box('!', '_')
+        win.box(b':', b'~')
+        self.assertRaises(TypeError, win.box, 65, 66, 67)
+        self.assertRaises(TypeError, win.box, 65)
+        win.box()
+
         stdscr.clearok(1)
 
         win4 = stdscr.derwin(2,2)
@@ -132,7 +147,9 @@ class TestCurses(unittest.TestCase):
 
         stdscr.idcok(1)
         stdscr.idlok(1)
-        stdscr.immedok(1)
+        if hasattr(stdscr, 'immedok'):
+            stdscr.immedok(1)
+            stdscr.immedok(0)
         stdscr.insch('c')
         stdscr.insdelln(1)
         stdscr.insnstr('abc', 3)
@@ -166,25 +183,27 @@ class TestCurses(unittest.TestCase):
         stdscr.setscrreg(10,15)
         win3 = stdscr.subwin(10,10)
         win3 = stdscr.subwin(10,10, 5,5)
-        stdscr.syncok(1)
+        if hasattr(stdscr, 'syncok') and not sys.platform.startswith("sunos"):
+            stdscr.syncok(1)
         stdscr.timeout(5)
         stdscr.touchline(5,5)
         stdscr.touchline(5,5,0)
         stdscr.vline('a', 3)
         stdscr.vline('a', 3, curses.A_STANDOUT)
-        stdscr.chgat(5, 2, 3, curses.A_BLINK)
-        stdscr.chgat(3, curses.A_BOLD)
-        stdscr.chgat(5, 8, curses.A_UNDERLINE)
-        stdscr.chgat(curses.A_BLINK)
+        if hasattr(stdscr, 'chgat'):
+            stdscr.chgat(5, 2, 3, curses.A_BLINK)
+            stdscr.chgat(3, curses.A_BOLD)
+            stdscr.chgat(5, 8, curses.A_UNDERLINE)
+            stdscr.chgat(curses.A_BLINK)
         stdscr.refresh()
 
         stdscr.vline(1,1, 'a', 3)
         stdscr.vline(1,1, 'a', 3, curses.A_STANDOUT)
 
-        if hasattr(curses, 'resize'):
-            stdscr.resize()
-        if hasattr(curses, 'enclose'):
-            stdscr.enclose()
+        if hasattr(stdscr, 'resize'):
+            stdscr.resize(25, 80)
+        if hasattr(stdscr, 'enclose'):
+            stdscr.enclose(10, 10)
 
         self.assertRaises(ValueError, stdscr.getstr, -400)
         self.assertRaises(ValueError, stdscr.getstr, 2, 3, -400)
@@ -196,14 +215,18 @@ class TestCurses(unittest.TestCase):
         "Test module-level functions"
         for func in [curses.baudrate, curses.beep, curses.can_change_color,
                      curses.cbreak, curses.def_prog_mode, curses.doupdate,
-                     curses.filter, curses.flash, curses.flushinp,
+                     curses.flash, curses.flushinp,
                      curses.has_colors, curses.has_ic, curses.has_il,
                      curses.isendwin, curses.killchar, curses.longname,
                      curses.nocbreak, curses.noecho, curses.nonl,
                      curses.noqiflush, curses.noraw,
                      curses.reset_prog_mode, curses.termattrs,
-                     curses.termname, curses.erasechar, curses.getsyx]:
+                     curses.termname, curses.erasechar]:
             func()
+        if hasattr(curses, 'filter'):
+            curses.filter()
+        if hasattr(curses, 'getsyx'):
+            curses.getsyx()
 
         # Functions that actually need arguments
         if curses.tigetstr("cnorm"):
@@ -227,15 +250,18 @@ class TestCurses(unittest.TestCase):
         curses.putp(b'abc')
         curses.qiflush()
         curses.raw() ; curses.raw(1)
-        curses.setsyx(5,5)
+        if hasattr(curses, 'setsyx'):
+            curses.setsyx(5,5)
         curses.tigetflag('hc')
         curses.tigetnum('co')
         curses.tigetstr('cr')
         curses.tparm(b'cr')
-        curses.typeahead(sys.__stdin__.fileno())
+        if hasattr(curses, 'typeahead'):
+            curses.typeahead(sys.__stdin__.fileno())
         curses.unctrl('a')
         curses.ungetch('a')
-        curses.use_env(1)
+        if hasattr(curses, 'use_env'):
+            curses.use_env(1)
 
     # Functions only available on a few platforms
     def test_colors_funcs(self):
@@ -269,6 +295,7 @@ class TestCurses(unittest.TestCase):
         curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
         m = curses.getmouse()
 
+    @requires_curses_func('panel')
     def test_userptr_without_set(self):
         w = curses.newwin(10, 10)
         p = curses.panel.new_panel(w)
@@ -277,6 +304,7 @@ class TestCurses(unittest.TestCase):
                                msg='userptr should fail since not set'):
             p.userptr()
 
+    @requires_curses_func('panel')
     def test_userptr_memory_leak(self):
         w = curses.newwin(10, 10)
         p = curses.panel.new_panel(w)
@@ -289,16 +317,20 @@ class TestCurses(unittest.TestCase):
         self.assertEqual(sys.getrefcount(obj), nrefs,
                          "set_userptr leaked references")
 
+    @requires_curses_func('panel')
     def test_userptr_segfault(self):
-        panel = curses.panel.new_panel(self.stdscr)
+        w = curses.newwin(10, 10)
+        panel = curses.panel.new_panel(w)
         class A:
             def __del__(self):
                 panel.set_userptr(None)
         panel.set_userptr(A())
         panel.set_userptr(None)
 
+    @requires_curses_func('panel')
     def test_new_curses_panel(self):
-        panel = curses.panel.new_panel(self.stdscr)
+        w = curses.newwin(10, 10)
+        panel = curses.panel.new_panel(w)
         self.assertRaises(TypeError, type(panel))
 
     @requires_curses_func('is_term_resized')
@@ -330,6 +362,8 @@ class TestCurses(unittest.TestCase):
 
     def test_issue13051(self):
         stdscr = self.stdscr
+        if not hasattr(stdscr, 'resize'):
+            raise unittest.SkipTest('requires curses.window.resize')
         box = curses.textpad.Textbox(stdscr, insert_mode=True)
         lines, cols = stdscr.getmaxyx()
         stdscr.resize(lines-2, cols-2)
index 20abe74bbc1bf18e80da58a388430f3b4deea15d..f56c3f5fe3de7b6dcd48347299ad6677ffe0c3d7 100644 (file)
@@ -492,6 +492,46 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
         self.assertEqual(str(t3), str(t4))
         self.assertEqual(t4.as_hours(), -1)
 
+    def test_issue31752(self):
+        # The interpreter shouldn't crash because divmod() returns negative
+        # remainder.
+        class BadInt(int):
+            def __mul__(self, other):
+                return Prod()
+
+        class BadLong(long):
+            def __mul__(self, other):
+                return Prod()
+
+        class Prod:
+            def __radd__(self, other):
+                return Sum()
+
+        class Sum(int):
+            def __divmod__(self, other):
+                # negative remainder
+                return (0, -1)
+
+        timedelta(microseconds=BadInt(1))
+        timedelta(hours=BadInt(1))
+        timedelta(weeks=BadInt(1))
+        timedelta(microseconds=BadLong(1))
+        timedelta(hours=BadLong(1))
+        timedelta(weeks=BadLong(1))
+
+        class Sum(long):
+            def __divmod__(self, other):
+                # negative remainder
+                return (0, -1)
+
+        timedelta(microseconds=BadInt(1))
+        timedelta(hours=BadInt(1))
+        timedelta(weeks=BadInt(1))
+        timedelta(microseconds=BadLong(1))
+        timedelta(hours=BadLong(1))
+        timedelta(weeks=BadLong(1))
+
+
 #############################################################################
 # date tests
 
index 6b2db34ef3319f50619e3a7459ad27f09f368fef..aacd4739ef3b6f77e40e7d343805830bcf49101a 100644 (file)
@@ -3,6 +3,7 @@ from test import test_support
 
 import UserDict, random, string
 import gc, weakref
+import sys
 
 
 class DictTest(unittest.TestCase):
@@ -422,6 +423,12 @@ class DictTest(unittest.TestCase):
         d = {1: BadRepr()}
         self.assertRaises(Exc, repr, d)
 
+    def test_repr_deep(self):
+        d = {}
+        for i in range(sys.getrecursionlimit() + 100):
+            d = {1: d}
+        self.assertRaises(RuntimeError, repr, d)
+
     def test_le(self):
         self.assertFalse({} < {})
         self.assertFalse({1: 2} < {1L: 2L})
index b585bdd90203eac8357ce3a561752aa863395ab1..1edeec55d0779110bfa167d4aa048150a0aadeff 100644 (file)
@@ -1,5 +1,6 @@
 import copy
 import pickle
+import sys
 import unittest
 import collections
 from test import test_support
@@ -169,6 +170,20 @@ class DictSetTest(unittest.TestCase):
     def test_recursive_repr(self):
         d = {}
         d[42] = d.viewvalues()
+        r = repr(d)
+        # Cannot perform a stronger test, as the contents of the repr
+        # are implementation-dependent.  All we can say is that we
+        # want a str result, not an exception of any sort.
+        self.assertIsInstance(r, str)
+        d[42] = d.viewitems()
+        r = repr(d)
+        # Again.
+        self.assertIsInstance(r, str)
+
+    def test_deeply_nested_repr(self):
+        d = {}
+        for i in range(sys.getrecursionlimit() + 100):
+            d = {42: d.viewvalues()}
         self.assertRaises(RuntimeError, repr, d)
 
     def test_abc_registry(self):
index 35f2c36ca70a322d6d5b6d872b87a6b53671a977..d8277b79b88052b2ad5878c74771c1c070eae820 100644 (file)
@@ -269,13 +269,33 @@ class TestOutputFormat(unittest.TestCase):
         self.assertEqual(fmt(3,6), '4,6')
         self.assertEqual(fmt(0,0), '0')
 
+class TestJunkAPIs(unittest.TestCase):
+    def test_is_line_junk_true(self):
+        for line in ['#', '  ', ' #', '# ', ' # ', '']:
+            self.assertTrue(difflib.IS_LINE_JUNK(line), repr(line))
+
+    def test_is_line_junk_false(self):
+        for line in ['##', ' ##', '## ', 'abc ', 'abc #', 'Mr. Moose is up!']:
+            self.assertFalse(difflib.IS_LINE_JUNK(line), repr(line))
+
+    def test_is_line_junk_REDOS(self):
+        evil_input = ('\t' * 1000000) + '##'
+        self.assertFalse(difflib.IS_LINE_JUNK(evil_input))
+
+    def test_is_character_junk_true(self):
+        for char in [' ', '\t']:
+            self.assertTrue(difflib.IS_CHARACTER_JUNK(char), repr(char))
+
+    def test_is_character_junk_false(self):
+        for char in ['a', '#', '\n', '\f', '\r', '\v']:
+            self.assertFalse(difflib.IS_CHARACTER_JUNK(char), repr(char))
 
 def test_main():
     difflib.HtmlDiff._default_prefix = 0
     Doctests = doctest.DocTestSuite(difflib)
     run_unittest(
         TestWithAscii, TestAutojunk, TestSFpatches, TestSFbugs,
-        TestOutputFormat, Doctests)
+        TestOutputFormat, TestJunkAPIs)
 
 if __name__ == '__main__':
     test_main()
index 3316fcfaa16d2654aa3ac73627f22695b6ab706b..cb9d10a10497fa4adbec52dba5c1981c93a1e6d1 100644 (file)
@@ -21,6 +21,7 @@ class EnsurepipMixin:
     def setUp(self):
         run_pip_patch = mock.patch("ensurepip._run_pip")
         self.run_pip = run_pip_patch.start()
+        self.run_pip.return_value = 0
         self.addCleanup(run_pip_patch.stop)
 
         # Avoid side effects on the actual os module
@@ -258,7 +259,7 @@ class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
         self.assertFalse(self.run_pip.called)
 
     def test_basic_bootstrapping(self):
-        ensurepip._main([])
+        exit_code = ensurepip._main([])
 
         self.run_pip.assert_called_once_with(
             [
@@ -270,6 +271,13 @@ class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
 
         additional_paths = self.run_pip.call_args[0][1]
         self.assertEqual(len(additional_paths), 2)
+        self.assertEqual(exit_code, 0)
+
+    def test_bootstrapping_error_code(self):
+        self.run_pip.return_value = 2
+        exit_code = ensurepip._main([])
+        self.assertEqual(exit_code, 2)
+
 
 
 class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
@@ -284,7 +292,7 @@ class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
 
     def test_basic_uninstall(self):
         with fake_pip():
-            ensurepip._uninstall._main([])
+            exit_code = ensurepip._uninstall._main([])
 
         self.run_pip.assert_called_once_with(
             [
@@ -293,6 +301,13 @@ class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
             ]
         )
 
+        self.assertEqual(exit_code, 0)
+
+    def test_uninstall_error_code(self):
+        with fake_pip():
+            self.run_pip.return_value = 2
+            exit_code = ensurepip._uninstall._main([])
+        self.assertEqual(exit_code, 2)
 
 if __name__ == "__main__":
     test.test_support.run_unittest(__name__)
index e39ef7042eae811708886dbbb5c75a25810f68c2..c73e8d8dc450e4202b87f749ba5301e9b9abcc11 100644 (file)
@@ -652,6 +652,33 @@ class FileThreadingTests(unittest.TestCase):
             self.f.writelines('')
         self._test_close_open_io(io_func)
 
+    def test_iteration_torture(self):
+        # bpo-31530
+        with open(self.filename, "wb") as fp:
+            for i in xrange(2**20):
+                fp.write(b"0"*50 + b"\n")
+        with open(self.filename, "rb") as f:
+            def it():
+                for l in f:
+                    pass
+            self._run_workers(it, 10)
+
+    def test_iteration_seek(self):
+        # bpo-31530: Crash when concurrently seek and iterate over a file.
+        with open(self.filename, "wb") as fp:
+            for i in xrange(10000):
+                fp.write(b"0"*50 + b"\n")
+        with open(self.filename, "rb") as f:
+            it = iter([1] + [0]*10)  # one thread reads, others seek
+            def iterate():
+                if next(it):
+                    for l in f:
+                        pass
+                else:
+                    for i in xrange(100):
+                        f.seek(i*100, 0)
+            self._run_workers(iterate, 10)
+
 
 @unittest.skipUnless(os.name == 'posix', 'test requires a posix system.')
 class TestFileSignalEINTR(unittest.TestCase):
index e6de3b0c11beb0a85c985d6d65b94f76fb8413b3..428623ebb35fa1998d09ed67e4781cf01f3ea578 100644 (file)
@@ -67,6 +67,16 @@ class FpformatTest(unittest.TestCase):
         else:
             self.fail("No exception on non-numeric sci")
 
+    def test_REDOS(self):
+        # This attack string will hang on the old decoder pattern.
+        attack = '+0' + ('0' * 1000000) + '++'
+        digs = 5 # irrelevant
+
+        # fix returns input if it does not decode
+        self.assertEqual(fpformat.fix(attack, digs), attack)
+        # sci raises NotANumber
+        with self.assertRaises(NotANumber):
+            fpformat.sci(attack, digs)
 
 def test_main():
     run_unittest(FpformatTest)
index fdfa31387cb4b999c1dfe09e50095d3e6d2c84ca..e728aa70f9ea5043ec8a852a1b40194c8a9039f7 100644 (file)
@@ -710,11 +710,11 @@ class TestTLS_FTPClass(TestCase):
             self.client.auth()
             self.assertRaises(ValueError, self.client.auth)
         finally:
-            self.client.ssl_version = ssl.PROTOCOL_TLSv1
+            self.client.ssl_version = ssl.PROTOCOL_TLS
 
     def test_context(self):
         self.client.quit()
-        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
         self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
                           context=ctx)
         self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
@@ -739,7 +739,7 @@ class TestTLS_FTPClass(TestCase):
 
     def test_check_hostname(self):
         self.client.quit()
-        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
         ctx.verify_mode = ssl.CERT_REQUIRED
         ctx.check_hostname = True
         ctx.load_verify_locations(CAFILE)
index 62d60296bcb5a55f58b9699f68665ce77d724935..2847573035f85a013f3d5015242c2b94a54e8dc1 100644 (file)
@@ -600,6 +600,67 @@ class TestTotalOrdering(unittest.TestCase):
         with self.assertRaises(TypeError):
             TestTO(8) <= ()
 
+    def test_bug_25732(self):
+        @functools.total_ordering
+        class A:
+            def __init__(self, value):
+                self.value = value
+            def __gt__(self, other):
+                return self.value > other.value
+            def __eq__(self, other):
+                return self.value == other.value
+            def __hash__(self):
+                return hash(self.value)
+        self.assertTrue(A(1) != A(2))
+        self.assertFalse(A(1) != A(1))
+
+        @functools.total_ordering
+        class A(object):
+            def __init__(self, value):
+                self.value = value
+            def __gt__(self, other):
+                return self.value > other.value
+            def __eq__(self, other):
+                return self.value == other.value
+            def __hash__(self):
+                return hash(self.value)
+        self.assertTrue(A(1) != A(2))
+        self.assertFalse(A(1) != A(1))
+
+        @functools.total_ordering
+        class A:
+            def __init__(self, value):
+                self.value = value
+            def __gt__(self, other):
+                return self.value > other.value
+            def __eq__(self, other):
+                return self.value == other.value
+            def __ne__(self, other):
+                raise RuntimeError(self, other)
+            def __hash__(self):
+                return hash(self.value)
+        with self.assertRaises(RuntimeError):
+            A(1) != A(2)
+        with self.assertRaises(RuntimeError):
+            A(1) != A(1)
+
+        @functools.total_ordering
+        class A(object):
+            def __init__(self, value):
+                self.value = value
+            def __gt__(self, other):
+                return self.value > other.value
+            def __eq__(self, other):
+                return self.value == other.value
+            def __ne__(self, other):
+                raise RuntimeError(self, other)
+            def __hash__(self):
+                return hash(self.value)
+        with self.assertRaises(RuntimeError):
+            A(1) != A(2)
+        with self.assertRaises(RuntimeError):
+            A(1) != A(1)
+
 def test_main(verbose=None):
     test_classes = (
         TestPartial,
index ed01c9802fc1ee5db1fe9dbed4d3ac260719f78d..7e47b2d3a27baef1f86aa59874b5621b05cb3ef6 100644 (file)
@@ -1,5 +1,6 @@
 import unittest
-from test.test_support import verbose, run_unittest, start_threads
+from test.support import (verbose, run_unittest, start_threads,
+                          requires_type_collecting)
 import sys
 import time
 import gc
@@ -90,6 +91,7 @@ class GCTests(unittest.TestCase):
         del a
         self.assertNotEqual(gc.collect(), 0)
 
+    @requires_type_collecting
     def test_newinstance(self):
         class A(object):
             pass
index 5e1a3e52d5087a3ddbed45355f460b32f25f2c61..0f7bf19abb8caa5d48e2db7e596d8a8601d7b2f5 100644 (file)
@@ -1524,13 +1524,7 @@ Yield by itself yields None:
 [None]
 
 
-
-An obscene abuse of a yield expression within a generator expression:
-
->>> list((yield 21) for i in range(4))
-[21, None, 21, None, 21, None, 21, None]
-
-And a more sane, but still weird usage:
+Yield is allowed only in the outermost iterable in generator expression:
 
 >>> def f(): list(i for i in [(yield 26)])
 >>> type(f())
@@ -1571,7 +1565,7 @@ SyntaxError: 'yield' outside function
 >>> def f(): return lambda x=(yield): 1
 Traceback (most recent call last):
   ...
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[21]>, line 1)
 
 >>> def f(): x = yield = y
 Traceback (most recent call last):
@@ -1784,7 +1778,7 @@ enclosing function a generator:
 >>> type(f())
 <type 'generator'>
 
->>> def f(): x=(i for i in (yield) if (yield))
+>>> def f(): x=(i for i in (yield) if i)
 >>> type(f())
 <type 'generator'>
 
index b360d09dfa6de96eb39278f13c0b23c7762a83b3..84b2e7ddd258d8cbc6abf5f060d45efd66290f26 100644 (file)
@@ -49,10 +49,10 @@ class GlobTests(unittest.TestCase):
             pattern = os.path.join(*parts)
         p = os.path.join(self.tempdir, pattern)
         res = glob.glob(p)
-        self.assertEqual(list(glob.iglob(p)), res)
+        self.assertItemsEqual(glob.iglob(p), res)
         ures = [fsdecode(x) for x in res]
-        self.assertEqual(glob.glob(fsdecode(p)), ures)
-        self.assertEqual(list(glob.iglob(fsdecode(p))), ures)
+        self.assertItemsEqual(glob.glob(fsdecode(p)), ures)
+        self.assertItemsEqual(glob.iglob(fsdecode(p)), ures)
         return res
 
     def assertSequencesEqual_noorder(self, l1, l2):
index 5f77c1d018bfb36b3fdc68d72f438d6ba969d8b5..23b6ce8d3c5c5d6f4feca7e0e225704f1e4d6847 100644 (file)
@@ -11,7 +11,7 @@ from sys import *
 
 class TokenTests(unittest.TestCase):
 
-    def testBackslash(self):
+    def test_backslash(self):
         # Backslash means line continuation:
         x = 1 \
         + 1
@@ -21,29 +21,42 @@ class TokenTests(unittest.TestCase):
         x = 0
         self.assertEqual(x, 0, 'backslash ending comment')
 
-    def testPlainIntegers(self):
+    def test_plain_integers(self):
+        self.assertEqual(type(000), type(0))
         self.assertEqual(0xff, 255)
         self.assertEqual(0377, 255)
+        self.assertEqual(0o377, 255)
         self.assertEqual(2147483647, 017777777777)
+        self.assertEqual(2147483647, 0o17777777777)
+        self.assertEqual(0b1001, 9)
         # "0x" is not a valid literal
         self.assertRaises(SyntaxError, eval, "0x")
         from sys import maxint
         if maxint == 2147483647:
-            self.assertEqual(-2147483647-1, -020000000000)
+            self.assertEqual(-2147483647-1, -0o20000000000)
             # XXX -2147483648
             self.assertTrue(037777777777 > 0)
+            self.assertTrue(0o37777777777 > 0)
             self.assertTrue(0xffffffff > 0)
-            for s in '2147483648', '040000000000', '0x100000000':
+            self.assertTrue(0b1111111111111111111111111111111 > 0)
+            for s in ('2147483648', '040000000000', '0o40000000000',
+                      '0x100000000',
+                      '0b10000000000000000000000000000000'):
                 try:
                     x = eval(s)
                 except OverflowError:
                     self.fail("OverflowError on huge integer literal %r" % s)
         elif maxint == 9223372036854775807:
             self.assertEqual(-9223372036854775807-1, -01000000000000000000000)
+            self.assertEqual(-9223372036854775807-1, -0o1000000000000000000000)
             self.assertTrue(01777777777777777777777 > 0)
+            self.assertTrue(0o1777777777777777777777 > 0)
             self.assertTrue(0xffffffffffffffff > 0)
+            self.assertTrue(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
             for s in '9223372036854775808', '02000000000000000000000', \
-                     '0x10000000000000000':
+                     '0o2000000000000000000000', \
+                     '0x10000000000000000', \
+                     '0b100000000000000000000000000000000000000000000000000000000000000':
                 try:
                     x = eval(s)
                 except OverflowError:
@@ -51,7 +64,7 @@ class TokenTests(unittest.TestCase):
         else:
             self.fail('Weird maxint value %r' % maxint)
 
-    def testLongIntegers(self):
+    def test_long_integers(self):
         x = 0L
         x = 0l
         x = 0xffffffffffffffffL
@@ -61,7 +74,7 @@ class TokenTests(unittest.TestCase):
         x = 123456789012345678901234567890L
         x = 123456789012345678901234567890l
 
-    def testFloats(self):
+    def test_floats(self):
         x = 3.14
         x = 314.
         x = 0.314
@@ -81,7 +94,7 @@ class TokenTests(unittest.TestCase):
         self.assertEqual(1 if 0else 0, 0)
         self.assertRaises(SyntaxError, eval, "0 if 1Else 0")
 
-    def testStringLiterals(self):
+    def test_string_literals(self):
         x = ''; y = ""; self.assertTrue(len(x) == 0 and x == y)
         x = '\''; y = "'"; self.assertTrue(len(x) == 1 and x == y and ord(x) == 39)
         x = '"'; y = "\""; self.assertTrue(len(x) == 1 and x == y and ord(x) == 34)
@@ -133,11 +146,11 @@ class GrammarTests(unittest.TestCase):
     # expr_input: testlist NEWLINE
     # XXX Hard to test -- used only in calls to input()
 
-    def testEvalInput(self):
+    def test_eval_input(self):
         # testlist ENDMARKER
         x = eval('1, 0 or 1')
 
-    def testFuncdef(self):
+    def test_funcdef(self):
         ### 'def' NAME parameters ':' suite
         ### parameters: '(' [varargslist] ')'
         ### varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
@@ -153,9 +166,10 @@ class GrammarTests(unittest.TestCase):
         f1(*(), **{})
         def f2(one_argument): pass
         def f3(two, arguments): pass
-        # Silence Py3k warning
-        exec('def f4(two, (compound, (argument, list))): pass')
-        exec('def f5((compound, first), two): pass')
+        with check_py3k_warnings(('tuple parameter unpacking has been removed',
+                                  SyntaxWarning)):
+            exec('def f4(two, (compound, (argument, list))): pass')
+            exec('def f5((compound, first), two): pass')
         self.assertEqual(f2.func_code.co_varnames, ('one_argument',))
         self.assertEqual(f3.func_code.co_varnames, ('two', 'arguments'))
         if sys.platform.startswith('java'):
@@ -174,8 +188,9 @@ class GrammarTests(unittest.TestCase):
         def v0(*rest): pass
         def v1(a, *rest): pass
         def v2(a, b, *rest): pass
-        # Silence Py3k warning
-        exec('def v3(a, (b, c), *rest): return a, b, c, rest')
+        with check_py3k_warnings(('tuple parameter unpacking has been removed',
+                                  SyntaxWarning)):
+            exec('def v3(a, (b, c), *rest): return a, b, c, rest')
 
         f1()
         f2(1)
@@ -212,7 +227,9 @@ class GrammarTests(unittest.TestCase):
         d01()
         d01(1)
         d01(*(1,))
+        d01(*[] or [2])
         d01(**{'a':2})
+        d01(**{'a':2} or {})
         def d11(a, b=1): pass
         d11(1)
         d11(1, 2)
@@ -280,9 +297,12 @@ class GrammarTests(unittest.TestCase):
         d22v(*(1, 2, 3, 4))
         d22v(1, 2, *(3, 4, 5))
         d22v(1, *(2, 3), **{'d': 4})
-        # Silence Py3k warning
-        exec('def d31v((x)): pass')
-        exec('def d32v((x,)): pass')
+        with check_py3k_warnings(('parenthesized argument names are invalid',
+                                  SyntaxWarning)):
+            exec('def d31v((x)): pass')
+        with check_py3k_warnings(('tuple parameter unpacking has been removed',
+                                  SyntaxWarning)):
+            exec('def d32v((x,)): pass')
         d31v(1)
         d32v((1,))
 
@@ -293,12 +313,19 @@ class GrammarTests(unittest.TestCase):
                                                     {'x':2, 'y':5}))
         self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
         self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
+        self.assertEqual(f(**{'eggs':'scrambled', 'spam':'fried'}),
+                         ((), {'eggs':'scrambled', 'spam':'fried'}))
+        self.assertEqual(f(spam='fried', **{'eggs':'scrambled'}),
+                         ((), {'eggs':'scrambled', 'spam':'fried'}))
 
         # Check ast errors in *args and *kwargs
         check_syntax_error(self, "f(*g(1=2))")
         check_syntax_error(self, "f(**g(1=2))")
 
-    def testLambdef(self):
+        # Check trailing commas are permitted in funcdef argument list
+        def f(a,): pass
+
+    def test_lambdef(self):
         ### lambdef: 'lambda' [varargslist] ':' test
         l1 = lambda : 0
         self.assertEqual(l1(), 0)
@@ -311,12 +338,18 @@ class GrammarTests(unittest.TestCase):
         self.assertEqual(l5(1, 2), 5)
         self.assertEqual(l5(1, 2, 3), 6)
         check_syntax_error(self, "lambda x: x = 2")
-        check_syntax_error(self, "lambda (None,): None")
+        with check_py3k_warnings(('tuple parameter unpacking has been removed',
+                                  SyntaxWarning)):
+            check_syntax_error(self, "lambda (None,): None")
+
+        # check that trailing commas are permitted
+        l10 = lambda a,: 0
+
 
     ### stmt: simple_stmt | compound_stmt
     # Tested below
 
-    def testSimpleStmt(self):
+    def test_simple_stmt(self):
         ### simple_stmt: small_stmt (';' small_stmt)* [';']
         x = 1; pass; del x
         def foo():
@@ -327,7 +360,7 @@ class GrammarTests(unittest.TestCase):
     ### small_stmt: expr_stmt | print_stmt  | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
     # Tested below
 
-    def testExprStmt(self):
+    def test_expr_stmt(self):
         # (exprlist '=')* exprlist
         1
         1, 2, 3
@@ -340,7 +373,7 @@ class GrammarTests(unittest.TestCase):
         check_syntax_error(self, "x + 1 = 1")
         check_syntax_error(self, "a + 1 = b + 2")
 
-    def testPrintStmt(self):
+    def test_print_stmt(self):
         # 'print' (test ',')* [test]
         import StringIO
 
@@ -410,7 +443,7 @@ hello world
         check_syntax_error(self, 'print ,')
         check_syntax_error(self, 'print >> x,')
 
-    def testDelStmt(self):
+    def test_del_stmt(self):
         # 'del' exprlist
         abc = [1,2,3]
         x, y, z = abc
@@ -419,18 +452,18 @@ hello world
         del abc
         del x, y, (z, xyz)
 
-    def testPassStmt(self):
+    def test_pass_stmt(self):
         # 'pass'
         pass
 
     # flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt
     # Tested below
 
-    def testBreakStmt(self):
+    def test_break_stmt(self):
         # 'break'
         while 1: break
 
-    def testContinueStmt(self):
+    def test_continue_stmt(self):
         # 'continue'
         i = 1
         while i: i = 0; continue
@@ -482,7 +515,7 @@ hello world
                 self.fail("continue then break in try/except in loop broken!")
         test_inner()
 
-    def testReturn(self):
+    def test_return(self):
         # 'return' [testlist]
         def g1(): return
         def g2(): return 1
@@ -490,17 +523,151 @@ hello world
         x = g2()
         check_syntax_error(self, "class foo:return 1")
 
-    def testYield(self):
-        check_syntax_error(self, "class foo:yield 1")
+    def test_break_in_finally(self):
+        count = 0
+        while count < 2:
+            count += 1
+            try:
+                pass
+            finally:
+                break
+        self.assertEqual(count, 1)
 
-    def testRaise(self):
+        count = 0
+        while count < 2:
+            count += 1
+            try:
+                continue
+            finally:
+                break
+        self.assertEqual(count, 1)
+
+        count = 0
+        while count < 2:
+            count += 1
+            try:
+                1.0/0.0
+            finally:
+                break
+        self.assertEqual(count, 1)
+
+        for count in [0, 1]:
+            self.assertEqual(count, 0)
+            try:
+                pass
+            finally:
+                break
+        self.assertEqual(count, 0)
+
+        for count in [0, 1]:
+            self.assertEqual(count, 0)
+            try:
+                continue
+            finally:
+                break
+        self.assertEqual(count, 0)
+
+        for count in [0, 1]:
+            self.assertEqual(count, 0)
+            try:
+                1.0/0.0
+            finally:
+                break
+        self.assertEqual(count, 0)
+
+    def test_return_in_finally(self):
+        def g1():
+            try:
+                pass
+            finally:
+                return 1
+        self.assertEqual(g1(), 1)
+
+        def g2():
+            try:
+                return 2
+            finally:
+                return 3
+        self.assertEqual(g2(), 3)
+
+        def g3():
+            try:
+                1.0/0.0
+            finally:
+                return 4
+        self.assertEqual(g3(), 4)
+
+    def test_yield(self):
+        # Allowed as standalone statement
+        def g(): yield 1
+        # Allowed as RHS of assignment
+        def g(): x = yield 1
+        # Ordinary yield accepts implicit tuples
+        def g(): yield 1, 1
+        def g(): x = yield 1, 1
+        # Requires parentheses as subexpression
+        def g(): 1, (yield 1)
+        check_syntax_error(self, "def g(): 1, yield 1")
+        # Requires parentheses as call argument
+        def g(): f((yield 1))
+        def g(): f((yield 1), 1)
+        check_syntax_error(self, "def g(): f(yield 1)")
+        check_syntax_error(self, "def g(): f(yield 1, 1)")
+        # Not allowed at top level
+        check_syntax_error(self, "yield")
+        # Not allowed at class scope
+        check_syntax_error(self, "class foo:yield 1")
+        # Check annotation refleak on SyntaxError
+        check_syntax_error(self, "def g(a:(yield)): pass")
+
+    def test_yield_in_comprehensions(self):
+        # Check yield in comprehensions
+        def g(): [x for x in [(yield 1)]]
+
+        def check(code, warntext):
+            with check_py3k_warnings((warntext, DeprecationWarning)):
+                compile(code, '<test string>', 'exec')
+            if sys.py3kwarning:
+                import warnings
+                with warnings.catch_warnings():
+                    warnings.filterwarnings('error', category=DeprecationWarning)
+                    with self.assertRaises(SyntaxError) as cm:
+                        compile(code, '<test string>', 'exec')
+                    self.assertIn(warntext, str(cm.exception))
+
+        check("def g(): [(yield x) for x in ()]",
+              "'yield' inside list comprehension")
+        check("def g(): [x for x in () if not (yield x)]",
+              "'yield' inside list comprehension")
+        check("def g(): [y for x in () for y in [(yield x)]]",
+              "'yield' inside list comprehension")
+        check("def g(): {(yield x) for x in ()}",
+              "'yield' inside set comprehension")
+        check("def g(): {(yield x): x for x in ()}",
+              "'yield' inside dict comprehension")
+        check("def g(): {x: (yield x) for x in ()}",
+              "'yield' inside dict comprehension")
+        check("def g(): ((yield x) for x in ())",
+              "'yield' inside generator expression")
+        with check_py3k_warnings(("'yield' inside list comprehension",
+                                  DeprecationWarning)):
+            check_syntax_error(self, "class C: [(yield x) for x in ()]")
+        check("class C: ((yield x) for x in ())",
+              "'yield' inside generator expression")
+        with check_py3k_warnings(("'yield' inside list comprehension",
+                                  DeprecationWarning)):
+            check_syntax_error(self, "[(yield x) for x in ()]")
+        check("((yield x) for x in ())",
+              "'yield' inside generator expression")
+
+    def test_raise(self):
         # 'raise' test [',' test]
         try: raise RuntimeError, 'just testing'
         except RuntimeError: pass
         try: raise KeyboardInterrupt
         except KeyboardInterrupt: pass
 
-    def testImport(self):
+    def test_import(self):
         # 'import' dotted_as_names
         import sys
         import time, sys
@@ -513,13 +680,13 @@ hello world
         from sys import (path, argv)
         from sys import (path, argv,)
 
-    def testGlobal(self):
+    def test_global(self):
         # 'global' NAME (',' NAME)*
         global a
         global a, b
         global one, two, three, four, five, six, seven, eight, nine, ten
 
-    def testExec(self):
+    def test_exec(self):
         # 'exec' expr ['in' expr [',' expr]]
         z = None
         del z
@@ -551,7 +718,7 @@ hello world
         if (g, l) != ({'a':1}, {'b':2}):
             self.fail('exec ... in g (%s), l (%s)' %(g,l))
 
-    def testAssert(self):
+    def test_assert(self):
         # assertTruestmt: 'assert' test [',' test]
         assert 1
         assert 1, 1
@@ -590,7 +757,7 @@ hello world
     ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
     # Tested below
 
-    def testIf(self):
+    def test_if(self):
         # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
         if 1: pass
         if 1: pass
@@ -603,7 +770,7 @@ hello world
         elif 0: pass
         else: pass
 
-    def testWhile(self):
+    def test_while(self):
         # 'while' test ':' suite ['else' ':' suite]
         while 0: pass
         while 0: pass
@@ -618,7 +785,7 @@ hello world
             x = 2
         self.assertEqual(x, 2)
 
-    def testFor(self):
+    def test_for(self):
         # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]
         for i in 1, 2, 3: pass
         for i, j, k in (): pass
@@ -645,30 +812,30 @@ hello world
             result.append(x)
         self.assertEqual(result, [1, 2, 3])
 
-    def testTry(self):
+    def test_try(self):
         ### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
         ###         | 'try' ':' suite 'finally' ':' suite
         ### except_clause: 'except' [expr [('as' | ',') expr]]
         try:
-            1/0
+            1/0.0
         except ZeroDivisionError:
             pass
         else:
             pass
-        try: 1/0
+        try: 1/0.0
         except EOFError: pass
         except TypeError as msg: pass
         except RuntimeError, msg: pass
         except: pass
         else: pass
-        try: 1/0
+        try: 1/0.0
         except (EOFError, TypeError, ZeroDivisionError): pass
-        try: 1/0
+        try: 1/0.0
         except (EOFError, TypeError, ZeroDivisionError), msg: pass
         try: pass
         finally: pass
 
-    def testSuite(self):
+    def test_suite(self):
         # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
         if 1: pass
         if 1:
@@ -683,7 +850,7 @@ hello world
             pass
             #
 
-    def testTest(self):
+    def test_test(self):
         ### and_test ('or' and_test)*
         ### and_test: not_test ('and' not_test)*
         ### not_test: 'not' not_test | comparison
@@ -694,7 +861,7 @@ hello world
         if not 1 and 1 and 1: pass
         if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass
 
-    def testComparison(self):
+    def test_comparison(self):
         ### comparison: expr (comp_op expr)*
         ### comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
         if 1: pass
@@ -710,40 +877,49 @@ hello world
         if 1 in (): pass
         if 1 not in (): pass
         if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
-        # Silence Py3k warning
-        if eval('1 <> 1'): pass
-        if eval('1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1'): pass
-
-    def testBinaryMaskOps(self):
+        with check_py3k_warnings(('<> not supported in 3.x; use !=',
+                                  DeprecationWarning)):
+            if eval('1 <> 1'): pass
+        with check_py3k_warnings(('<> not supported in 3.x; use !=',
+                                  DeprecationWarning)):
+            if eval('1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1'): pass
+
+    def test_binary_mask_ops(self):
         x = 1 & 1
         x = 1 ^ 1
         x = 1 | 1
 
-    def testShiftOps(self):
+    def test_shift_ops(self):
         x = 1 << 1
         x = 1 >> 1
         x = 1 << 1 >> 1
 
-    def testAdditiveOps(self):
+    def test_additive_ops(self):
         x = 1
         x = 1 + 1
         x = 1 - 1 - 1
         x = 1 - 1 + 1 - 1 + 1
 
-    def testMultiplicativeOps(self):
+    def test_multiplicative_ops(self):
         x = 1 * 1
-        x = 1 / 1
+        with check_py3k_warnings(('classic int division', DeprecationWarning)):
+            x = 1 / 1
+        x = 1 / 1.0
         x = 1 % 1
-        x = 1 / 1 * 1 % 1
+        with check_py3k_warnings(('classic int division', DeprecationWarning)):
+            x = 1 / 1 * 1 % 1
+        x = 1 / 1.0 * 1 % 1
 
-    def testUnaryOps(self):
+    def test_unary_ops(self):
         x = +1
         x = -1
         x = ~1
         x = ~1 ^ 1 & 1 | 1 & 1 ^ -1
-        x = -1*1/1 + 1*1 - ---1*1
+        with check_py3k_warnings(('classic int division', DeprecationWarning)):
+            x = -1*1/1 + 1*1 - ---1*1
+        x = -1*1/1.0 + 1*1 - ---1*1
 
-    def testSelectors(self):
+    def test_selectors(self):
         ### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME
         ### subscript: expr | [expr] ':' [expr]
 
@@ -770,10 +946,10 @@ hello world
         d[1,2] = 3
         d[1,2,3] = 4
         L = list(d)
-        L.sort()
+        L.sort(key=lambda x: (type(x).__name__, x))
         self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
 
-    def testAtoms(self):
+    def test_atoms(self):
         ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
         ### dictorsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [','])
 
@@ -800,10 +976,10 @@ hello world
         x = {'one', 'two', 'three'}
         x = {2, 3, 4,}
 
-        # Silence Py3k warning
-        x = eval('`x`')
-        x = eval('`1 or 2 or 3`')
-        self.assertEqual(eval('`1,2`'), '(1, 2)')
+        with check_py3k_warnings(('backquote not supported', SyntaxWarning)):
+            x = eval('`x`')
+            x = eval('`1 or 2 or 3`')
+            self.assertEqual(eval('`1,2`'), '(1, 2)')
 
         x = x
         x = 'x'
@@ -813,7 +989,7 @@ hello world
     ### testlist: test (',' test)* [',']
     # These have been exercised enough above
 
-    def testClassdef(self):
+    def test_classdef(self):
         # 'class' NAME ['(' [testlist] ')'] ':' suite
         class B: pass
         class B2(): pass
@@ -824,6 +1000,7 @@ hello world
             def meth1(self): pass
             def meth2(self, arg): pass
             def meth3(self, a1, a2): pass
+
         # decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
         # decorators: decorator+
         # decorated: decorators (classdef | funcdef)
@@ -835,14 +1012,14 @@ hello world
             pass
         self.assertEqual(G.decorated, True)
 
-    def testDictcomps(self):
+    def test_dictcomps(self):
         # dictorsetmaker: ( (test ':' test (comp_for |
         #                                   (',' test ':' test)* [','])) |
         #                   (test (comp_for | (',' test)* [','])) )
         nums = [1, 2, 3]
         self.assertEqual({i:i+1 for i in nums}, {1: 2, 2: 3, 3: 4})
 
-    def testListcomps(self):
+    def test_listcomps(self):
         # list comprehension tests
         nums = [1, 2, 3, 4, 5]
         strs = ["Apple", "Banana", "Coconut"]
@@ -865,7 +1042,7 @@ hello world
                          [[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]])
 
         def test_in_func(l):
-            return [None < x < 3 for x in l if x > 2]
+            return [0 < x < 3 for x in l if x > 2]
 
         self.assertEqual(test_in_func(nums), [False, False, False])
 
@@ -905,7 +1082,7 @@ hello world
         self.assertEqual(x, [('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'),
                              ('Macdonalds', 'Cheeseburger')])
 
-    def testGenexps(self):
+    def test_genexps(self):
         # generator expression tests
         g = ([x for x in range(10)] for x in range(1))
         self.assertEqual(g.next(), [x for x in range(10)])
@@ -940,7 +1117,7 @@ hello world
         check_syntax_error(self, "foo(x for x in range(10), 100)")
         check_syntax_error(self, "foo(100, x for x in range(10))")
 
-    def testComprehensionSpecials(self):
+    def test_comprehension_specials(self):
         # test for outmost iterable precomputation
         x = 10; g = (i for i in range(x)); x = 5
         self.assertEqual(len(list(g)), 10)
@@ -979,11 +1156,11 @@ hello world
         with manager() as x, manager():
             pass
 
-    def testIfElseExpr(self):
+    def test_if_else_expr(self):
         # Test ifelse expressions in various cases
         def _checkeval(msg, ret):
             "helper to check that evaluation of expressions is done correctly"
-            print x
+            print(msg)
             return ret
 
         self.assertEqual([ x() for x in lambda: True, lambda: False if x() ], [True])
@@ -1002,7 +1179,8 @@ hello world
         self.assertEqual((6 + 1 if 1 else 2), 7)
         self.assertEqual((6 - 1 if 1 else 2), 5)
         self.assertEqual((6 * 2 if 1 else 4), 12)
-        self.assertEqual((6 / 2 if 1 else 3), 3)
+        with check_py3k_warnings(('classic int division', DeprecationWarning)):
+            self.assertEqual((6 / 2 if 1 else 3), 3)
         self.assertEqual((6 < 4 if 0 else 2), 2)
 
     def test_paren_evaluation(self):
@@ -1015,13 +1193,7 @@ hello world
 
 
 def test_main():
-    with check_py3k_warnings(
-            ("backquote not supported", SyntaxWarning),
-            ("tuple parameter unpacking has been removed", SyntaxWarning),
-            ("parenthesized argument names are invalid", SyntaxWarning),
-            ("classic int division", DeprecationWarning),
-            (".+ not supported in 3.x", DeprecationWarning)):
-        run_unittest(TokenTests, GrammarTests)
+    run_unittest(TokenTests, GrammarTests)
 
 if __name__ == '__main__':
     test_main()
index 5025b91d343aa6cf6ad8e3181b1af60edf1e0460..902d93fe043f8e42d2c393407a536a198703f7fe 100644 (file)
@@ -331,6 +331,26 @@ class TestGzip(unittest.TestCase):
             with gzip.GzipFile(fileobj=f, mode="w") as g:
                 self.assertEqual(g.name, "")
 
+    def test_fileobj_mode(self):
+        gzip.GzipFile(self.filename, "wb").close()
+        with open(self.filename, "r+b") as f:
+            with gzip.GzipFile(fileobj=f, mode='r') as g:
+                self.assertEqual(g.mode, gzip.READ)
+            with gzip.GzipFile(fileobj=f, mode='w') as g:
+                self.assertEqual(g.mode, gzip.WRITE)
+            with gzip.GzipFile(fileobj=f, mode='a') as g:
+                self.assertEqual(g.mode, gzip.WRITE)
+            with self.assertRaises(IOError):
+                gzip.GzipFile(fileobj=f, mode='z')
+        for mode in "rb", "r+b":
+            with open(self.filename, mode) as f:
+                with gzip.GzipFile(fileobj=f) as g:
+                    self.assertEqual(g.mode, gzip.READ)
+        for mode in "wb", "ab":
+            with open(self.filename, mode) as f:
+                with gzip.GzipFile(fileobj=f) as g:
+                    self.assertEqual(g.mode, gzip.WRITE)
+
     def test_read_with_extra(self):
         # Gzip data with an extra field
         gzdata = (b'\x1f\x8b\x08\x04\xb2\x17cQ\x02\xff'
index 7e8b058e8b0f6e18e78fb606d0ea2c404c56383b..44ffac7036886e212d19cbd95f24f4808259d82d 100644 (file)
@@ -860,7 +860,7 @@ class HTTPSTest(TestCase):
         import ssl
         test_support.requires('network')
         with test_support.transient_internet('self-signed.pythontest.net'):
-            context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
             context.verify_mode = ssl.CERT_REQUIRED
             context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
             h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
@@ -874,7 +874,7 @@ class HTTPSTest(TestCase):
         import ssl
         test_support.requires('network')
         with test_support.transient_internet('self-signed.pythontest.net'):
-            context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
             context.verify_mode = ssl.CERT_REQUIRED
             context.load_verify_locations(CERT_localhost)
             h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
@@ -895,7 +895,7 @@ class HTTPSTest(TestCase):
         # The (valid) cert validates the HTTP hostname
         import ssl
         server = self.make_server(CERT_localhost)
-        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        context = ssl.SSLContext(ssl.PROTOCOL_TLS)
         context.verify_mode = ssl.CERT_REQUIRED
         context.load_verify_locations(CERT_localhost)
         h = httplib.HTTPSConnection('localhost', server.port, context=context)
@@ -907,7 +907,7 @@ class HTTPSTest(TestCase):
         # The (valid) cert doesn't validate the HTTP hostname
         import ssl
         server = self.make_server(CERT_fakehostname)
-        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        context = ssl.SSLContext(ssl.PROTOCOL_TLS)
         context.verify_mode = ssl.CERT_REQUIRED
         context.check_hostname = True
         context.load_verify_locations(CERT_fakehostname)
index caca0333e0d82f9447542aab49c8bfd345f5d6e3..ea5ec656f755b31b600874319bdee89ab4cba5cb 100644 (file)
@@ -2666,6 +2666,22 @@ class TextIOWrapperTest(unittest.TestCase):
         t = self.TextIOWrapper(NonbytesStream('a'))
         self.assertEqual(t.read(), u'a')
 
+    def test_illegal_encoder(self):
+        # bpo-31271: A TypeError should be raised in case the return value of
+        # encoder's encode() is invalid.
+        class BadEncoder:
+            def encode(self, dummy):
+                return u'spam'
+        def get_bad_encoder(dummy):
+            return BadEncoder()
+        rot13 = codecs.lookup("rot13")
+        with support.swap_attr(rot13, '_is_text_encoding', True), \
+             support.swap_attr(rot13, 'incrementalencoder', get_bad_encoder):
+            t = io.TextIOWrapper(io.BytesIO(b'foo'), encoding="rot13")
+        with self.assertRaises(TypeError):
+            t.write('bar')
+            t.flush()
+
     def test_illegal_decoder(self):
         # Issue #17106
         # Bypass the early encoding check added in issue 20404
@@ -2702,6 +2718,26 @@ class TextIOWrapperTest(unittest.TestCase):
             #t = _make_illegal_wrapper()
             #self.assertRaises(TypeError, t.read)
 
+        # Issue 31243: calling read() while the return value of decoder's
+        # getstate() is invalid should neither crash the interpreter nor
+        # raise a SystemError.
+        def _make_very_illegal_wrapper(getstate_ret_val):
+            class BadDecoder:
+                def getstate(self):
+                    return getstate_ret_val
+            def _get_bad_decoder(dummy):
+                return BadDecoder()
+            quopri = codecs.lookup("quopri_codec")
+            with support.swap_attr(quopri, 'incrementaldecoder',
+                                   _get_bad_decoder):
+                return _make_illegal_wrapper()
+        t = _make_very_illegal_wrapper(42)
+        with self.maybeRaises(TypeError):
+            t.read(42)
+        t = _make_very_illegal_wrapper(())
+        with self.maybeRaises(TypeError):
+            t.read(42)
+
 
 class CTextIOWrapperTest(TextIOWrapperTest):
 
index 7b2362d29e9bcfa672d27554b0488b79a8fe6436..04279792065edfae8c69605f1779b45339960baa 100644 (file)
@@ -802,6 +802,7 @@ class TestBasicOps(unittest.TestCase):
                 (10, 20, 3),
                 (10, 3, 20),
                 (10, 20),
+                (10, 10),
                 (10, 3),
                 (20,)
                 ]:
@@ -826,6 +827,10 @@ class TestBasicOps(unittest.TestCase):
         self.assertEqual(list(islice(it, 3)), range(3))
         self.assertEqual(list(it), range(3, 10))
 
+        it = iter(range(10))
+        self.assertEqual(list(islice(it, 3, 3)), [])
+        self.assertEqual(list(it), range(3, 10))
+
         # Test invalid arguments
         self.assertRaises(TypeError, islice, xrange(10))
         self.assertRaises(TypeError, islice, xrange(10), 1, 2, 3, 4)
@@ -1084,6 +1089,48 @@ class TestExamples(unittest.TestCase):
         self.assertEqual(list(takewhile(lambda x: x<5, [1,4,6,4,1])), [1,4])
 
 
+class TestPurePythonRoughEquivalents(unittest.TestCase):
+
+    @staticmethod
+    def islice(iterable, *args):
+        s = slice(*args)
+        start, stop, step = s.start or 0, s.stop or sys.maxint, s.step or 1
+        it = iter(xrange(start, stop, step))
+        try:
+            nexti = next(it)
+        except StopIteration:
+            # Consume *iterable* up to the *start* position.
+            for i, element in izip(xrange(start), iterable):
+                pass
+            return
+        try:
+            for i, element in enumerate(iterable):
+                if i == nexti:
+                    yield element
+                    nexti = next(it)
+        except StopIteration:
+            # Consume to *stop*.
+            for i, element in izip(xrange(i + 1, stop), iterable):
+                pass
+
+    def test_islice_recipe(self):
+        self.assertEqual(list(self.islice('ABCDEFG', 2)), list('AB'))
+        self.assertEqual(list(self.islice('ABCDEFG', 2, 4)), list('CD'))
+        self.assertEqual(list(self.islice('ABCDEFG', 2, None)), list('CDEFG'))
+        self.assertEqual(list(self.islice('ABCDEFG', 0, None, 2)), list('ACEG'))
+        # Test items consumed.
+        it = iter(xrange(10))
+        self.assertEqual(list(self.islice(it, 3)), range(3))
+        self.assertEqual(list(it), range(3, 10))
+        it = iter(xrange(10))
+        self.assertEqual(list(self.islice(it, 3, 3)), [])
+        self.assertEqual(list(it), range(3, 10))
+        # Test that slice finishes in predictable state.
+        c = count()
+        self.assertEqual(list(self.islice(c, 1, 3, 50)), [1])
+        self.assertEqual(next(c), 3)
+
+
 class TestGC(unittest.TestCase):
 
     def makecycle(self, iterator, container):
@@ -1473,6 +1520,31 @@ class RegressionTests(unittest.TestCase):
         with self.assertRaises(StopIteration):
             next(it)
 
+    def test_issue30347_1(self):
+        def f(n):
+            if n == 5:
+                list(b)
+            return n != 6
+        for (k, b) in groupby(range(10), f):
+            list(b)  # shouldn't crash
+
+    def test_issue30347_2(self):
+        class K(object):
+            i = 0
+            def __init__(self, v):
+                pass
+            def __eq__(self, other):
+                K.i += 1
+                if K.i == 1:
+                    next(g, None)
+                return True
+            def __hash__(self):
+                return 1
+        g = next(groupby(range(10), K))[1]
+        for j in range(2):
+            next(g, None)  # shouldn't crash
+
+
 class SubclassWithKwargsTest(unittest.TestCase):
     def test_keywords_in_subclass(self):
         # count is not subclassable...
@@ -1552,6 +1624,17 @@ Samuele
 ...     "Return function(0), function(1), ..."
 ...     return imap(function, count(start))
 
+>>> import collections
+>>> def consume(iterator, n=None):
+...     "Advance the iterator n-steps ahead. If n is None, consume entirely."
+...     # Use functions that consume iterators at C speed.
+...     if n is None:
+...         # feed the entire iterator into a zero-length deque
+...         collections.deque(iterator, maxlen=0)
+...     else:
+...         # advance to the empty slice starting at position n
+...         next(islice(iterator, n, n), None)
+
 >>> def nth(iterable, n, default=None):
 ...     "Returns the nth item or a default value"
 ...     return next(islice(iterable, n, None), default)
@@ -1653,6 +1736,14 @@ perform as purported.
 >>> list(islice(tabulate(lambda x: 2*x), 4))
 [0, 2, 4, 6]
 
+>>> it = iter(xrange(10))
+>>> consume(it, 3)
+>>> next(it)
+3
+>>> consume(it)
+>>> next(it, 'Done')
+'Done'
+
 >>> nth('abcde', 3)
 'd'
 
@@ -1728,7 +1819,8 @@ __test__ = {'libreftest' : libreftest}
 def test_main(verbose=None):
     test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
                     RegressionTests, LengthTransparency,
-                    SubclassWithKwargsTest, TestExamples)
+                    SubclassWithKwargsTest, TestExamples,
+                    TestPurePythonRoughEquivalents)
     test_support.run_unittest(*test_classes)
 
     # verify reference counting
index 1bdfec835dfca5839be6966d4a1cf1ceb14e775b..b3722033f392fb7189c93f26a9b38cc154d0b836 100644 (file)
@@ -36,9 +36,12 @@ class TestKQueue(unittest.TestCase):
         self.assertEqual(cmp(ev, other), -1)
         self.assertTrue(ev < other)
         self.assertTrue(other >= ev)
-        self.assertRaises(TypeError, cmp, ev, None)
-        self.assertRaises(TypeError, cmp, ev, 1)
-        self.assertRaises(TypeError, cmp, ev, "ev")
+        self.assertNotEqual(cmp(ev, None), 0)
+        self.assertNotEqual(cmp(ev, 1), 0)
+        self.assertNotEqual(cmp(ev, "ev"), 0)
+        self.assertEqual(cmp(ev, None), -cmp(None, ev))
+        self.assertEqual(cmp(ev, 1), -cmp(1, ev))
+        self.assertEqual(cmp(ev, "ev"), -cmp("ev", ev))
 
         ev = select.kevent(fd, select.KQ_FILTER_WRITE)
         self.assertEqual(ev.ident, fd)
@@ -205,6 +208,30 @@ class TestKQueue(unittest.TestCase):
         b.close()
         kq.close()
 
+    def test_issue30058(self):
+        # changelist must be an iterable
+        kq = select.kqueue()
+        a, b = socket.socketpair()
+        ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
+
+        kq.control([ev], 0)
+        # not a list
+        kq.control((ev,), 0)
+        # __len__ is not consistent with __iter__
+        class BadList:
+            def __len__(self):
+                return 0
+            def __iter__(self):
+                for i in range(100):
+                    yield ev
+        kq.control(BadList(), 0)
+        # doesn't have __len__
+        kq.control(iter([ev]), 0)
+
+        a.close()
+        b.close()
+        kq.close()
+
 def test_main():
     test_support.run_unittest(TestKQueue)
 
index 2261bb854cb765ca7db0780fc3024b1ba4bc48a0..f8db5d5723fb280a36b2059f221739d53b42b84d 100644 (file)
@@ -654,7 +654,7 @@ class TestMaildir(TestMailbox, unittest.TestCase):
             hostname = hostname.replace(':', r'\072')
         pid = os.getpid()
         pattern = re.compile(r"(?P<time>\d+)\.M(?P<M>\d{1,6})P(?P<P>\d+)"
-                             r"Q(?P<Q>\d+)\.(?P<host>[^:/]+)")
+                             r"Q(?P<Q>\d+)\.(?P<host>[^:/]*)")
         previous_groups = None
         for x in xrange(repetitions):
             tmp_file = self._box._create_tmp()
index a77bfee6718ee66afab33b28e0c69b64dfd0340c..1071d7fac6532b5cca338aef81e2ddc16c52249f 100644 (file)
@@ -671,7 +671,8 @@ class _TestQueue(BaseTestCase):
             q = self.Queue()
             q.put(NotSerializable())
             q.put(True)
-            self.assertTrue(q.get(timeout=0.1))
+            # bpo-30595: use a timeout of 1 second for slow buildbots
+            self.assertTrue(q.get(timeout=1.0))
 
 
 #
index 4156c535eff499db05899e93a18855eead1f42ae..4d49a55cb64823a3a78efafe65a1c2f587d3314a 100644 (file)
@@ -5,25 +5,29 @@ temp_filename = test_support.TESTFN
 
 class NetrcTestCase(unittest.TestCase):
 
-    def make_nrc(self, test_data):
+    def make_nrc(self, test_data, cleanup=True):
         test_data = textwrap.dedent(test_data)
         mode = 'w'
         if sys.platform != 'cygwin':
             mode += 't'
         with open(temp_filename, mode) as fp:
             fp.write(test_data)
-        self.addCleanup(os.unlink, temp_filename)
+        if cleanup:
+            self.addCleanup(os.unlink, temp_filename)
         return netrc.netrc(temp_filename)
 
     def test_default(self):
         nrc = self.make_nrc("""\
             machine host1.domain.com login log1 password pass1 account acct1
             default login log2 password pass2
-            """)
+            """, cleanup=False)
         self.assertEqual(nrc.hosts['host1.domain.com'],
                          ('log1', 'acct1', 'pass1'))
         self.assertEqual(nrc.hosts['default'], ('log2', None, 'pass2'))
 
+        nrc2 = self.make_nrc(nrc.__repr__(), cleanup=True)
+        self.assertEqual(nrc.hosts, nrc2.hosts)
+
     def test_macros(self):
         nrc = self.make_nrc("""\
             macdef macro1
index 85e4841fbb4b2105f3c10a6e983498dca6435ba8..17326c5190c61ea44a7d4046daa29bd4b64f8e1c 100644 (file)
@@ -220,6 +220,19 @@ class TestOrderedDict(unittest.TestCase):
         self.assertEqual(repr(od),
             "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])")
 
+    def test_repr_recursive_values(self):
+        od = OrderedDict()
+        od[42] = od.viewvalues()
+        r = repr(od)
+        # Cannot perform a stronger test, as the contents of the repr
+        # are implementation-dependent.  All we can say is that we
+        # want a str result, not an exception of any sort.
+        self.assertIsInstance(r, str)
+        od[42] = od.viewitems()
+        r = repr(od)
+        # Again.
+        self.assertIsInstance(r, str)
+
     def test_setdefault(self):
         pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
         shuffle(pairs)
index aca03fdabb1decaf281c0f733a88bb7926556ff3..84e20e0c013b7536b5aee8d884db06f00e91a8d0 100644 (file)
@@ -900,6 +900,56 @@ class Win32KillTests(unittest.TestCase):
         self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
 
 
+@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
+class Win32ListdirTests(unittest.TestCase):
+    """Test listdir on Windows."""
+
+    def setUp(self):
+        self.created_paths = []
+        for i in range(2):
+            dir_name = 'SUB%d' % i
+            dir_path = os.path.join(support.TESTFN, dir_name)
+            file_name = 'FILE%d' % i
+            file_path = os.path.join(support.TESTFN, file_name)
+            os.makedirs(dir_path)
+            with open(file_path, 'w') as f:
+                f.write("I'm %s and proud of it. Blame test_os.\n" % file_path)
+            self.created_paths.extend([dir_name, file_name])
+        self.created_paths.sort()
+
+    def tearDown(self):
+        shutil.rmtree(support.TESTFN)
+
+    def test_listdir_no_extended_path(self):
+        """Test when the path is not an "extended" path."""
+        # unicode
+        fs_encoding = sys.getfilesystemencoding()
+        self.assertEqual(
+                sorted(os.listdir(support.TESTFN.decode(fs_encoding))),
+                [path.decode(fs_encoding) for path in self.created_paths])
+
+        # bytes
+        self.assertEqual(
+                sorted(os.listdir(os.fsencode(support.TESTFN))),
+                self.created_paths)
+
+    def test_listdir_extended_path(self):
+        """Test when the path starts with '\\\\?\\'."""
+        # See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
+        # unicode
+        fs_encoding = sys.getfilesystemencoding()
+        path = u'\\\\?\\' + os.path.abspath(support.TESTFN.decode(fs_encoding))
+        self.assertEqual(
+                sorted(os.listdir(path)),
+                [path.decode(fs_encoding) for path in self.created_paths])
+
+        # bytes
+        path = b'\\\\?\\' + os.path.abspath(support.TESTFN)
+        self.assertEqual(
+                sorted(os.listdir(path)),
+                self.created_paths)
+
+
 class SpawnTests(unittest.TestCase):
     def _test_invalid_env(self, spawn):
         args = [sys.executable, '-c', 'pass']
index 1e195ed624da9068685d1fb650d16f7af8a2bccd..7ad693d319fb9cb70510278b69b0013ecc538529 100644 (file)
@@ -205,6 +205,28 @@ class PollTests(unittest.TestCase):
             os.write(w, b'spam')
             t.join()
 
+    @unittest.skipUnless(threading, 'Threading required for this test.')
+    @reap_threads
+    def test_poll_blocks_with_negative_ms(self):
+        for timeout_ms in [None, -1000, -1, -1.0]:
+            # Create two file descriptors. This will be used to unlock
+            # the blocking call to poll.poll inside the thread
+            r, w = os.pipe()
+            pollster = select.poll()
+            pollster.register(r, select.POLLIN)
+
+            poll_thread = threading.Thread(target=pollster.poll, args=(timeout_ms,))
+            poll_thread.start()
+            poll_thread.join(timeout=0.1)
+            self.assertTrue(poll_thread.is_alive())
+
+            # Write to the pipe so pollster.poll unblocks and the thread ends.
+            os.write(w, b'spam')
+            poll_thread.join()
+            self.assertFalse(poll_thread.is_alive())
+            os.close(r)
+            os.close(w)
+
 
 def test_main():
     run_unittest(PollTests)
index 23d688724b95c99ee30cac01ff6515c984c71a0d..d2143759ba6652ef1938bce53d4c649e2d421997 100644 (file)
@@ -211,6 +211,16 @@ class TestPOP3Class(TestCase):
     def test_rpop(self):
         self.assertOK(self.client.rpop('foo'))
 
+    def test_apop_REDOS(self):
+        # Replace welcome with very long evil welcome.
+        # NB The upper bound on welcome length is currently 2048.
+        # At this length, evil input makes each apop call take
+        # on the order of milliseconds instead of microseconds.
+        evil_welcome = b'+OK' + (b'<' * 1000000)
+        with test_support.swap_attr(self.client, 'welcome', evil_welcome):
+            # The evil welcome is invalid, so apop should throw.
+            self.assertRaises(poplib.error_proto, self.client.apop, 'a', 'kb')
+
     def test_top(self):
         expected =  ('+OK 116 bytes',
                      ['From: postmaster@python.org', 'Content-Type: text/plain',
index bec38c45456b9c0ac5a05c0d9c3831eef936ec83..f623aa09620ec0c0cb48bcca687466e4797a5331 100644 (file)
@@ -11,6 +11,7 @@ import sys
 import select
 import signal
 import socket
+import io # readline
 import unittest
 
 TEST_STRING_1 = "I wish to buy a fish license.\n"
@@ -24,6 +25,16 @@ else:
         pass
 
 
+# Note that os.read() is nondeterministic so we need to be very careful
+# to make the test suite deterministic.  A normal call to os.read() may
+# give us less than expected.
+#
+# Beware, on my Linux system, if I put 'foo\n' into a terminal fd, I get
+# back 'foo\r\n' at the other end.  The behavior depends on the termios
+# setting.  The newline translation may be OS-specific.  To make the
+# test suite deterministic and OS-independent, the functions _readline
+# and normalize_output can be used.
+
 def normalize_output(data):
     # Some operating systems do conversions on newline.  We could possibly
     # fix that by doing the appropriate termios.tcsetattr()s.  I couldn't
@@ -45,6 +56,12 @@ def normalize_output(data):
 
     return data
 
+def _readline(fd):
+    """Read one line.  May block forever if no newline is read."""
+    reader = io.FileIO(fd, mode='rb', closefd=False)
+    return reader.readline()
+
+
 
 # Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
 # because pty code is not too portable.
@@ -97,14 +114,14 @@ class PtyTest(unittest.TestCase):
 
         debug("Writing to slave_fd")
         os.write(slave_fd, TEST_STRING_1)
-        s1 = os.read(master_fd, 1024)
+        s1 = _readline(master_fd)
         self.assertEqual('I wish to buy a fish license.\n',
                          normalize_output(s1))
 
         debug("Writing chunked output")
         os.write(slave_fd, TEST_STRING_2[:5])
         os.write(slave_fd, TEST_STRING_2[5:])
-        s2 = os.read(master_fd, 1024)
+        s2 = _readline(master_fd)
         self.assertEqual('For my pet fish, Eric.\n', normalize_output(s2))
 
         os.close(slave_fd)
index 90d334a835a2a7f7bf1e94bfe9f735ce5a231a98..8a6d17290ddaccc8040051edd28f0fc64c5dca27 100644 (file)
@@ -307,6 +307,22 @@ class SystemRandom_TestBasicOps(TestBasicOps):
 class MersenneTwister_TestBasicOps(TestBasicOps):
     gen = random.Random()
 
+    @test_support.cpython_only
+    def test_bug_31478(self):
+        # _random.Random.seed() should ignore the __abs__() method of a
+        # long/int subclass argument.
+        class BadInt(int):
+            def __abs__(self):
+                1/0.0
+        class BadLong(long):
+            def __abs__(self):
+                1/0.0
+        self.gen.seed(42)
+        expected_value = self.gen.random()
+        for seed_arg in [42L, BadInt(42), BadLong(42)]:
+            self.gen.seed(seed_arg)
+            self.assertEqual(self.gen.random(), expected_value)
+
     def test_setstate_first_arg(self):
         self.assertRaises(ValueError, self.gen.setstate, (1, None, None))
 
index 174c5ca462cdca0e11b146f0fa6cb66e3444e6f7..ae314841c68422eb40a705fc3e7857968e622afb 100644 (file)
@@ -58,7 +58,7 @@ class ReTests(unittest.TestCase):
 
         s = r"\1\1"
         self.assertEqual(re.sub('(.)', s, 'x'), 'xx')
-        self.assertEqual(re.sub('(.)', re.escape(s), 'x'), s)
+        self.assertEqual(re.sub('(.)', s.replace('\\', r'\\'), 'x'), s)
         self.assertEqual(re.sub('(.)', lambda m: s, 'x'), s)
 
         self.assertEqual(re.sub('(?P<a>x)', '\g<a>\g<a>', 'xx'), 'xxxx')
index 264c74d22ba7e47483e7cda5c5723eec82ee1282..988a72c109962abe36e49a4e0c768c55c78ed39d 100644 (file)
@@ -493,6 +493,7 @@ class ArgsTestCase(BaseTestCase):
             self.assertIn(line2, reflog)
 
     @unittest.skipUnless(Py_DEBUG, 'need a debug build')
+    @support.requires_type_collecting
     def test_huntrleaks(self):
         # test --huntrleaks
         code = textwrap.dedent("""
@@ -543,6 +544,8 @@ class ArgsTestCase(BaseTestCase):
                                 testname)
         self.assertEqual(output.splitlines(), all_methods)
 
+    @unittest.skipIf(sys.platform.startswith('aix'),
+                     "support._crash_python() doesn't work on AIX")
     def test_crashed(self):
         # Any code which causes a crash
         code = 'import test.support; test.support._crash_python()'
index 2b20a791501ff1e172c5c4951264f71c319f2cd2..ca53899418cecfe99de7938df64bc2e3bff3fc39 100644 (file)
@@ -35,7 +35,7 @@ def try_address(host, port=0, family=socket.AF_INET):
 
 HOST = test_support.HOST
 MSG = b'Michael Gilfix was here\n'
-SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6)
+SUPPORTS_IPV6 = test_support.IPV6_ENABLED
 
 try:
     import thread
@@ -733,6 +733,7 @@ class GeneralModuleTests(unittest.TestCase):
                 self.assertRaises(socket.timeout, c.sendall,
                                   b"x" * test_support.SOCK_MAX_SIZE)
         finally:
+            signal.alarm(0)
             signal.signal(signal.SIGALRM, old_alarm)
             c.close()
             s.close()
@@ -1357,6 +1358,10 @@ class NetworkConnectionNoServer(unittest.TestCase):
         expected_errnos = [ errno.ECONNREFUSED, ]
         if hasattr(errno, 'ENETUNREACH'):
             expected_errnos.append(errno.ENETUNREACH)
+        if hasattr(errno, 'EADDRNOTAVAIL'):
+            # bpo-31910: socket.create_connection() fails randomly
+            # with EADDRNOTAVAIL on Travis CI
+            expected_errnos.append(errno.EADDRNOTAVAIL)
 
         self.assertIn(cm.exception.errno, expected_errnos)
 
index d645d208dcadbb8c84bf6635735195b1945f5c49..0087b9e24d7aa80b142f523ad7f467584b10f708 100644 (file)
@@ -69,6 +69,20 @@ def simple_subprocess(testcase):
     testcase.assertEqual(72 << 8, status)
 
 
+def close_server(server):
+    server.server_close()
+
+    if hasattr(server, 'active_children'):
+        # ForkingMixIn: Manually reap all child processes, since server_close()
+        # calls waitpid() in non-blocking mode using the WNOHANG flag.
+        for pid in server.active_children.copy():
+            try:
+                os.waitpid(pid, 0)
+            except ChildProcessError:
+                pass
+        server.active_children.clear()
+
+
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class SocketServerTest(unittest.TestCase):
     """Test all socket servers."""
@@ -118,7 +132,7 @@ class SocketServerTest(unittest.TestCase):
         class MyServer(svrcls):
             def handle_error(self, request, client_address):
                 self.close_request(request)
-                self.server_close()
+                close_server(self)
                 raise
 
         class MyHandler(hdlrbase):
@@ -158,7 +172,7 @@ class SocketServerTest(unittest.TestCase):
         if verbose: print "waiting for server"
         server.shutdown()
         t.join()
-        server.server_close()
+        close_server(server)
         self.assertRaises(socket.error, server.socket.fileno)
         if verbose: print "done"
 
@@ -314,6 +328,7 @@ class SocketServerTest(unittest.TestCase):
             s.shutdown()
         for t, s in threads:
             t.join()
+            close_server(s)
 
     def test_tcpserver_bind_leak(self):
         # Issue #22435: the server socket wouldn't be closed if bind()/listen()
@@ -347,7 +362,7 @@ class MiscTestCase(unittest.TestCase):
         s.close()
         server.handle_request()
         self.assertEqual(server.shutdown_called, 1)
-        server.server_close()
+        close_server(server)
 
 
 def test_main():
index 07526c2cf159757b87924ee0c0dbeb83b38e95d6..b59fe73f04c7a0f77b7105d111493e689d4ffca2 100644 (file)
@@ -14,7 +14,7 @@ import gc
 import os
 import errno
 import pprint
-import tempfile
+import shutil
 import urllib2
 import traceback
 import weakref
@@ -168,6 +168,13 @@ class BasicSocketTests(unittest.TestCase):
             ssl.OP_NO_COMPRESSION
         self.assertIn(ssl.HAS_SNI, {True, False})
         self.assertIn(ssl.HAS_ECDH, {True, False})
+        ssl.OP_NO_SSLv2
+        ssl.OP_NO_SSLv3
+        ssl.OP_NO_TLSv1
+        ssl.OP_NO_TLSv1_3
+        if ssl.OPENSSL_VERSION_INFO >= (1, 0, 1):
+            ssl.OP_NO_TLSv1_1
+            ssl.OP_NO_TLSv1_2
 
     def test_random(self):
         v = ssl.RAND_status()
@@ -993,6 +1000,10 @@ class ContextTests(unittest.TestCase):
         self.assertEqual(cm.exception.errno, errno.ENOENT)
         with self.assertRaises(ssl.SSLError) as cm:
             ctx.load_dh_params(CERTFILE)
+        with support.temp_dir() as d:
+            fname = os.path.join(d, u'dhpäräm.pem')
+            shutil.copy(DHFILE, fname)
+            ctx.load_dh_params(fname)
 
     @skip_if_broken_ubuntu_ssl
     def test_session_stats(self):
@@ -1588,34 +1599,6 @@ class NetworkedTests(unittest.TestCase):
                                         cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
                     s.connect(remote)
 
-    def test_algorithms(self):
-        # Issue #8484: all algorithms should be available when verifying a
-        # certificate.
-        # SHA256 was added in OpenSSL 0.9.8
-        if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
-            self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
-        # sha256.tbs-internet.com needs SNI to use the correct certificate
-        if not ssl.HAS_SNI:
-            self.skipTest("SNI needed for this test")
-        # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
-        remote = ("sha256.tbs-internet.com", 443)
-        sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
-        with support.transient_internet("sha256.tbs-internet.com"):
-            ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
-            ctx.verify_mode = ssl.CERT_REQUIRED
-            ctx.load_verify_locations(sha256_cert)
-            s = ctx.wrap_socket(socket.socket(socket.AF_INET),
-                                server_hostname="sha256.tbs-internet.com")
-            try:
-                s.connect(remote)
-                if support.verbose:
-                    sys.stdout.write("\nCipher with %r is %r\n" %
-                                     (remote, s.cipher()))
-                    sys.stdout.write("Certificate is:\n%s\n" %
-                                     pprint.pformat(s.getpeercert()))
-            finally:
-                s.close()
-
     def test_get_ca_certs_capath(self):
         # capath certs are loaded on request
         with support.transient_internet(REMOTE_HOST):
@@ -1795,7 +1778,7 @@ else:
             else:
                 self.context = ssl.SSLContext(ssl_version
                                               if ssl_version is not None
-                                              else ssl.PROTOCOL_TLSv1)
+                                              else ssl.PROTOCOL_TLS)
                 self.context.verify_mode = (certreqs if certreqs is not None
                                             else ssl.CERT_NONE)
                 if cacerts:
@@ -2812,6 +2795,24 @@ else:
                     self.assertEqual(s.version(), 'TLSv1')
                 self.assertIs(s.version(), None)
 
+        @unittest.skipUnless(ssl.HAS_TLSv1_3,
+                             "test requires TLSv1.3 enabled OpenSSL")
+        def test_tls1_3(self):
+            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
+            context.load_cert_chain(CERTFILE)
+            # disable all but TLS 1.3
+            context.options |= (
+                ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_TLSv1_2
+            )
+            with ThreadedEchoServer(context=context) as server:
+                with context.wrap_socket(socket.socket()) as s:
+                    s.connect((HOST, server.port))
+                    self.assertIn(s.cipher()[0], [
+                        'TLS13-AES-256-GCM-SHA384',
+                        'TLS13-CHACHA20-POLY1305-SHA256',
+                        'TLS13-AES-128-GCM-SHA256',
+                    ])
+
         @unittest.skipUnless(ssl.HAS_ECDH, "test requires ECDH-enabled OpenSSL")
         def test_default_ecdh_curve(self):
             # Issue #21015: elliptic curve-based Diffie Hellman key exchange
index b26ebec93dc28295bc18b15c1980e70e85aadefd..325024ceaee90539cf7f537c5a003248ed6281fd 100644 (file)
@@ -60,8 +60,10 @@ class StrftimeTest(unittest.TestCase):
             import java
             java.util.Locale.setDefault(java.util.Locale.US)
         except ImportError:
-            import locale
-            locale.setlocale(locale.LC_TIME, 'C')
+            from locale import setlocale, LC_TIME
+            saved_locale = setlocale(LC_TIME)
+            setlocale(LC_TIME, 'C')
+            self.addCleanup(setlocale, LC_TIME, saved_locale)
 
     def test_strftime(self):
         now = time.time()
index 81d078ed8d39c6e1ad3bcbd6b875a0817d9773ed..50b8f6ebc3d8f7ef98ee9c8a4b141bc12e1a6f9e 100644 (file)
@@ -2,11 +2,12 @@ import warnings
 warnings.filterwarnings("ignore", "strop functions are obsolete;",
                         DeprecationWarning,
                         r'test.test_strop|unittest')
-import strop
 import unittest
 import sys
 from test import test_support
 
+strop = test_support.import_module("strop")
+
 
 class StropFunctionTestCase(unittest.TestCase):
 
index a5a727efd62d4301f261b34c38623a1be94fdef9..ee2383b8a93522622ceae4bec18b84208f015ffc 100644 (file)
@@ -697,7 +697,7 @@ class ProcessTestCase(BaseTestCase):
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
             # ignore errors that indicate the command was not found
-            if c.exception.errno not in (errno.ENOENT, errno.EACCES):
+            if c.exception.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EACCES):
                 raise c.exception
 
     @unittest.skipIf(threading is None, "threading required")
index 0a61462a608557df83556ae60c851d4ff406f597..103b4c110936c7d85882bb0173b6d92e169c8179 100644 (file)
@@ -73,13 +73,12 @@ SyntaxError: can't assign to literal
 
 >>> "abc" = 1
 Traceback (most recent call last):
-  File "<doctest test.test_syntax[8]>", line 1
+  File "<doctest test.test_syntax[9]>", line 1
 SyntaxError: can't assign to literal
 
->>> `1` = 1
+>>> b"" = 1
 Traceback (most recent call last):
-  File "<doctest test.test_syntax[10]>", line 1
-SyntaxError: can't assign to repr
+SyntaxError: can't assign to literal
 
 If the left-hand side of an assignment is a list or tuple, an illegal
 expression inside that contain should still cause a syntax error.
@@ -148,7 +147,7 @@ SyntaxError: cannot assign to None
 
 From ast_for_call():
 
->>> def f(it, *varargs):
+>>> def f(it, *varargs, **kwargs):
 ...     return list(it)
 >>> L = range(10)
 >>> f(x for x in L)
@@ -157,73 +156,179 @@ From ast_for_call():
 Traceback (most recent call last):
   File "<doctest test.test_syntax[23]>", line 1
 SyntaxError: Generator expression must be parenthesized if not sole argument
+>>> f(x for x in L, y=1)
+Traceback (most recent call last):
+SyntaxError: Generator expression must be parenthesized if not sole argument
+>>> f(L, x for x in L)
+Traceback (most recent call last):
+SyntaxError: Generator expression must be parenthesized if not sole argument
+>>> f(x for x in L, y for y in L)
+Traceback (most recent call last):
+SyntaxError: Generator expression must be parenthesized if not sole argument
+>>> f(x for x in L,)
+[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 >>> f((x for x in L), 1)
 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
->>> f(i0,  i1,  i2,  i3,  i4,  i5,  i6,  i7,  i8,  i9,  i10,  i11,
-...   i12,  i13,  i14,  i15,  i16,  i17,  i18,  i19,  i20,  i21,  i22,
-...   i23,  i24,  i25,  i26,  i27,  i28,  i29,  i30,  i31,  i32,  i33,
-...   i34,  i35,  i36,  i37,  i38,  i39,  i40,  i41,  i42,  i43,  i44,
-...   i45,  i46,  i47,  i48,  i49,  i50,  i51,  i52,  i53,  i54,  i55,
-...   i56,  i57,  i58,  i59,  i60,  i61,  i62,  i63,  i64,  i65,  i66,
-...   i67,  i68,  i69,  i70,  i71,  i72,  i73,  i74,  i75,  i76,  i77,
-...   i78,  i79,  i80,  i81,  i82,  i83,  i84,  i85,  i86,  i87,  i88,
-...   i89,  i90,  i91,  i92,  i93,  i94,  i95,  i96,  i97,  i98,  i99,
-...   i100,  i101,  i102,  i103,  i104,  i105,  i106,  i107,  i108,
-...   i109,  i110,  i111,  i112,  i113,  i114,  i115,  i116,  i117,
-...   i118,  i119,  i120,  i121,  i122,  i123,  i124,  i125,  i126,
-...   i127,  i128,  i129,  i130,  i131,  i132,  i133,  i134,  i135,
-...   i136,  i137,  i138,  i139,  i140,  i141,  i142,  i143,  i144,
-...   i145,  i146,  i147,  i148,  i149,  i150,  i151,  i152,  i153,
-...   i154,  i155,  i156,  i157,  i158,  i159,  i160,  i161,  i162,
-...   i163,  i164,  i165,  i166,  i167,  i168,  i169,  i170,  i171,
-...   i172,  i173,  i174,  i175,  i176,  i177,  i178,  i179,  i180,
-...   i181,  i182,  i183,  i184,  i185,  i186,  i187,  i188,  i189,
-...   i190,  i191,  i192,  i193,  i194,  i195,  i196,  i197,  i198,
-...   i199,  i200,  i201,  i202,  i203,  i204,  i205,  i206,  i207,
-...   i208,  i209,  i210,  i211,  i212,  i213,  i214,  i215,  i216,
-...   i217,  i218,  i219,  i220,  i221,  i222,  i223,  i224,  i225,
-...   i226,  i227,  i228,  i229,  i230,  i231,  i232,  i233,  i234,
-...   i235,  i236,  i237,  i238,  i239,  i240,  i241,  i242,  i243,
-...   i244,  i245,  i246,  i247,  i248,  i249,  i250,  i251,  i252,
-...   i253,  i254,  i255)
+>>> def g(*args, **kwargs):
+...     print args, sorted(kwargs.items())
+>>> g(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
+...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
+...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
+...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+...   248, 249, 250, 251, 252, 253, 254)  # doctest: +ELLIPSIS
+(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 252, 253, 254) []
+>>> g(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
+...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
+...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
+...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+...   248, 249, 250, 251, 252, 253, 254, 255)
 Traceback (most recent call last):
   File "<doctest test.test_syntax[25]>", line 1
 SyntaxError: more than 255 arguments
 
-The actual error cases counts positional arguments, keyword arguments,
-and generator expression arguments separately.  This test combines the
-three.
-
->>> f(i0,  i1,  i2,  i3,  i4,  i5,  i6,  i7,  i8,  i9,  i10,  i11,
-...   i12,  i13,  i14,  i15,  i16,  i17,  i18,  i19,  i20,  i21,  i22,
-...   i23,  i24,  i25,  i26,  i27,  i28,  i29,  i30,  i31,  i32,  i33,
-...   i34,  i35,  i36,  i37,  i38,  i39,  i40,  i41,  i42,  i43,  i44,
-...   i45,  i46,  i47,  i48,  i49,  i50,  i51,  i52,  i53,  i54,  i55,
-...   i56,  i57,  i58,  i59,  i60,  i61,  i62,  i63,  i64,  i65,  i66,
-...   i67,  i68,  i69,  i70,  i71,  i72,  i73,  i74,  i75,  i76,  i77,
-...   i78,  i79,  i80,  i81,  i82,  i83,  i84,  i85,  i86,  i87,  i88,
-...   i89,  i90,  i91,  i92,  i93,  i94,  i95,  i96,  i97,  i98,  i99,
-...   i100,  i101,  i102,  i103,  i104,  i105,  i106,  i107,  i108,
-...   i109,  i110,  i111,  i112,  i113,  i114,  i115,  i116,  i117,
-...   i118,  i119,  i120,  i121,  i122,  i123,  i124,  i125,  i126,
-...   i127,  i128,  i129,  i130,  i131,  i132,  i133,  i134,  i135,
-...   i136,  i137,  i138,  i139,  i140,  i141,  i142,  i143,  i144,
-...   i145,  i146,  i147,  i148,  i149,  i150,  i151,  i152,  i153,
-...   i154,  i155,  i156,  i157,  i158,  i159,  i160,  i161,  i162,
-...   i163,  i164,  i165,  i166,  i167,  i168,  i169,  i170,  i171,
-...   i172,  i173,  i174,  i175,  i176,  i177,  i178,  i179,  i180,
-...   i181,  i182,  i183,  i184,  i185,  i186,  i187,  i188,  i189,
-...   i190,  i191,  i192,  i193,  i194,  i195,  i196,  i197,  i198,
-...   i199,  i200,  i201,  i202,  i203,  i204,  i205,  i206,  i207,
-...   i208,  i209,  i210,  i211,  i212,  i213,  i214,  i215,  i216,
-...   i217,  i218,  i219,  i220,  i221,  i222,  i223,  i224,  i225,
-...   i226,  i227,  i228,  i229,  i230,  i231,  i232,  i233,  i234,
-...   i235, i236,  i237,  i238,  i239,  i240,  i241,  i242,  i243,
-...   (x for x in i244),  i245,  i246,  i247,  i248,  i249,  i250,  i251,
-...    i252=1, i253=1,  i254=1,  i255=1)
-Traceback (most recent call last):
-  File "<doctest test.test_syntax[26]>", line 1
+>>> g(a000=0, a001=1, a002=2, a003=3, a004=4, a005=5, a006=6, a007=7, a008=8,
+...   a009=9, a010=10, a011=11, a012=12, a013=13, a014=14, a015=15, a016=16,
+...   a017=17, a018=18, a019=19, a020=20, a021=21, a022=22, a023=23, a024=24,
+...   a025=25, a026=26, a027=27, a028=28, a029=29, a030=30, a031=31, a032=32,
+...   a033=33, a034=34, a035=35, a036=36, a037=37, a038=38, a039=39, a040=40,
+...   a041=41, a042=42, a043=43, a044=44, a045=45, a046=46, a047=47, a048=48,
+...   a049=49, a050=50, a051=51, a052=52, a053=53, a054=54, a055=55, a056=56,
+...   a057=57, a058=58, a059=59, a060=60, a061=61, a062=62, a063=63, a064=64,
+...   a065=65, a066=66, a067=67, a068=68, a069=69, a070=70, a071=71, a072=72,
+...   a073=73, a074=74, a075=75, a076=76, a077=77, a078=78, a079=79, a080=80,
+...   a081=81, a082=82, a083=83, a084=84, a085=85, a086=86, a087=87, a088=88,
+...   a089=89, a090=90, a091=91, a092=92, a093=93, a094=94, a095=95, a096=96,
+...   a097=97, a098=98, a099=99, a100=100, a101=101, a102=102, a103=103,
+...   a104=104, a105=105, a106=106, a107=107, a108=108, a109=109, a110=110,
+...   a111=111, a112=112, a113=113, a114=114, a115=115, a116=116, a117=117,
+...   a118=118, a119=119, a120=120, a121=121, a122=122, a123=123, a124=124,
+...   a125=125, a126=126, a127=127, a128=128, a129=129, a130=130, a131=131,
+...   a132=132, a133=133, a134=134, a135=135, a136=136, a137=137, a138=138,
+...   a139=139, a140=140, a141=141, a142=142, a143=143, a144=144, a145=145,
+...   a146=146, a147=147, a148=148, a149=149, a150=150, a151=151, a152=152,
+...   a153=153, a154=154, a155=155, a156=156, a157=157, a158=158, a159=159,
+...   a160=160, a161=161, a162=162, a163=163, a164=164, a165=165, a166=166,
+...   a167=167, a168=168, a169=169, a170=170, a171=171, a172=172, a173=173,
+...   a174=174, a175=175, a176=176, a177=177, a178=178, a179=179, a180=180,
+...   a181=181, a182=182, a183=183, a184=184, a185=185, a186=186, a187=187,
+...   a188=188, a189=189, a190=190, a191=191, a192=192, a193=193, a194=194,
+...   a195=195, a196=196, a197=197, a198=198, a199=199, a200=200, a201=201,
+...   a202=202, a203=203, a204=204, a205=205, a206=206, a207=207, a208=208,
+...   a209=209, a210=210, a211=211, a212=212, a213=213, a214=214, a215=215,
+...   a216=216, a217=217, a218=218, a219=219, a220=220, a221=221, a222=222,
+...   a223=223, a224=224, a225=225, a226=226, a227=227, a228=228, a229=229,
+...   a230=230, a231=231, a232=232, a233=233, a234=234, a235=235, a236=236,
+...   a237=237, a238=238, a239=239, a240=240, a241=241, a242=242, a243=243,
+...   a244=244, a245=245, a246=246, a247=247, a248=248, a249=249, a250=250,
+...   a251=251, a252=252, a253=253, a254=254)  # doctest: +ELLIPSIS
+() [('a000', 0), ('a001', 1), ('a002', 2), ..., ('a253', 253), ('a254', 254)]
+>>> g(a000=0, a001=1, a002=2, a003=3, a004=4, a005=5, a006=6, a007=7, a008=8,
+...   a009=9, a010=10, a011=11, a012=12, a013=13, a014=14, a015=15, a016=16,
+...   a017=17, a018=18, a019=19, a020=20, a021=21, a022=22, a023=23, a024=24,
+...   a025=25, a026=26, a027=27, a028=28, a029=29, a030=30, a031=31, a032=32,
+...   a033=33, a034=34, a035=35, a036=36, a037=37, a038=38, a039=39, a040=40,
+...   a041=41, a042=42, a043=43, a044=44, a045=45, a046=46, a047=47, a048=48,
+...   a049=49, a050=50, a051=51, a052=52, a053=53, a054=54, a055=55, a056=56,
+...   a057=57, a058=58, a059=59, a060=60, a061=61, a062=62, a063=63, a064=64,
+...   a065=65, a066=66, a067=67, a068=68, a069=69, a070=70, a071=71, a072=72,
+...   a073=73, a074=74, a075=75, a076=76, a077=77, a078=78, a079=79, a080=80,
+...   a081=81, a082=82, a083=83, a084=84, a085=85, a086=86, a087=87, a088=88,
+...   a089=89, a090=90, a091=91, a092=92, a093=93, a094=94, a095=95, a096=96,
+...   a097=97, a098=98, a099=99, a100=100, a101=101, a102=102, a103=103,
+...   a104=104, a105=105, a106=106, a107=107, a108=108, a109=109, a110=110,
+...   a111=111, a112=112, a113=113, a114=114, a115=115, a116=116, a117=117,
+...   a118=118, a119=119, a120=120, a121=121, a122=122, a123=123, a124=124,
+...   a125=125, a126=126, a127=127, a128=128, a129=129, a130=130, a131=131,
+...   a132=132, a133=133, a134=134, a135=135, a136=136, a137=137, a138=138,
+...   a139=139, a140=140, a141=141, a142=142, a143=143, a144=144, a145=145,
+...   a146=146, a147=147, a148=148, a149=149, a150=150, a151=151, a152=152,
+...   a153=153, a154=154, a155=155, a156=156, a157=157, a158=158, a159=159,
+...   a160=160, a161=161, a162=162, a163=163, a164=164, a165=165, a166=166,
+...   a167=167, a168=168, a169=169, a170=170, a171=171, a172=172, a173=173,
+...   a174=174, a175=175, a176=176, a177=177, a178=178, a179=179, a180=180,
+...   a181=181, a182=182, a183=183, a184=184, a185=185, a186=186, a187=187,
+...   a188=188, a189=189, a190=190, a191=191, a192=192, a193=193, a194=194,
+...   a195=195, a196=196, a197=197, a198=198, a199=199, a200=200, a201=201,
+...   a202=202, a203=203, a204=204, a205=205, a206=206, a207=207, a208=208,
+...   a209=209, a210=210, a211=211, a212=212, a213=213, a214=214, a215=215,
+...   a216=216, a217=217, a218=218, a219=219, a220=220, a221=221, a222=222,
+...   a223=223, a224=224, a225=225, a226=226, a227=227, a228=228, a229=229,
+...   a230=230, a231=231, a232=232, a233=233, a234=234, a235=235, a236=236,
+...   a237=237, a238=238, a239=239, a240=240, a241=241, a242=242, a243=243,
+...   a244=244, a245=245, a246=246, a247=247, a248=248, a249=249, a250=250,
+...   a251=251, a252=252, a253=253, a254=254, a255=255)
+Traceback (most recent call last):
+  File "<doctest test.test_syntax[35]>", line 1
+SyntaxError: more than 255 arguments
+
+>>> class C:
+...     def meth(self, *args):
+...         return args
+>>> obj = C()
+>>> obj.meth(
+...   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
+...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
+...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
+...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+...   248, 249, 250, 251, 252, 253, 254)  # doctest: +ELLIPSIS
+(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 252, 253, 254)
+>>> obj.meth(
+...   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
+...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
+...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
+...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+...   248, 249, 250, 251, 252, 253, 254, 255)
+Traceback (most recent call last):
+  File "<doctest test.test_syntax[38]>", line 1
 SyntaxError: more than 255 arguments
 
 >>> f(lambda x: x[0] = 3)
@@ -403,6 +508,16 @@ build.  The number of blocks must be greater than CO_MAXBLOCKS.  SF #1565514
      ...
    SyntaxError: too many statically nested blocks
 
+Misuse of the global statement can lead to a few unique syntax errors.
+
+   >>> def f(x):
+   ...     global x
+   ... # doctest: +ELLIPSIS
+   Traceback (most recent call last):
+     ...
+   SyntaxError: name 'x' is local and global (<doctest ...>, line 1)
+
+
 This tests assignment-context; there was a bug in Python 2.5 where compiling
 a complex 'if' (one with 'elif') would fail to notice an invalid suite,
 leading to spurious errors.
@@ -458,9 +573,21 @@ leading to spurious errors.
      File "<doctest test.test_syntax[48]>", line 6
    SyntaxError: can't assign to function call
 
+Test the "raise X, Y[, Z]" form:
+
+   >>> raise ArithmeticError, 'bad number'
+   Traceback (most recent call last):
+     ...
+   ArithmeticError: bad number
+   >>> raise ArithmeticError, 'bad number', None
+   Traceback (most recent call last):
+     ...
+   ArithmeticError: bad number
+
+
 >>> f(a=23, a=234)
 Traceback (most recent call last):
-   ...
+  ...
   File "<doctest test.test_syntax[49]>", line 1
 SyntaxError: keyword argument repeated
 
@@ -476,6 +603,12 @@ Traceback (most recent call last):
    File "<doctest test.test_syntax[50]>", line 1
 SyntaxError: can't assign to literal
 
+Corner-case that used to fail to raise the correct error:
+
+    >>> def f(x=lambda __debug__:0): pass
+    Traceback (most recent call last):
+    SyntaxError: cannot assign to __debug__
+
 Corner-case that used to crash:
 
     >>> def f(*xx, **__debug__): pass
@@ -488,12 +621,12 @@ import re
 import unittest
 import warnings
 
-from test import test_support
+from test import support
 
 class SyntaxTestCase(unittest.TestCase):
 
     def _check_error(self, code, errtext,
-                     filename="<testcase>", mode="exec", subclass=None):
+                     filename="<testcase>", mode="exec", subclass=None, lineno=None, offset=None):
         """Check that compiling code raises SyntaxError with errtext.
 
         errtest is a regular expression that must be present in the
@@ -501,13 +634,19 @@ class SyntaxTestCase(unittest.TestCase):
         is the expected subclass of SyntaxError (e.g. IndentationError).
         """
         try:
-            compile(code, filename, mode)
-        except SyntaxError, err:
+            compile(code, filename or "<testcase>", mode)
+        except SyntaxError as err:
             if subclass and not isinstance(err, subclass):
                 self.fail("SyntaxError is not a %s" % subclass.__name__)
             mo = re.search(errtext, str(err))
             if mo is None:
                 self.fail("%s did not contain '%r'" % (err, errtext,))
+            if filename is not None:
+                self.assertEqual(err.filename, filename)
+            if lineno is not None:
+                self.assertEqual(err.lineno, lineno)
+            if offset is not None:
+                self.assertEqual(err.offset, offset)
         else:
             self.fail("compile() did not raise SyntaxError")
 
@@ -515,6 +654,11 @@ class SyntaxTestCase(unittest.TestCase):
         self._check_error("def f((x)=23): pass",
                           "parenthesized arg with default")
 
+    def test_assign_repr(self):
+        with support.check_py3k_warnings(('backquote not supported',
+                                          SyntaxWarning)):
+            self._check_error("`1` = 1", "assign to repr")
+
     def test_assign_call(self):
         self._check_error("f() = 1", "assign")
 
@@ -524,28 +668,48 @@ class SyntaxTestCase(unittest.TestCase):
     def test_global_err_then_warn(self):
         # Bug tickler:  The SyntaxError raised for one global statement
         # shouldn't be clobbered by a SyntaxWarning issued for a later one.
-        source = re.sub('(?m)^ *:', '', """\
-            :def error(a):
-            :    global a  # SyntaxError
-            :def warning():
-            :    b = 1
-            :    global b  # SyntaxWarning
-            :""")
-        warnings.filterwarnings(action='ignore', category=SyntaxWarning)
-        self._check_error(source, "global")
-        warnings.filters.pop(0)
+        source = """if 1:
+            def error(a):
+                global a  # SyntaxError
+            def warning():
+                b = 1
+                global b  # SyntaxWarning
+            """
+        with support.check_warnings((".*assigned to before global declaration",
+                                     SyntaxWarning)):
+            self._check_error(source, "local and global", lineno=2)
+
+    def test_misuse_global(self):
+        source = """if 1:
+            def f():
+                print(x)
+                global x
+            """
+        with support.check_warnings(('.*used prior to global declaration',
+                                     SyntaxWarning)):
+            compile(source, '<testcase>', 'exec')
+
+    def test_misuse_global_2(self):
+        source = """if 1:
+            def f():
+                x = 1
+                global x
+            """
+        with support.check_warnings(('.*assigned to before global declaration',
+                                     SyntaxWarning)):
+            compile(source, '<testcase>', 'exec')
 
     def test_break_outside_loop(self):
         self._check_error("break", "outside loop")
 
     def test_delete_deref(self):
-        source = re.sub('(?m)^ *:', '', """\
-            :def foo(x):
-            :  def bar():
-            :    print x
-            :  del x
-            :""")
-        self._check_error(source, "nested scope")
+        source = """if 1:
+            def foo(x):
+                def bar():
+                    print(x)
+                del x
+            """
+        self._check_error(source, "nested scope", filename=None)
 
     def test_unexpected_indent(self):
         self._check_error("foo()\n bar()\n", "unexpected indent",
@@ -564,11 +728,9 @@ class SyntaxTestCase(unittest.TestCase):
         self._check_error("int(base=10, '2')", "non-keyword arg")
 
 def test_main():
-    test_support.run_unittest(SyntaxTestCase)
+    support.run_unittest(SyntaxTestCase)
     from test import test_syntax
-    with test_support.check_py3k_warnings(("backquote not supported",
-                                             SyntaxWarning)):
-        test_support.run_doctest(test_syntax, verbosity=True)
+    support.run_doctest(test_syntax, verbosity=True)
 
 if __name__ == "__main__":
     test_main()
index 5baaa352c0ba76ba8045bb722de8e453604b1126..9342716272a7167a29c057836a8abecb03ec672b 100644 (file)
@@ -748,7 +748,10 @@ class SizeofTest(unittest.TestCase):
         # tupleiterator
         check(iter(()), size('lP'))
         # type
-        s = vsize('P2P15Pl4PP9PP11PI'   # PyTypeObject
+        fmt = 'P2P15Pl4PP9PP11PI'
+        if hasattr(sys, 'getcounts'):
+            fmt += '3P2P'
+        s = vsize(fmt +                 # PyTypeObject
                   '39P'                 # PyNumberMethods
                   '3P'                  # PyMappingMethods
                   '10P'                 # PySequenceMethods
index cc9a5815e4380c960b3982c69a5768736e554169..d8737af3bc8d6c174dd40c8357ed7f92633fe495 100644 (file)
@@ -5,6 +5,19 @@ import unittest
 import sys
 import difflib
 import gc
+from functools import wraps
+
+class tracecontext:
+    """Contex manager that traces its enter and exit."""
+    def __init__(self, output, value):
+        self.output = output
+        self.value = value
+
+    def __enter__(self):
+        self.output.append(self.value)
+
+    def __exit__(self, *exc_info):
+        self.output.append(-self.value)
 
 # A very basic example.  If this fails, we're in deep trouble.
 def basic():
@@ -467,311 +480,528 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
 # command (aka. "Set next statement").
 
 class JumpTracer:
-    """Defines a trace function that jumps from one place to another,
-    with the source and destination lines of the jump being defined by
-    the 'jump' property of the function under test."""
-
-    def __init__(self, function):
-        self.function = function
-        self.jumpFrom = function.jump[0]
-        self.jumpTo = function.jump[1]
+    """Defines a trace function that jumps from one place to another."""
+
+    def __init__(self, function, jumpFrom, jumpTo, event='line',
+                 decorated=False):
+        self.code = function.func_code
+        self.jumpFrom = jumpFrom
+        self.jumpTo = jumpTo
+        self.event = event
+        self.firstLine = None if decorated else self.code.co_firstlineno
         self.done = False
 
     def trace(self, frame, event, arg):
-        if not self.done and frame.f_code == self.function.func_code:
-            firstLine = frame.f_code.co_firstlineno
-            if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom:
+        if self.done:
+            return
+        # frame.f_code.co_firstlineno is the first line of the decorator when
+        # 'function' is decorated and the decorator may be written using
+        # multiple physical lines when it is too long. Use the first line
+        # trace event in 'function' to find the first line of 'function'.
+        if (self.firstLine is None and frame.f_code == self.code and
+                event == 'line'):
+            self.firstLine = frame.f_lineno - 1
+        if (event == self.event and self.firstLine and
+                frame.f_lineno == self.firstLine + self.jumpFrom):
+            f = frame
+            while f is not None and f.f_code != self.code:
+                f = f.f_back
+            if f is not None:
                 # Cope with non-integer self.jumpTo (because of
                 # no_jump_to_non_integers below).
                 try:
-                    frame.f_lineno = firstLine + self.jumpTo
+                    frame.f_lineno = self.firstLine + self.jumpTo
                 except TypeError:
                     frame.f_lineno = self.jumpTo
                 self.done = True
         return self.trace
 
-# The first set of 'jump' tests are for things that are allowed:
+# This verifies the line-numbers-must-be-integers rule.
+def no_jump_to_non_integers(output):
+    try:
+        output.append(2)
+    except ValueError as e:
+        output.append('integer' in str(e))
+
+# This verifies that you can't set f_lineno via _getframe or similar
+# trickery.
+def no_jump_without_trace_function():
+    try:
+        previous_frame = sys._getframe().f_back
+        previous_frame.f_lineno = previous_frame.f_lineno
+    except ValueError as e:
+        # This is the exception we wanted; make sure the error message
+        # talks about trace functions.
+        if 'trace' not in str(e):
+            raise
+    else:
+        # Something's wrong - the expected exception wasn't raised.
+        raise AssertionError("Trace-function-less jump failed to fail")
+
+
+class JumpTestCase(unittest.TestCase):
+    def setUp(self):
+        self.addCleanup(sys.settrace, sys.gettrace())
+        sys.settrace(None)
+
+    def compare_jump_output(self, expected, received):
+        if received != expected:
+            self.fail( "Outputs don't match:\n" +
+                       "Expected: " + repr(expected) + "\n" +
+                       "Received: " + repr(received))
 
-def jump_simple_forwards(output):
-    output.append(1)
-    output.append(2)
-    output.append(3)
+    def run_test(self, func, jumpFrom, jumpTo, expected, error=None,
+                 event='line', decorated=False):
+        tracer = JumpTracer(func, jumpFrom, jumpTo, event, decorated)
+        sys.settrace(tracer.trace)
+        output = []
+        if error is None:
+            func(output)
+        else:
+            with self.assertRaisesRegexp(*error):
+                func(output)
+        sys.settrace(None)
+        self.compare_jump_output(expected, output)
+
+    def jump_test(jumpFrom, jumpTo, expected, error=None, event='line'):
+        """Decorator that creates a test that makes a jump
+        from one place to another in the following code.
+        """
+        def decorator(func):
+            @wraps(func)
+            def test(self):
+                self.run_test(func, jumpFrom, jumpTo, expected,
+                              error=error, event=event, decorated=True)
+            return test
+        return decorator
+
+    ## The first set of 'jump' tests are for things that are allowed:
+
+    @jump_test(1, 3, [3])
+    def test_jump_simple_forwards(output):
+        output.append(1)
+        output.append(2)
+        output.append(3)
 
-jump_simple_forwards.jump = (1, 3)
-jump_simple_forwards.output = [3]
+    @jump_test(2, 1, [1, 1, 2])
+    def test_jump_simple_backwards(output):
+        output.append(1)
+        output.append(2)
 
-def jump_simple_backwards(output):
-    output.append(1)
-    output.append(2)
+    @jump_test(3, 5, [2, 5])
+    def test_jump_out_of_block_forwards(output):
+        for i in 1, 2:
+            output.append(2)
+            for j in [3]:  # Also tests jumping over a block
+                output.append(4)
+        output.append(5)
+
+    @jump_test(6, 1, [1, 3, 5, 1, 3, 5, 6, 7])
+    def test_jump_out_of_block_backwards(output):
+        output.append(1)
+        for i in [1]:
+            output.append(3)
+            for j in [2]:  # Also tests jumping over a block
+                output.append(5)
+            output.append(6)
+        output.append(7)
 
-jump_simple_backwards.jump = (2, 1)
-jump_simple_backwards.output = [1, 1, 2]
+    @jump_test(1, 2, [3])
+    def test_jump_to_codeless_line(output):
+        output.append(1)
+        # Jumping to this line should skip to the next one.
+        output.append(3)
 
-def jump_out_of_block_forwards(output):
-    for i in 1, 2:
+    @jump_test(2, 2, [1, 2, 3])
+    def test_jump_to_same_line(output):
+        output.append(1)
         output.append(2)
-        for j in [3]:  # Also tests jumping over a block
+        output.append(3)
+
+    # Tests jumping within a finally block, and over one.
+    @jump_test(4, 9, [2, 9])
+    def test_jump_in_nested_finally(output):
+        try:
+            output.append(2)
+        finally:
             output.append(4)
-    output.append(5)
+            try:
+                output.append(6)
+            finally:
+                output.append(8)
+            output.append(9)
+
+    @jump_test(6, 7, [2, 7], (ZeroDivisionError, ''))
+    def test_jump_in_nested_finally_2(output):
+        try:
+            output.append(2)
+            1.0/0.0
+            return
+        finally:
+            output.append(6)
+            output.append(7)
+        output.append(8)
 
-jump_out_of_block_forwards.jump = (3, 5)
-jump_out_of_block_forwards.output = [2, 5]
+    @jump_test(6, 11, [2, 11], (ZeroDivisionError, ''))
+    def test_jump_in_nested_finally_3(output):
+        try:
+            output.append(2)
+            1.0/0.0
+            return
+        finally:
+            output.append(6)
+            try:
+                output.append(8)
+            finally:
+                output.append(10)
+            output.append(11)
+        output.append(12)
+
+    @jump_test(3, 4, [1, 4])
+    def test_jump_infinite_while_loop(output):
+        output.append(1)
+        while True:
+            output.append(3)
+        output.append(4)
 
-def jump_out_of_block_backwards(output):
-    output.append(1)
-    for i in [1]:
+    @jump_test(2, 3, [1, 3])
+    def test_jump_forwards_out_of_with_block(output):
+        with tracecontext(output, 1):
+            output.append(2)
         output.append(3)
-        for j in [2]:  # Also tests jumping over a block
-            output.append(5)
-        output.append(6)
-    output.append(7)
 
-jump_out_of_block_backwards.jump = (6, 1)
-jump_out_of_block_backwards.output = [1, 3, 5, 1, 3, 5, 6, 7]
+    @jump_test(3, 1, [1, 2, 1, 2, 3, -2])
+    def test_jump_backwards_out_of_with_block(output):
+        output.append(1)
+        with tracecontext(output, 2):
+            output.append(3)
 
-def jump_to_codeless_line(output):
-    output.append(1)
-    # Jumping to this line should skip to the next one.
-    output.append(3)
+    @jump_test(2, 5, [5])
+    def test_jump_forwards_out_of_try_finally_block(output):
+        try:
+            output.append(2)
+        finally:
+            output.append(4)
+        output.append(5)
 
-jump_to_codeless_line.jump = (1, 2)
-jump_to_codeless_line.output = [3]
+    @jump_test(3, 1, [1, 1, 3, 5])
+    def test_jump_backwards_out_of_try_finally_block(output):
+        output.append(1)
+        try:
+            output.append(3)
+        finally:
+            output.append(5)
 
-def jump_to_same_line(output):
-    output.append(1)
-    output.append(2)
-    output.append(3)
+    @jump_test(2, 6, [6])
+    def test_jump_forwards_out_of_try_except_block(output):
+        try:
+            output.append(2)
+        except:
+            output.append(4)
+            raise
+        output.append(6)
 
-jump_to_same_line.jump = (2, 2)
-jump_to_same_line.output = [1, 2, 3]
+    @jump_test(3, 1, [1, 1, 3])
+    def test_jump_backwards_out_of_try_except_block(output):
+        output.append(1)
+        try:
+            output.append(3)
+        except:
+            output.append(5)
+            raise
 
-# Tests jumping within a finally block, and over one.
-def jump_in_nested_finally(output):
-    try:
-        output.append(2)
-    finally:
-        output.append(4)
+    @jump_test(5, 7, [4, 7, 8])
+    def test_jump_between_except_blocks(output):
         try:
+            1.0/0.0
+        except ZeroDivisionError:
+            output.append(4)
+            output.append(5)
+        except FloatingPointError:
+            output.append(7)
+        output.append(8)
+
+    @jump_test(5, 6, [4, 6, 7])
+    def test_jump_within_except_block(output):
+        try:
+            1.0/0.0
+        except:
+            output.append(4)
+            output.append(5)
             output.append(6)
-        finally:
-            output.append(8)
-        output.append(9)
+        output.append(7)
 
-jump_in_nested_finally.jump = (4, 9)
-jump_in_nested_finally.output = [2, 9]
+    @jump_test(2, 4, [1, 4, 5, -4])
+    def test_jump_across_with(output):
+        output.append(1)
+        with tracecontext(output, 2):
+            output.append(3)
+        with tracecontext(output, 4):
+            output.append(5)
 
-def jump_infinite_while_loop(output):
-    output.append(1)
-    while 1:
-        output.append(2)
-    output.append(3)
+    @jump_test(4, 5, [1, 3, 5, 6])
+    def test_jump_out_of_with_block_within_for_block(output):
+        output.append(1)
+        for i in [1]:
+            with tracecontext(output, 3):
+                output.append(4)
+            output.append(5)
+        output.append(6)
 
-jump_infinite_while_loop.jump = (3, 4)
-jump_infinite_while_loop.output = [1, 3]
+    @jump_test(4, 5, [1, 2, 3, 5, -2, 6])
+    def test_jump_out_of_with_block_within_with_block(output):
+        output.append(1)
+        with tracecontext(output, 2):
+            with tracecontext(output, 3):
+                output.append(4)
+            output.append(5)
+        output.append(6)
 
-# The second set of 'jump' tests are for things that are not allowed:
+    @jump_test(5, 6, [2, 4, 6, 7])
+    def test_jump_out_of_with_block_within_finally_block(output):
+        try:
+            output.append(2)
+        finally:
+            with tracecontext(output, 4):
+                output.append(5)
+            output.append(6)
+        output.append(7)
 
-def no_jump_too_far_forwards(output):
-    try:
-        output.append(2)
-        output.append(3)
-    except ValueError, e:
-        output.append('after' in str(e))
+    @jump_test(8, 11, [1, 3, 5, 11, 12])
+    def test_jump_out_of_complex_nested_blocks(output):
+        output.append(1)
+        for i in [1]:
+            output.append(3)
+            for j in [1, 2]:
+                output.append(5)
+                try:
+                    for k in [1, 2]:
+                        output.append(8)
+                finally:
+                    output.append(10)
+            output.append(11)
+        output.append(12)
+
+    @jump_test(3, 5, [1, 2, 5])
+    def test_jump_out_of_with_assignment(output):
+        output.append(1)
+        with tracecontext(output, 2) \
+                as x:
+            output.append(4)
+        output.append(5)
 
-no_jump_too_far_forwards.jump = (3, 6)
-no_jump_too_far_forwards.output = [2, True]
+    @jump_test(3, 6, [1, 6, 8, 9])
+    def test_jump_over_return_in_try_finally_block(output):
+        output.append(1)
+        try:
+            output.append(3)
+            if not output: # always false
+                return
+            output.append(6)
+        finally:
+            output.append(8)
+        output.append(9)
 
-def no_jump_too_far_backwards(output):
-    try:
-        output.append(2)
-        output.append(3)
-    except ValueError, e:
-        output.append('before' in str(e))
+    @jump_test(5, 8, [1, 3, 8, 10, 11, 13])
+    def test_jump_over_break_in_try_finally_block(output):
+        output.append(1)
+        while True:
+            output.append(3)
+            try:
+                output.append(5)
+                if not output: # always false
+                    break
+                output.append(8)
+            finally:
+                output.append(10)
+            output.append(11)
+            break
+        output.append(13)
+
+    @jump_test(1, 7, [7, 8])
+    def test_jump_over_for_block_before_else(output):
+        output.append(1)
+        if not output:  # always false
+            for i in [3]:
+                output.append(4)
+        else:
+            output.append(6)
+            output.append(7)
+        output.append(8)
 
-no_jump_too_far_backwards.jump = (3, -1)
-no_jump_too_far_backwards.output = [2, True]
+    # The second set of 'jump' tests are for things that are not allowed:
 
-# Test each kind of 'except' line.
-def no_jump_to_except_1(output):
-    try:
+    @jump_test(2, 3, [1], (ValueError, 'after'))
+    def test_no_jump_too_far_forwards(output):
+        output.append(1)
         output.append(2)
-    except:
-        e = sys.exc_info()[1]
-        output.append('except' in str(e))
-
-no_jump_to_except_1.jump = (2, 3)
-no_jump_to_except_1.output = [True]
 
-def no_jump_to_except_2(output):
-    try:
+    @jump_test(2, -2, [1], (ValueError, 'before'))
+    def test_no_jump_too_far_backwards(output):
+        output.append(1)
         output.append(2)
-    except ValueError:
-        e = sys.exc_info()[1]
-        output.append('except' in str(e))
 
-no_jump_to_except_2.jump = (2, 3)
-no_jump_to_except_2.output = [True]
+    # Test each kind of 'except' line.
+    @jump_test(2, 3, [4], (ValueError, 'except'))
+    def test_no_jump_to_except_1(output):
+        try:
+            output.append(2)
+        except:
+            output.append(4)
+            raise
 
-def no_jump_to_except_3(output):
-    try:
-        output.append(2)
-    except ValueError, e:
-        output.append('except' in str(e))
+    @jump_test(2, 3, [4], (ValueError, 'except'))
+    def test_no_jump_to_except_2(output):
+        try:
+            output.append(2)
+        except ValueError:
+            output.append(4)
+            raise
 
-no_jump_to_except_3.jump = (2, 3)
-no_jump_to_except_3.output = [True]
+    @jump_test(2, 3, [4], (ValueError, 'except'))
+    def test_no_jump_to_except_3(output):
+        try:
+            output.append(2)
+        except ValueError as e:
+            output.append(4)
+            raise e
 
-def no_jump_to_except_4(output):
-    try:
-        output.append(2)
-    except (ValueError, RuntimeError), e:
-        output.append('except' in str(e))
+    @jump_test(2, 3, [4], (ValueError, 'except'))
+    def test_no_jump_to_except_4(output):
+        try:
+            output.append(2)
+        except (ValueError, RuntimeError) as e:
+            output.append(4)
+            raise e
 
-no_jump_to_except_4.jump = (2, 3)
-no_jump_to_except_4.output = [True]
+    @jump_test(1, 3, [], (ValueError, 'into'))
+    def test_no_jump_forwards_into_for_block(output):
+        output.append(1)
+        for i in 1, 2:
+            output.append(3)
 
-def no_jump_forwards_into_block(output):
-    try:
-        output.append(2)
+    @jump_test(3, 2, [2, 2], (ValueError, 'into'))
+    def test_no_jump_backwards_into_for_block(output):
         for i in 1, 2:
+            output.append(2)
+        output.append(3)
+
+    @jump_test(2, 4, [], (ValueError, 'into'))
+    def test_no_jump_forwards_into_while_block(output):
+        i = 1
+        output.append(2)
+        while i <= 2:
             output.append(4)
-    except ValueError, e:
-        output.append('into' in str(e))
+            i += 1
 
-no_jump_forwards_into_block.jump = (2, 4)
-no_jump_forwards_into_block.output = [True]
+    @jump_test(5, 3, [3, 3], (ValueError, 'into'))
+    def test_no_jump_backwards_into_while_block(output):
+        i = 1
+        while i <= 2:
+            output.append(3)
+            i += 1
+        output.append(5)
 
-def no_jump_backwards_into_block(output):
-    try:
-        for i in 1, 2:
+    @jump_test(1, 3, [], (ValueError, 'into'))
+    def test_no_jump_forwards_into_with_block(output):
+        output.append(1)
+        with tracecontext(output, 2):
             output.append(3)
-        output.append(4)
-    except ValueError, e:
-        output.append('into' in str(e))
 
-no_jump_backwards_into_block.jump = (4, 3)
-no_jump_backwards_into_block.output = [3, 3, True]
+    @jump_test(3, 2, [1, 2, -1], (ValueError, 'into'))
+    def test_no_jump_backwards_into_with_block(output):
+        with tracecontext(output, 1):
+            output.append(2)
+        output.append(3)
 
-def no_jump_into_finally_block(output):
-    try:
+    @jump_test(1, 3, [], (ValueError, 'into'))
+    def test_no_jump_forwards_into_try_finally_block(output):
+        output.append(1)
         try:
             output.append(3)
-            x = 1
         finally:
-            output.append(6)
-    except ValueError, e:
-        output.append('finally' in str(e))
+            output.append(5)
 
-no_jump_into_finally_block.jump = (4, 6)
-no_jump_into_finally_block.output = [3, 6, True]  # The 'finally' still runs
+    @jump_test(5, 2, [2, 4], (ValueError, 'into'))
+    def test_no_jump_backwards_into_try_finally_block(output):
+        try:
+            output.append(2)
+        finally:
+            output.append(4)
+        output.append(5)
 
-def no_jump_out_of_finally_block(output):
-    try:
+    @jump_test(1, 3, [], (ValueError, 'into'))
+    def test_no_jump_forwards_into_try_except_block(output):
+        output.append(1)
         try:
             output.append(3)
-        finally:
+        except:
             output.append(5)
-            output.append(6)
-    except ValueError, e:
-        output.append('finally' in str(e))
+            raise
 
-no_jump_out_of_finally_block.jump = (5, 1)
-no_jump_out_of_finally_block.output = [3, True]
+    @jump_test(6, 2, [2], (ValueError, 'into'))
+    def test_no_jump_backwards_into_try_except_block(output):
+        try:
+            output.append(2)
+        except:
+            output.append(4)
+            raise
+        output.append(6)
 
-# This verifies the line-numbers-must-be-integers rule.
-def no_jump_to_non_integers(output):
-    try:
-        output.append(2)
-    except ValueError, e:
-        output.append('integer' in str(e))
+    @jump_test(3, 6, [2, 5, 6], (ValueError, 'finally'))
+    def test_no_jump_into_finally_block(output):
+        try:
+            output.append(2)
+            output.append(3)
+        finally:  # still executed if the jump is failed
+            output.append(5)
+            output.append(6)
+        output.append(7)
 
-no_jump_to_non_integers.jump = (2, "Spam")
-no_jump_to_non_integers.output = [True]
+    @jump_test(1, 5, [], (ValueError, 'finally'))
+    def test_no_jump_into_finally_block_2(output):
+        output.append(1)
+        try:
+            output.append(3)
+        finally:
+            output.append(5)
 
-def jump_across_with(output):
-    with open(test_support.TESTFN, "wb") as fp:
-        pass
-    with open(test_support.TESTFN, "wb") as fp:
-        pass
-jump_across_with.jump = (1, 3)
-jump_across_with.output = []
+    @jump_test(5, 1, [1, 3], (ValueError, 'finally'))
+    def test_no_jump_out_of_finally_block(output):
+        output.append(1)
+        try:
+            output.append(3)
+        finally:
+            output.append(5)
 
-# This verifies that you can't set f_lineno via _getframe or similar
-# trickery.
-def no_jump_without_trace_function():
-    try:
-        previous_frame = sys._getframe().f_back
-        previous_frame.f_lineno = previous_frame.f_lineno
-    except ValueError, e:
-        # This is the exception we wanted; make sure the error message
-        # talks about trace functions.
-        if 'trace' not in str(e):
-            raise
-    else:
-        # Something's wrong - the expected exception wasn't raised.
-        raise RuntimeError, "Trace-function-less jump failed to fail"
+    @jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
+    def test_no_jump_between_with_blocks(output):
+        output.append(1)
+        with tracecontext(output, 2):
+            output.append(3)
+        with tracecontext(output, 4):
+            output.append(5)
 
+    @jump_test(7, 4, [1, 6], (ValueError, 'into'))
+    def test_no_jump_into_for_block_before_else(output):
+        output.append(1)
+        if not output:  # always false
+            for i in [3]:
+                output.append(4)
+        else:
+            output.append(6)
+            output.append(7)
+        output.append(8)
 
-class JumpTestCase(unittest.TestCase):
-    def compare_jump_output(self, expected, received):
-        if received != expected:
-            self.fail( "Outputs don't match:\n" +
-                       "Expected: " + repr(expected) + "\n" +
-                       "Received: " + repr(received))
+    def test_no_jump_to_non_integers(self):
+        self.run_test(no_jump_to_non_integers, 2, "Spam", [True])
 
-    def run_test(self, func):
-        tracer = JumpTracer(func)
-        sys.settrace(tracer.trace)
-        output = []
-        func(output)
-        sys.settrace(None)
-        self.compare_jump_output(func.output, output)
-
-    def test_01_jump_simple_forwards(self):
-        self.run_test(jump_simple_forwards)
-    def test_02_jump_simple_backwards(self):
-        self.run_test(jump_simple_backwards)
-    def test_03_jump_out_of_block_forwards(self):
-        self.run_test(jump_out_of_block_forwards)
-    def test_04_jump_out_of_block_backwards(self):
-        self.run_test(jump_out_of_block_backwards)
-    def test_05_jump_to_codeless_line(self):
-        self.run_test(jump_to_codeless_line)
-    def test_06_jump_to_same_line(self):
-        self.run_test(jump_to_same_line)
-    def test_07_jump_in_nested_finally(self):
-        self.run_test(jump_in_nested_finally)
-    def test_jump_infinite_while_loop(self):
-        self.run_test(jump_infinite_while_loop)
-    def test_08_no_jump_too_far_forwards(self):
-        self.run_test(no_jump_too_far_forwards)
-    def test_09_no_jump_too_far_backwards(self):
-        self.run_test(no_jump_too_far_backwards)
-    def test_10_no_jump_to_except_1(self):
-        self.run_test(no_jump_to_except_1)
-    def test_11_no_jump_to_except_2(self):
-        self.run_test(no_jump_to_except_2)
-    def test_12_no_jump_to_except_3(self):
-        self.run_test(no_jump_to_except_3)
-    def test_13_no_jump_to_except_4(self):
-        self.run_test(no_jump_to_except_4)
-    def test_14_no_jump_forwards_into_block(self):
-        self.run_test(no_jump_forwards_into_block)
-    def test_15_no_jump_backwards_into_block(self):
-        self.run_test(no_jump_backwards_into_block)
-    def test_16_no_jump_into_finally_block(self):
-        self.run_test(no_jump_into_finally_block)
-    def test_17_no_jump_out_of_finally_block(self):
-        self.run_test(no_jump_out_of_finally_block)
-    def test_18_no_jump_to_non_integers(self):
-        self.run_test(no_jump_to_non_integers)
-    def test_19_no_jump_without_trace_function(self):
+    def test_no_jump_without_trace_function(self):
+        # Must set sys.settrace(None) in setUp(), else condition is not
+        # triggered.
         no_jump_without_trace_function()
-    def test_jump_across_with(self):
-        self.addCleanup(test_support.unlink, test_support.TESTFN)
-        self.run_test(jump_across_with)
 
-    def test_20_large_function(self):
+    def test_large_function(self):
         d = {}
         exec("""def f(output):        # line 0
             x = 0                     # line 1
@@ -783,10 +1013,7 @@ class JumpTestCase(unittest.TestCase):
             output.append(x)          # line 1007
             return""" % ('\n' * 1000,), d)
         f = d['f']
-
-        f.jump = (2, 1007)
-        f.output = [0]
-        self.run_test(f)
+        self.run_test(f, 2, 1007, [0])
 
     def test_jump_to_firstlineno(self):
         # This tests that PDB can jump back to the first line in a
@@ -800,14 +1027,43 @@ output.append(4)
 """, "<fake module>", "exec")
         class fake_function:
             func_code = code
-            jump = (2, 0)
-        tracer = JumpTracer(fake_function)
+        tracer = JumpTracer(fake_function, 2, 0)
         sys.settrace(tracer.trace)
         namespace = {"output": []}
         exec code in namespace
         sys.settrace(None)
         self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"])
 
+    @jump_test(2, 3, [1], event='call', error=(ValueError, "can't jump from"
+               " the 'call' trace event of a new frame"))
+    def test_no_jump_from_call(output):
+        output.append(1)
+        def nested():
+            output.append(3)
+        nested()
+        output.append(5)
+
+    @jump_test(2, 1, [1], event='return', error=(ValueError,
+               "can only jump from a 'line' trace event"))
+    def test_no_jump_from_return_event(output):
+        output.append(1)
+        return
+
+    @jump_test(2, 1, [1], event='exception', error=(ValueError,
+               "can only jump from a 'line' trace event"))
+    def test_no_jump_from_exception_event(output):
+        output.append(1)
+        1 / 0
+
+    @jump_test(3, 2, [2], event='return', error=(ValueError,
+               "can't jump from a yield statement"))
+    def test_no_jump_from_yield(output):
+        def gen():
+            output.append(2)
+            yield 3
+        next(gen())
+        output.append(5)
+
 
 def test_main():
     test_support.run_unittest(
index 921d094d5a78fea878841f3709ac3d7708114eba..f0c9877862ec0b71c4fe380cbfd2730833c7f053 100644 (file)
@@ -705,25 +705,25 @@ class BigmemTclTest(unittest.TestCase):
         self.check_huge_string_builtins(value)
 
     def check_huge_string_builtins(self, value):
-        self.assertRaises(OverflowError, self.interp.tk.getint, value)
-        self.assertRaises(OverflowError, self.interp.tk.getdouble, value)
-        self.assertRaises(OverflowError, self.interp.tk.getboolean, value)
-        self.assertRaises(OverflowError, self.interp.eval, value)
-        self.assertRaises(OverflowError, self.interp.evalfile, value)
-        self.assertRaises(OverflowError, self.interp.record, value)
-        self.assertRaises(OverflowError, self.interp.adderrorinfo, value)
-        self.assertRaises(OverflowError, self.interp.setvar, value, 'x', 'a')
-        self.assertRaises(OverflowError, self.interp.setvar, 'x', value, 'a')
-        self.assertRaises(OverflowError, self.interp.unsetvar, value)
-        self.assertRaises(OverflowError, self.interp.unsetvar, 'x', value)
-        self.assertRaises(OverflowError, self.interp.adderrorinfo, value)
-        self.assertRaises(OverflowError, self.interp.exprstring, value)
-        self.assertRaises(OverflowError, self.interp.exprlong, value)
-        self.assertRaises(OverflowError, self.interp.exprboolean, value)
-        self.assertRaises(OverflowError, self.interp.splitlist, value)
-        self.assertRaises(OverflowError, self.interp.split, value)
-        self.assertRaises(OverflowError, self.interp.createcommand, value, max)
-        self.assertRaises(OverflowError, self.interp.deletecommand, value)
+        tk = self.interp.tk
+        self.assertRaises(OverflowError, tk.getint, value)
+        self.assertRaises(OverflowError, tk.getdouble, value)
+        self.assertRaises(OverflowError, tk.getboolean, value)
+        self.assertRaises(OverflowError, tk.eval, value)
+        self.assertRaises(OverflowError, tk.evalfile, value)
+        self.assertRaises(OverflowError, tk.record, value)
+        self.assertRaises(OverflowError, tk.adderrorinfo, value)
+        self.assertRaises(OverflowError, tk.setvar, value, 'x', 'a')
+        self.assertRaises(OverflowError, tk.setvar, 'x', value, 'a')
+        self.assertRaises(OverflowError, tk.unsetvar, value)
+        self.assertRaises(OverflowError, tk.unsetvar, 'x', value)
+        self.assertRaises(OverflowError, tk.exprstring, value)
+        self.assertRaises(OverflowError, tk.exprlong, value)
+        self.assertRaises(OverflowError, tk.exprboolean, value)
+        self.assertRaises(OverflowError, tk.splitlist, value)
+        self.assertRaises(OverflowError, tk.split, value)
+        self.assertRaises(OverflowError, tk.createcommand, value, max)
+        self.assertRaises(OverflowError, tk.deletecommand, value)
 
 
 def setUpModule():
index 4c4c62607cb02802d5f3472e0cb249d152c61169..421a9ef8892f80c113fa1e56bbe0185117da2a1e 100644 (file)
@@ -6,8 +6,10 @@ import os
 import unittest
 import socket
 import tempfile
+import textwrap
 import errno
 from test import support
+from test.support import script_helper
 
 TESTFN = support.TESTFN
 
@@ -176,6 +178,34 @@ class TestSupport(unittest.TestCase):
         expected = ['tests may fail, unable to create temp dir: ' + path]
         self.assertEqual(warnings, expected)
 
+    @unittest.skipUnless(hasattr(os, "fork"), "test requires os.fork")
+    def test_temp_dir__forked_child(self):
+        """Test that a forked child process does not remove the directory."""
+        # See bpo-30028 for details.
+        # Run the test as an external script, because it uses fork.
+        script_helper.assert_python_ok("-c", textwrap.dedent("""
+            import os
+            from test import support
+            with support.temp_cwd() as temp_path:
+                pid = os.fork()
+                if pid != 0:
+                    # parent process (child has pid == 0)
+
+                    # wait for the child to terminate
+                    (pid, status) = os.waitpid(pid, 0)
+                    if status != 0:
+                        raise AssertionError("Child process failed with exit "
+                                             "status indication "
+                                             "0x{:x}.".format(status))
+
+                    # Make sure that temp_path is still present. When the child
+                    # process leaves the 'temp_cwd'-context, the __exit__()-
+                    # method of the context must not remove the temporary
+                    # directory.
+                    if not os.path.isdir(temp_path):
+                        raise AssertionError("Child removed temp_path.")
+        """))
+
     # Tests for change_cwd()
 
     def test_change_cwd(self):
@@ -330,6 +360,64 @@ class TestSupport(unittest.TestCase):
             del D["y"]
         self.assertNotIn("y", D)
 
+    def test_match_test(self):
+        class Test:
+            def __init__(self, test_id):
+                self.test_id = test_id
+
+            def id(self):
+                return self.test_id
+
+        test_access = Test('test.test_os.FileTests.test_access')
+        test_chdir = Test('test.test_os.Win32ErrorTests.test_chdir')
+
+        with support.swap_attr(support, '_match_test_func', None):
+            # match all
+            support.set_match_tests([])
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            # match all using None
+            support.set_match_tests(None)
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            # match the full test identifier
+            support.set_match_tests([test_access.id()])
+            self.assertTrue(support.match_test(test_access))
+            self.assertFalse(support.match_test(test_chdir))
+
+            # match the module name
+            support.set_match_tests(['test_os'])
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            # Test '*' pattern
+            support.set_match_tests(['test_*'])
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            # Test case sensitivity
+            support.set_match_tests(['filetests'])
+            self.assertFalse(support.match_test(test_access))
+            support.set_match_tests(['FileTests'])
+            self.assertTrue(support.match_test(test_access))
+
+            # Test pattern containing '.' and a '*' metacharacter
+            support.set_match_tests(['*test_os.*.test_*'])
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            # Multiple patterns
+            support.set_match_tests([test_access.id(), test_chdir.id()])
+            self.assertTrue(support.match_test(test_access))
+            self.assertTrue(support.match_test(test_chdir))
+
+            support.set_match_tests(['test_access', 'DONTMATCH'])
+            self.assertTrue(support.match_test(test_access))
+            self.assertFalse(support.match_test(test_chdir))
+
+
     # XXX -follows a list of untested API
     # make_legacy_pyc
     # is_resource_enabled
index 4571c108d6717701ccacc2aee7aa7e1347406a7c..4da6703c56c7b3e58d8ffcd8ea694975a4c129e7 100644 (file)
@@ -2,6 +2,12 @@ from test import test_support
 import time
 import unittest
 import sys
+import sysconfig
+
+
+# Max year is only limited by the size of C int.
+SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4
+TIME_MAXYEAR = (1 << 8 * SIZEOF_INT - 1) - 1
 
 
 class TimeTestCase(unittest.TestCase):
@@ -45,6 +51,66 @@ class TimeTestCase(unittest.TestCase):
             with self.assertRaises(ValueError):
                 time.strftime('%f')
 
+    def _bounds_checking(self, func):
+        # Make sure that strftime() checks the bounds of the various parts
+        # of the time tuple (0 is valid for *all* values).
+
+        # The year field is tested by other test cases above
+
+        # Check month [1, 12] + zero support
+        func((1900, 0, 1, 0, 0, 0, 0, 1, -1))
+        func((1900, 12, 1, 0, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, -1, 1, 0, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 13, 1, 0, 0, 0, 0, 1, -1))
+        # Check day of month [1, 31] + zero support
+        func((1900, 1, 0, 0, 0, 0, 0, 1, -1))
+        func((1900, 1, 31, 0, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, -1, 0, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 32, 0, 0, 0, 0, 1, -1))
+        # Check hour [0, 23]
+        func((1900, 1, 1, 23, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, -1, 0, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 24, 0, 0, 0, 1, -1))
+        # Check minute [0, 59]
+        func((1900, 1, 1, 0, 59, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, -1, 0, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 60, 0, 0, 1, -1))
+        # Check second [0, 61]
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 0, -1, 0, 1, -1))
+        # C99 only requires allowing for one leap second, but Python's docs say
+        # allow two leap seconds (0..61)
+        func((1900, 1, 1, 0, 0, 60, 0, 1, -1))
+        func((1900, 1, 1, 0, 0, 61, 0, 1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 0, 62, 0, 1, -1))
+        # No check for upper-bound day of week;
+        #  value forced into range by a ``% 7`` calculation.
+        # Start check at -2 since gettmarg() increments value before taking
+        #  modulo.
+        self.assertEqual(func((1900, 1, 1, 0, 0, 0, -1, 1, -1)),
+                         func((1900, 1, 1, 0, 0, 0, +6, 1, -1)))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 0, 0, -2, 1, -1))
+        # Check day of the year [1, 366] + zero support
+        func((1900, 1, 1, 0, 0, 0, 0, 0, -1))
+        func((1900, 1, 1, 0, 0, 0, 0, 366, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 0, 0, 0, -1, -1))
+        self.assertRaises(ValueError, func,
+                            (1900, 1, 1, 0, 0, 0, 0, 367, -1))
+
+    def test_strftime_bounding_check(self):
+        self._bounds_checking(lambda tup: time.strftime('', tup))
+
     def test_strftime_bounds_checking(self):
         # Make sure that strftime() checks the bounds of the various parts
         #of the time tuple (0 is valid for *all* values).
@@ -123,15 +189,15 @@ class TimeTestCase(unittest.TestCase):
         time.asctime(time.gmtime(self.t))
         self.assertRaises(TypeError, time.asctime, 0)
         self.assertRaises(TypeError, time.asctime, ())
-        # XXX: Posix compiant asctime should refuse to convert
-        # year > 9999, but Linux implementation does not.
-        # self.assertRaises(ValueError, time.asctime,
-        #                  (12345, 1, 0, 0, 0, 0, 0, 0, 0))
-        # XXX: For now, just make sure we don't have a crash:
-        try:
-            time.asctime((12345, 1, 1, 0, 0, 0, 0, 1, 0))
-        except ValueError:
-            pass
+
+        # Max year is only limited by the size of C int.
+        asc = time.asctime((TIME_MAXYEAR, 6, 1) + (0,) * 6)
+        self.assertEqual(asc[-len(str(TIME_MAXYEAR)):], str(TIME_MAXYEAR))
+        self.assertRaises(OverflowError, time.asctime,
+                          (TIME_MAXYEAR + 1,) + (0,) * 8)
+        self.assertRaises(TypeError, time.asctime, 0)
+        self.assertRaises(TypeError, time.asctime, ())
+        self.assertRaises(TypeError, time.asctime, (0,) * 10)
 
     @unittest.skipIf(not hasattr(time, "tzset"),
         "time module has no attribute tzset")
index 061233f9f2f2544833620b32ebc22fcb0c3537c0..932b57223a5652c373d896a4ccba09ae833aa1a2 100644 (file)
@@ -577,7 +577,7 @@ class TestUrlopen(BaseTestCase):
         sni_name = [None]
         def cb_sni(ssl_sock, server_name, initial_context):
             sni_name[0] = server_name
-        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        context = ssl.SSLContext(ssl.PROTOCOL_TLS)
         context.set_servername_callback(cb_sni)
         handler = self.start_https_server(context=context, certfile=CERT_localhost)
         context = ssl.create_default_context(cafile=CERT_localhost)
index 0a8130ee0c7c46b505ce9ec68c347342e9eaf6ba..3749564c930e392920d231117bff0fe6a16e4b24 100644 (file)
@@ -429,54 +429,52 @@ eth0      Link encap:Ethernet  HWaddr 12:34:56:78:90:ab
             )
             self.assertEqual(mac, 0x1234567890ab)
 
-    def check_node(self, node, requires=None, network=False):
+    def check_node(self, node, requires=None):
         if requires and node is None:
             self.skipTest('requires ' + requires)
         hex = '%012x' % node
         if test_support.verbose >= 2:
             print hex + ' ',
-        if network:
-            # 47 bit will never be set in IEEE 802 addresses obtained
-            # from network cards.
-            self.assertFalse(node & 0x010000000000, hex)
         self.assertTrue(0 < node < (1L << 48),
                         "%s is not an RFC 4122 node ID" % hex)
 
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_ifconfig_getnode(self):
         node = uuid._ifconfig_getnode()
-        self.check_node(node, 'ifconfig', True)
+        self.check_node(node, 'ifconfig')
 
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_arp_getnode(self):
         node = uuid._arp_getnode()
-        self.check_node(node, 'arp', True)
+        self.check_node(node, 'arp')
 
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_lanscan_getnode(self):
         node = uuid._lanscan_getnode()
-        self.check_node(node, 'lanscan', True)
+        self.check_node(node, 'lanscan')
 
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_netstat_getnode(self):
         node = uuid._netstat_getnode()
-        self.check_node(node, 'netstat', True)
+        self.check_node(node, 'netstat')
 
     @unittest.skipUnless(os.name == 'nt', 'requires Windows')
     def test_ipconfig_getnode(self):
         node = uuid._ipconfig_getnode()
-        self.check_node(node, 'ipconfig', True)
+        self.check_node(node, 'ipconfig')
 
     @unittest.skipUnless(importable('win32wnet'), 'requires win32wnet')
     @unittest.skipUnless(importable('netbios'), 'requires netbios')
     def test_netbios_getnode(self):
         node = uuid._netbios_getnode()
-        self.check_node(node, network=True)
+        self.check_node(node)
 
     def test_random_getnode(self):
         node = uuid._random_getnode()
-        # Least significant bit of first octet must be set.
-        self.assertTrue(node & 0x010000000000, '%012x' % node)
+        # The multicast bit, i.e. the least significant bit of first octet,
+        # must be set for randomly generated MAC addresses.  See RFC 4122,
+        # $4.1.6.
+        self.assertTrue(node & (1 << 40), '%012x' % node)
         self.check_node(node)
 
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
index 607d9f9b7220c855f10a3419b30cb57498e5df3f..ae081eeee3f75a857afbdbe9e19ba7366831a258 100644 (file)
@@ -584,6 +584,38 @@ class _WarningsTests(BaseTest):
         self.assertNotIn(b'Warning!', stderr)
         self.assertNotIn(b'Error', stderr)
 
+    def test_issue31285(self):
+        # warn_explicit() shouldn't raise a SystemError in case the return
+        # value of get_source() has a bad splitlines() method.
+        class BadLoader:
+            def get_source(self, fullname):
+                class BadSource(str):
+                    def splitlines(self):
+                        return 42
+                return BadSource('spam')
+
+        wmod = self.module
+        with original_warnings.catch_warnings(module=wmod):
+            wmod.filterwarnings('default', category=UserWarning)
+
+            with test_support.captured_stderr() as stderr:
+                wmod.warn_explicit(
+                    'foo', UserWarning, 'bar', 1,
+                    module_globals={'__loader__': BadLoader(),
+                                    '__name__': 'foobar'})
+            self.assertIn('UserWarning: foo', stderr.getvalue())
+
+    @test_support.cpython_only
+    def test_issue31411(self):
+        # warn_explicit() shouldn't raise a SystemError in case
+        # warnings.onceregistry isn't a dictionary.
+        wmod = self.module
+        with original_warnings.catch_warnings(module=wmod):
+            wmod.filterwarnings('once')
+            with test_support.swap_attr(wmod, 'onceregistry', None):
+                with self.assertRaises(TypeError):
+                    wmod.warn_explicit('foo', Warning, 'bar', 1, registry=None)
+
 
 class WarningsDisplayTests(unittest.TestCase):
 
index 415d5ebbd728bf85cd444cee8c85c83c1b8b0b17..418481dadd8f596d26f91b48b58a5992a0206930 100644 (file)
@@ -601,6 +601,7 @@ class ReferencesTestCase(TestBase):
         del c1, c2, C, D
         gc.collect()
 
+    @test_support.requires_type_collecting
     def test_callback_in_cycle_resurrection(self):
         import gc
 
index 60b26ead7a2a121e459a4509198156a7efd0bc3c..c75d55f05c17cd5968b276db4beb35608a75d540 100644 (file)
@@ -30,6 +30,7 @@ ET = None
 
 SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata")
 SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata")
+UTF8_BUG_XMLFILE = findfile("expat224_utf8_bug.xml", subdir="xmltestdata")
 
 SAMPLE_XML = """\
 <body>
@@ -135,6 +136,13 @@ def python_only(test):
         return test(*args)
     return wrapper
 
+def cet_only(test):
+    def wrapper(*args):
+        if ET is pyET:
+            raise unittest.SkipTest('only for the C version')
+        return test(*args)
+    return wrapper
+
 # --------------------------------------------------------------------
 # element tree tests
 
@@ -1338,6 +1346,7 @@ class BugsTest(unittest.TestCase):
         self.assertEqual(t.find('.//paragraph').text,
             u'A new cultivar of Begonia plant named \u2018BCT9801BEG\u2019.')
 
+    @unittest.skipIf(sys.gettrace(), "Skips under coverage.")
     def test_bug_xmltoolkit63(self):
         # Check reference leak.
         def xmltoolkit63():
@@ -1493,6 +1502,36 @@ class BugsTest(unittest.TestCase):
         ET.register_namespace('test10777', 'http://myuri/')
         ET.register_namespace('test10777', 'http://myuri/')
 
+    def check_expat224_utf8_bug(self, text):
+        xml = b'<a b="%s"/>' % text
+        root = ET.XML(xml)
+        self.assertEqual(root.get('b'), text.decode('utf-8'))
+
+    def test_expat224_utf8_bug(self):
+        # bpo-31170: Expat 2.2.3 had a bug in its UTF-8 decoder.
+        # Check that Expat 2.2.4 fixed the bug.
+        #
+        # Test buffer bounds at odd and even positions.
+
+        text = b'\xc3\xa0' * 1024
+        self.check_expat224_utf8_bug(text)
+
+        text = b'x' + b'\xc3\xa0' * 1024
+        self.check_expat224_utf8_bug(text)
+
+    def test_expat224_utf8_bug_file(self):
+        with open(UTF8_BUG_XMLFILE, 'rb') as fp:
+            raw = fp.read()
+        root = ET.fromstring(raw)
+        xmlattr = root.get('b')
+
+        # "Parse" manually the XML file to extract the value of the 'b'
+        # attribute of the <a b='xxx' /> XML element
+        text = raw.decode('utf-8').strip()
+        text = text.replace('\r\n', ' ')
+        text = text[6:-4]
+        self.assertEqual(root.get('b'), text)
+
 
 # --------------------------------------------------------------------
 
@@ -2197,6 +2236,32 @@ class TreeBuilderTest(unittest.TestCase):
             ('html', '-//W3C//DTD XHTML 1.0 Transitional//EN',
              'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'))
 
+    @cet_only  # PyET does not look up the attributes in XMLParser().__init__()
+    def test_builder_lookup_errors(self):
+        class RaisingBuilder(object):
+            def __init__(self, raise_in=None, what=ValueError):
+                self.raise_in = raise_in
+                self.what = what
+
+            def __getattr__(self, name):
+                if name == self.raise_in:
+                    raise self.what(self.raise_in)
+                def handle(*args):
+                    pass
+                return handle
+
+        ET.XMLParser(target=RaisingBuilder())
+        # cET also checks for 'close' and 'doctype', PyET does it only at need
+        for event in ('start', 'data', 'end', 'comment', 'pi'):
+            with self.assertRaises(ValueError):
+                ET.XMLParser(target=RaisingBuilder(event))
+
+        ET.XMLParser(target=RaisingBuilder(what=AttributeError))
+        for event in ('start', 'data', 'end', 'comment', 'pi'):
+            parser = ET.XMLParser(target=RaisingBuilder(event, what=AttributeError))
+            parser.feed(self.sample1)
+            self.assertIsNone(parser.close())
+
 
 class XMLParserTest(unittest.TestCase):
     sample1 = b'<file><line>22</line></file>'
index e122b3db2438c1049da4bfe8258a57534df873bc..71a755c0a649695e2a5a6992726a6d70b5ca9eed 100644 (file)
@@ -53,6 +53,31 @@ class MiscTests(unittest.TestCase):
             del element.attrib
         self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'})
 
+    def test_bpo_31728(self):
+        # A crash shouldn't happen in case garbage collection triggers a call
+        # to clear() or a reading of text or tail, while a setter or clear()
+        # is already running.
+        elem = cET.Element('elem')
+        class X:
+            def __del__(self):
+                elem.text
+                elem.tail
+                elem.clear()
+
+        elem.text = X()
+        elem.clear()  # shouldn't crash
+
+        elem.tail = X()
+        elem.clear()  # shouldn't crash
+
+        elem.text = X()
+        elem.text = X()  # shouldn't crash
+        elem.clear()
+
+        elem.tail = X()
+        elem.tail = X()  # shouldn't crash
+        elem.clear()
+
 
 def test_main():
     from test import test_xml_etree, test_xml_etree_c
diff --git a/Lib/test/xmltestdata/expat224_utf8_bug.xml b/Lib/test/xmltestdata/expat224_utf8_bug.xml
new file mode 100644 (file)
index 0000000..d66a8e6
--- /dev/null
@@ -0,0 +1,2 @@
+<a b='01234567890123456古人咏雪抽幽思骋妍辞竞险韵偶得一编奇绝辄擅美当时流声后代是以北门之风南山之雅梁园之简黄台之赋至今为作家称述尚矣及至洛阳之卧剡溪之兴灞桥之思亦皆传为故事钱塘沈履德先生隐居西湖两峰间孤高贞洁与雪同调方大雪满天皴肤粟背之际先生乃鹿中豹舄端居闭门或扶童曳杖踏遍六桥三竺时取古人诗讽咏之合唐宋元诸名家集句成诗得二百四十章联络通穿如出一人如呵一气气立于言表格备于篇中略无掇拾补凑之形非胸次包罗壮阔笔底驱走鲍谢欧苏诸公不能为此世称王荆公为集句擅长观其在钟山对雪仅题数篇未见有此噫嘻奇矣哉亦富矣哉予慕先生有袁安之节愧不能为慧可之立乃取新集命工传写使海内同好者知先生为博古传述之士而一新世人之耳目他日必有慕潜德阐幽光而剞劂以传者余实为之执殳矣\r
+弘治戊午仲冬望日慈溪杨子器衵于海虞官舍序毕诗部' />\r
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
new file mode 100644 (file)
index 0000000..5b0e29c
--- /dev/null
@@ -0,0 +1,1872 @@
+import unittest
+import tkinter
+from tkinter import ttk, TclError
+from test.support import requires
+import sys
+
+from tkinter.test.test_ttk.test_functions import MockTclObj
+from tkinter.test.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
+                                  simulate_mouse_click)
+from tkinter.test.widget_tests import (add_standard_options, noconv,
+    AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
+    setUpModule)
+
+requires('gui')
+
+
+class StandardTtkOptionsTests(StandardOptionsTests):
+
+    def test_class(self):
+        widget = self.create()
+        self.assertEqual(widget['class'], '')
+        errmsg='attempt to change read-only option'
+        if get_tk_patchlevel() < (8, 6, 0, 'beta', 3):
+            errmsg='Attempt to change read-only option'
+        self.checkInvalidParam(widget, 'class', 'Foo', errmsg=errmsg)
+        widget2 = self.create(class_='Foo')
+        self.assertEqual(widget2['class'], 'Foo')
+
+    def test_padding(self):
+        widget = self.create()
+        self.checkParam(widget, 'padding', 0, expected=('0',))
+        self.checkParam(widget, 'padding', 5, expected=('5',))
+        self.checkParam(widget, 'padding', (5, 6), expected=('5', '6'))
+        self.checkParam(widget, 'padding', (5, 6, 7),
+                        expected=('5', '6', '7'))
+        self.checkParam(widget, 'padding', (5, 6, 7, 8),
+                        expected=('5', '6', '7', '8'))
+        self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
+        self.checkParam(widget, 'padding', (), expected='')
+
+    def test_style(self):
+        widget = self.create()
+        self.assertEqual(widget['style'], '')
+        errmsg = 'Layout Foo not found'
+        if hasattr(self, 'default_orient'):
+            errmsg = ('Layout %s.Foo not found' %
+                      getattr(self, 'default_orient').title())
+        self.checkInvalidParam(widget, 'style', 'Foo',
+                errmsg=errmsg)
+        widget2 = self.create(class_='Foo')
+        self.assertEqual(widget2['class'], 'Foo')
+        # XXX
+        pass
+
+
+class WidgetTest(AbstractTkTest, unittest.TestCase):
+    """Tests methods available in every ttk widget."""
+
+    def setUp(self):
+        super().setUp()
+        self.widget = ttk.Button(self.root, width=0, text="Text")
+        self.widget.pack()
+        self.widget.wait_visibility()
+
+
+    def test_identify(self):
+        self.widget.update_idletasks()
+        self.assertEqual(self.widget.identify(
+            int(self.widget.winfo_width() / 2),
+            int(self.widget.winfo_height() / 2)
+            ), "label")
+        self.assertEqual(self.widget.identify(-1, -1), "")
+
+        self.assertRaises(tkinter.TclError, self.widget.identify, None, 5)
+        self.assertRaises(tkinter.TclError, self.widget.identify, 5, None)
+        self.assertRaises(tkinter.TclError, self.widget.identify, 5, '')
+
+
+    def test_widget_state(self):
+        # XXX not sure about the portability of all these tests
+        self.assertEqual(self.widget.state(), ())
+        self.assertEqual(self.widget.instate(['!disabled']), True)
+
+        # changing from !disabled to disabled
+        self.assertEqual(self.widget.state(['disabled']), ('!disabled', ))
+        # no state change
+        self.assertEqual(self.widget.state(['disabled']), ())
+        # change back to !disable but also active
+        self.assertEqual(self.widget.state(['!disabled', 'active']),
+            ('!active', 'disabled'))
+        # no state changes, again
+        self.assertEqual(self.widget.state(['!disabled', 'active']), ())
+        self.assertEqual(self.widget.state(['active', '!disabled']), ())
+
+        def test_cb(arg1, **kw):
+            return arg1, kw
+        self.assertEqual(self.widget.instate(['!disabled'],
+            test_cb, "hi", **{"msg": "there"}),
+            ('hi', {'msg': 'there'}))
+
+        # attempt to set invalid statespec
+        currstate = self.widget.state()
+        self.assertRaises(tkinter.TclError, self.widget.instate,
+            ['badstate'])
+        self.assertRaises(tkinter.TclError, self.widget.instate,
+            ['disabled', 'badstate'])
+        # verify that widget didn't change its state
+        self.assertEqual(currstate, self.widget.state())
+
+        # ensuring that passing None as state doesn't modify current state
+        self.widget.state(['active', '!disabled'])
+        self.assertEqual(self.widget.state(), ('active', ))
+
+
+class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
+    _conv_pixels = noconv
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class FrameTest(AbstractToplevelTest, unittest.TestCase):
+    OPTIONS = (
+        'borderwidth', 'class', 'cursor', 'height',
+        'padding', 'relief', 'style', 'takefocus',
+        'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.Frame(self.root, **kwargs)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
+    OPTIONS = (
+        'borderwidth', 'class', 'cursor', 'height',
+        'labelanchor', 'labelwidget',
+        'padding', 'relief', 'style', 'takefocus',
+        'text', 'underline', 'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.LabelFrame(self.root, **kwargs)
+
+    def test_labelanchor(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'labelanchor',
+                'e', 'en', 'es', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w', 'wn', 'ws',
+                errmsg='Bad label anchor specification {}')
+        self.checkInvalidParam(widget, 'labelanchor', 'center')
+
+    def test_labelwidget(self):
+        widget = self.create()
+        label = ttk.Label(self.root, text='Mupp', name='foo')
+        self.checkParam(widget, 'labelwidget', label, expected='.foo')
+        label.destroy()
+
+
+class AbstractLabelTest(AbstractWidgetTest):
+
+    def checkImageParam(self, widget, name):
+        image = tkinter.PhotoImage(master=self.root, name='image1')
+        image2 = tkinter.PhotoImage(master=self.root, name='image2')
+        self.checkParam(widget, name, image, expected=('image1',))
+        self.checkParam(widget, name, 'image1', expected=('image1',))
+        self.checkParam(widget, name, (image,), expected=('image1',))
+        self.checkParam(widget, name, (image, 'active', image2),
+                        expected=('image1', 'active', 'image2'))
+        self.checkParam(widget, name, 'image1 active image2',
+                        expected=('image1', 'active', 'image2'))
+        self.checkInvalidParam(widget, name, 'spam',
+                errmsg='image "spam" doesn\'t exist')
+
+    def test_compound(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'compound',
+                'none', 'text', 'image', 'center',
+                'top', 'bottom', 'left', 'right')
+
+    def test_state(self):
+        widget = self.create()
+        self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
+
+    def test_width(self):
+        widget = self.create()
+        self.checkParams(widget, 'width', 402, -402, 0)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class LabelTest(AbstractLabelTest, unittest.TestCase):
+    OPTIONS = (
+        'anchor', 'background', 'borderwidth',
+        'class', 'compound', 'cursor', 'font', 'foreground',
+        'image', 'justify', 'padding', 'relief', 'state', 'style',
+        'takefocus', 'text', 'textvariable',
+        'underline', 'width', 'wraplength',
+    )
+    _conv_pixels = noconv
+
+    def create(self, **kwargs):
+        return ttk.Label(self.root, **kwargs)
+
+    def test_font(self):
+        widget = self.create()
+        self.checkParam(widget, 'font',
+                        '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class ButtonTest(AbstractLabelTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'command', 'compound', 'cursor', 'default',
+        'image', 'padding', 'state', 'style',
+        'takefocus', 'text', 'textvariable',
+        'underline', 'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.Button(self.root, **kwargs)
+
+    def test_default(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'default', 'normal', 'active', 'disabled')
+
+    def test_invoke(self):
+        success = []
+        btn = ttk.Button(self.root, command=lambda: success.append(1))
+        btn.invoke()
+        self.assertTrue(success)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'command', 'compound', 'cursor',
+        'image',
+        'offvalue', 'onvalue',
+        'padding', 'state', 'style',
+        'takefocus', 'text', 'textvariable',
+        'underline', 'variable', 'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.Checkbutton(self.root, **kwargs)
+
+    def test_offvalue(self):
+        widget = self.create()
+        self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string')
+
+    def test_onvalue(self):
+        widget = self.create()
+        self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string')
+
+    def test_invoke(self):
+        success = []
+        def cb_test():
+            success.append(1)
+            return "cb test called"
+
+        cbtn = ttk.Checkbutton(self.root, command=cb_test)
+        # the variable automatically created by ttk.Checkbutton is actually
+        # undefined till we invoke the Checkbutton
+        self.assertEqual(cbtn.state(), ('alternate', ))
+        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
+            cbtn['variable'])
+
+        res = cbtn.invoke()
+        self.assertEqual(res, "cb test called")
+        self.assertEqual(cbtn['onvalue'],
+            cbtn.tk.globalgetvar(cbtn['variable']))
+        self.assertTrue(success)
+
+        cbtn['command'] = ''
+        res = cbtn.invoke()
+        self.assertFalse(str(res))
+        self.assertLessEqual(len(success), 1)
+        self.assertEqual(cbtn['offvalue'],
+            cbtn.tk.globalgetvar(cbtn['variable']))
+
+
+@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
+class EntryTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'background', 'class', 'cursor',
+        'exportselection', 'font', 'foreground',
+        'invalidcommand', 'justify',
+        'show', 'state', 'style', 'takefocus', 'textvariable',
+        'validate', 'validatecommand', 'width', 'xscrollcommand',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.entry = self.create()
+
+    def create(self, **kwargs):
+        return ttk.Entry(self.root, **kwargs)
+
+    def test_invalidcommand(self):
+        widget = self.create()
+        self.checkCommandParam(widget, 'invalidcommand')
+
+    def test_show(self):
+        widget = self.create()
+        self.checkParam(widget, 'show', '*')
+        self.checkParam(widget, 'show', '')
+        self.checkParam(widget, 'show', ' ')
+
+    def test_state(self):
+        widget = self.create()
+        self.checkParams(widget, 'state',
+                         'disabled', 'normal', 'readonly')
+
+    def test_validate(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'validate',
+                'all', 'key', 'focus', 'focusin', 'focusout', 'none')
+
+    def test_validatecommand(self):
+        widget = self.create()
+        self.checkCommandParam(widget, 'validatecommand')
+
+
+    def test_bbox(self):
+        self.assertIsBoundingBox(self.entry.bbox(0))
+        self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex')
+        self.assertRaises(tkinter.TclError, self.entry.bbox, None)
+
+
+    def test_identify(self):
+        self.entry.pack()
+        self.entry.wait_visibility()
+        self.entry.update_idletasks()
+
+        self.assertEqual(self.entry.identify(5, 5), "textarea")
+        self.assertEqual(self.entry.identify(-1, -1), "")
+
+        self.assertRaises(tkinter.TclError, self.entry.identify, None, 5)
+        self.assertRaises(tkinter.TclError, self.entry.identify, 5, None)
+        self.assertRaises(tkinter.TclError, self.entry.identify, 5, '')
+
+
+    def test_validation_options(self):
+        success = []
+        test_invalid = lambda: success.append(True)
+
+        self.entry['validate'] = 'none'
+        self.entry['validatecommand'] = lambda: False
+
+        self.entry['invalidcommand'] = test_invalid
+        self.entry.validate()
+        self.assertTrue(success)
+
+        self.entry['invalidcommand'] = ''
+        self.entry.validate()
+        self.assertEqual(len(success), 1)
+
+        self.entry['invalidcommand'] = test_invalid
+        self.entry['validatecommand'] = lambda: True
+        self.entry.validate()
+        self.assertEqual(len(success), 1)
+
+        self.entry['validatecommand'] = ''
+        self.entry.validate()
+        self.assertEqual(len(success), 1)
+
+        self.entry['validatecommand'] = True
+        self.assertRaises(tkinter.TclError, self.entry.validate)
+
+
+    def test_validation(self):
+        validation = []
+        def validate(to_insert):
+            if not 'a' <= to_insert.lower() <= 'z':
+                validation.append(False)
+                return False
+            validation.append(True)
+            return True
+
+        self.entry['validate'] = 'key'
+        self.entry['validatecommand'] = self.entry.register(validate), '%S'
+
+        self.entry.insert('end', 1)
+        self.entry.insert('end', 'a')
+        self.assertEqual(validation, [False, True])
+        self.assertEqual(self.entry.get(), 'a')
+
+
+    def test_revalidation(self):
+        def validate(content):
+            for letter in content:
+                if not 'a' <= letter.lower() <= 'z':
+                    return False
+            return True
+
+        self.entry['validatecommand'] = self.entry.register(validate), '%P'
+
+        self.entry.insert('end', 'avocado')
+        self.assertEqual(self.entry.validate(), True)
+        self.assertEqual(self.entry.state(), ())
+
+        self.entry.delete(0, 'end')
+        self.assertEqual(self.entry.get(), '')
+
+        self.entry.insert('end', 'a1b')
+        self.assertEqual(self.entry.validate(), False)
+        self.assertEqual(self.entry.state(), ('invalid', ))
+
+        self.entry.delete(1)
+        self.assertEqual(self.entry.validate(), True)
+        self.assertEqual(self.entry.state(), ())
+
+
+@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
+class ComboboxTest(EntryTest, unittest.TestCase):
+    OPTIONS = (
+        'background', 'class', 'cursor', 'exportselection',
+        'font', 'foreground', 'height', 'invalidcommand',
+        'justify', 'postcommand', 'show', 'state', 'style',
+        'takefocus', 'textvariable',
+        'validate', 'validatecommand', 'values',
+        'width', 'xscrollcommand',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.combo = self.create()
+
+    def create(self, **kwargs):
+        return ttk.Combobox(self.root, **kwargs)
+
+    def test_height(self):
+        widget = self.create()
+        self.checkParams(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i')
+
+    def _show_drop_down_listbox(self):
+        width = self.combo.winfo_width()
+        self.combo.event_generate('<ButtonPress-1>', x=width - 5, y=5)
+        self.combo.event_generate('<ButtonRelease-1>', x=width - 5, y=5)
+        self.combo.update_idletasks()
+
+
+    def test_virtual_event(self):
+        success = []
+
+        self.combo['values'] = [1]
+        self.combo.bind('<<ComboboxSelected>>',
+            lambda evt: success.append(True))
+        self.combo.pack()
+        self.combo.wait_visibility()
+
+        height = self.combo.winfo_height()
+        self._show_drop_down_listbox()
+        self.combo.update()
+        self.combo.event_generate('<Return>')
+        self.combo.update()
+
+        self.assertTrue(success)
+
+
+    def test_postcommand(self):
+        success = []
+
+        self.combo['postcommand'] = lambda: success.append(True)
+        self.combo.pack()
+        self.combo.wait_visibility()
+
+        self._show_drop_down_listbox()
+        self.assertTrue(success)
+
+        # testing postcommand removal
+        self.combo['postcommand'] = ''
+        self._show_drop_down_listbox()
+        self.assertEqual(len(success), 1)
+
+
+    def test_values(self):
+        def check_get_current(getval, currval):
+            self.assertEqual(self.combo.get(), getval)
+            self.assertEqual(self.combo.current(), currval)
+
+        self.assertEqual(self.combo['values'],
+                         () if tcl_version < (8, 5) else '')
+        check_get_current('', -1)
+
+        self.checkParam(self.combo, 'values', 'mon tue wed thur',
+                        expected=('mon', 'tue', 'wed', 'thur'))
+        self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur'))
+        self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string'))
+        self.checkParam(self.combo, 'values', '',
+                        expected='' if get_tk_patchlevel() < (8, 5, 10) else ())
+
+        self.combo['values'] = ['a', 1, 'c']
+
+        self.combo.set('c')
+        check_get_current('c', 2)
+
+        self.combo.current(0)
+        check_get_current('a', 0)
+
+        self.combo.set('d')
+        check_get_current('d', -1)
+
+        # testing values with empty string
+        self.combo.set('')
+        self.combo['values'] = (1, 2, '', 3)
+        check_get_current('', 2)
+
+        # testing values with empty string set through configure
+        self.combo.configure(values=[1, '', 2])
+        self.assertEqual(self.combo['values'],
+                         ('1', '', '2') if self.wantobjects else
+                         '1 {} 2')
+
+        # testing values with spaces
+        self.combo['values'] = ['a b', 'a\tb', 'a\nb']
+        self.assertEqual(self.combo['values'],
+                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
+                         '{a b} {a\tb} {a\nb}')
+
+        # testing values with special characters
+        self.combo['values'] = [r'a\tb', '"a"', '} {']
+        self.assertEqual(self.combo['values'],
+                         (r'a\tb', '"a"', '} {') if self.wantobjects else
+                         r'a\\tb {"a"} \}\ \{')
+
+        # out of range
+        self.assertRaises(tkinter.TclError, self.combo.current,
+            len(self.combo['values']))
+        # it expects an integer (or something that can be converted to int)
+        self.assertRaises(tkinter.TclError, self.combo.current, '')
+
+        # testing creating combobox with empty string in values
+        combo2 = ttk.Combobox(self.root, values=[1, 2, ''])
+        self.assertEqual(combo2['values'],
+                         ('1', '2', '') if self.wantobjects else '1 2 {}')
+        combo2.destroy()
+
+
+@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
+class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'cursor', 'height',
+        'orient', 'style', 'takefocus', 'width',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.paned = self.create()
+
+    def create(self, **kwargs):
+        return ttk.PanedWindow(self.root, **kwargs)
+
+    def test_orient(self):
+        widget = self.create()
+        self.assertEqual(str(widget['orient']), 'vertical')
+        errmsg='attempt to change read-only option'
+        if get_tk_patchlevel() < (8, 6, 0, 'beta', 3):
+            errmsg='Attempt to change read-only option'
+        self.checkInvalidParam(widget, 'orient', 'horizontal',
+                errmsg=errmsg)
+        widget2 = self.create(orient='horizontal')
+        self.assertEqual(str(widget2['orient']), 'horizontal')
+
+    def test_add(self):
+        # attempt to add a child that is not a direct child of the paned window
+        label = ttk.Label(self.paned)
+        child = ttk.Label(label)
+        self.assertRaises(tkinter.TclError, self.paned.add, child)
+        label.destroy()
+        child.destroy()
+        # another attempt
+        label = ttk.Label(self.root)
+        child = ttk.Label(label)
+        self.assertRaises(tkinter.TclError, self.paned.add, child)
+        child.destroy()
+        label.destroy()
+
+        good_child = ttk.Label(self.root)
+        self.paned.add(good_child)
+        # re-adding a child is not accepted
+        self.assertRaises(tkinter.TclError, self.paned.add, good_child)
+
+        other_child = ttk.Label(self.paned)
+        self.paned.add(other_child)
+        self.assertEqual(self.paned.pane(0), self.paned.pane(1))
+        self.assertRaises(tkinter.TclError, self.paned.pane, 2)
+        good_child.destroy()
+        other_child.destroy()
+        self.assertRaises(tkinter.TclError, self.paned.pane, 0)
+
+
+    def test_forget(self):
+        self.assertRaises(tkinter.TclError, self.paned.forget, None)
+        self.assertRaises(tkinter.TclError, self.paned.forget, 0)
+
+        self.paned.add(ttk.Label(self.root))
+        self.paned.forget(0)
+        self.assertRaises(tkinter.TclError, self.paned.forget, 0)
+
+
+    def test_insert(self):
+        self.assertRaises(tkinter.TclError, self.paned.insert, None, 0)
+        self.assertRaises(tkinter.TclError, self.paned.insert, 0, None)
+        self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0)
+
+        child = ttk.Label(self.root)
+        child2 = ttk.Label(self.root)
+        child3 = ttk.Label(self.root)
+
+        self.assertRaises(tkinter.TclError, self.paned.insert, 0, child)
+
+        self.paned.insert('end', child2)
+        self.paned.insert(0, child)
+        self.assertEqual(self.paned.panes(), (str(child), str(child2)))
+
+        self.paned.insert(0, child2)
+        self.assertEqual(self.paned.panes(), (str(child2), str(child)))
+
+        self.paned.insert('end', child3)
+        self.assertEqual(self.paned.panes(),
+            (str(child2), str(child), str(child3)))
+
+        # reinserting a child should move it to its current position
+        panes = self.paned.panes()
+        self.paned.insert('end', child3)
+        self.assertEqual(panes, self.paned.panes())
+
+        # moving child3 to child2 position should result in child2 ending up
+        # in previous child position and child ending up in previous child3
+        # position
+        self.paned.insert(child2, child3)
+        self.assertEqual(self.paned.panes(),
+            (str(child3), str(child2), str(child)))
+
+
+    def test_pane(self):
+        self.assertRaises(tkinter.TclError, self.paned.pane, 0)
+
+        child = ttk.Label(self.root)
+        self.paned.add(child)
+        self.assertIsInstance(self.paned.pane(0), dict)
+        self.assertEqual(self.paned.pane(0, weight=None),
+                         0 if self.wantobjects else '0')
+        # newer form for querying a single option
+        self.assertEqual(self.paned.pane(0, 'weight'),
+                         0 if self.wantobjects else '0')
+        self.assertEqual(self.paned.pane(0), self.paned.pane(str(child)))
+
+        self.assertRaises(tkinter.TclError, self.paned.pane, 0,
+            badoption='somevalue')
+
+
+    def test_sashpos(self):
+        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
+        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
+        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
+
+        child = ttk.Label(self.paned, text='a')
+        self.paned.add(child, weight=1)
+        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
+        child2 = ttk.Label(self.paned, text='b')
+        self.paned.add(child2)
+        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
+
+        self.paned.pack(expand=True, fill='both')
+        self.paned.wait_visibility()
+
+        curr_pos = self.paned.sashpos(0)
+        self.paned.sashpos(0, 1000)
+        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
+        self.assertIsInstance(self.paned.sashpos(0), int)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'command', 'compound', 'cursor',
+        'image',
+        'padding', 'state', 'style',
+        'takefocus', 'text', 'textvariable',
+        'underline', 'value', 'variable', 'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.Radiobutton(self.root, **kwargs)
+
+    def test_value(self):
+        widget = self.create()
+        self.checkParams(widget, 'value', 1, 2.3, '', 'any string')
+
+    def test_invoke(self):
+        success = []
+        def cb_test():
+            success.append(1)
+            return "cb test called"
+
+        myvar = tkinter.IntVar(self.root)
+        cbtn = ttk.Radiobutton(self.root, command=cb_test,
+                               variable=myvar, value=0)
+        cbtn2 = ttk.Radiobutton(self.root, command=cb_test,
+                                variable=myvar, value=1)
+
+        if self.wantobjects:
+            conv = lambda x: x
+        else:
+            conv = int
+
+        res = cbtn.invoke()
+        self.assertEqual(res, "cb test called")
+        self.assertEqual(conv(cbtn['value']), myvar.get())
+        self.assertEqual(myvar.get(),
+            conv(cbtn.tk.globalgetvar(cbtn['variable'])))
+        self.assertTrue(success)
+
+        cbtn2['command'] = ''
+        res = cbtn2.invoke()
+        self.assertEqual(str(res), '')
+        self.assertLessEqual(len(success), 1)
+        self.assertEqual(conv(cbtn2['value']), myvar.get())
+        self.assertEqual(myvar.get(),
+            conv(cbtn.tk.globalgetvar(cbtn['variable'])))
+
+        self.assertEqual(str(cbtn['variable']), str(cbtn2['variable']))
+
+
+class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'compound', 'cursor', 'direction',
+        'image', 'menu', 'padding', 'state', 'style',
+        'takefocus', 'text', 'textvariable',
+        'underline', 'width',
+    )
+
+    def create(self, **kwargs):
+        return ttk.Menubutton(self.root, **kwargs)
+
+    def test_direction(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'direction',
+                'above', 'below', 'left', 'right', 'flush')
+
+    def test_menu(self):
+        widget = self.create()
+        menu = tkinter.Menu(widget, name='menu')
+        self.checkParam(widget, 'menu', menu, conv=str)
+        menu.destroy()
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class ScaleTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'command', 'cursor', 'from', 'length',
+        'orient', 'style', 'takefocus', 'to', 'value', 'variable',
+    )
+    _conv_pixels = noconv
+    default_orient = 'horizontal'
+
+    def setUp(self):
+        super().setUp()
+        self.scale = self.create()
+        self.scale.pack()
+        self.scale.update()
+
+    def create(self, **kwargs):
+        return ttk.Scale(self.root, **kwargs)
+
+    def test_from(self):
+        widget = self.create()
+        self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False)
+
+    def test_length(self):
+        widget = self.create()
+        self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
+
+    def test_to(self):
+        widget = self.create()
+        self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)
+
+    def test_value(self):
+        widget = self.create()
+        self.checkFloatParam(widget, 'value', 300, 14.9, 15.1, -10, conv=False)
+
+    def test_custom_event(self):
+        failure = [1, 1, 1] # will need to be empty
+
+        funcid = self.scale.bind('<<RangeChanged>>', lambda evt: failure.pop())
+
+        self.scale['from'] = 10
+        self.scale['from_'] = 10
+        self.scale['to'] = 3
+
+        self.assertFalse(failure)
+
+        failure = [1, 1, 1]
+        self.scale.configure(from_=2, to=5)
+        self.scale.configure(from_=0, to=-2)
+        self.scale.configure(to=10)
+
+        self.assertFalse(failure)
+
+
+    def test_get(self):
+        if self.wantobjects:
+            conv = lambda x: x
+        else:
+            conv = float
+
+        scale_width = self.scale.winfo_width()
+        self.assertEqual(self.scale.get(scale_width, 0), self.scale['to'])
+
+        self.assertEqual(conv(self.scale.get(0, 0)), conv(self.scale['from']))
+        self.assertEqual(self.scale.get(), self.scale['value'])
+        self.scale['value'] = 30
+        self.assertEqual(self.scale.get(), self.scale['value'])
+
+        self.assertRaises(tkinter.TclError, self.scale.get, '', 0)
+        self.assertRaises(tkinter.TclError, self.scale.get, 0, '')
+
+
+    def test_set(self):
+        if self.wantobjects:
+            conv = lambda x: x
+        else:
+            conv = float
+
+        # set restricts the max/min values according to the current range
+        max = conv(self.scale['to'])
+        new_max = max + 10
+        self.scale.set(new_max)
+        self.assertEqual(conv(self.scale.get()), max)
+        min = conv(self.scale['from'])
+        self.scale.set(min - 1)
+        self.assertEqual(conv(self.scale.get()), min)
+
+        # changing directly the variable doesn't impose this limitation tho
+        var = tkinter.DoubleVar(self.root)
+        self.scale['variable'] = var
+        var.set(max + 5)
+        self.assertEqual(conv(self.scale.get()), var.get())
+        self.assertEqual(conv(self.scale.get()), max + 5)
+        del var
+
+        # the same happens with the value option
+        self.scale['value'] = max + 10
+        self.assertEqual(conv(self.scale.get()), max + 10)
+        self.assertEqual(conv(self.scale.get()), conv(self.scale['value']))
+
+        # nevertheless, note that the max/min values we can get specifying
+        # x, y coords are the ones according to the current range
+        self.assertEqual(conv(self.scale.get(0, 0)), min)
+        self.assertEqual(conv(self.scale.get(self.scale.winfo_width(), 0)), max)
+
+        self.assertRaises(tkinter.TclError, self.scale.set, None)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class ProgressbarTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'cursor', 'orient', 'length',
+        'mode', 'maximum', 'phase',
+        'style', 'takefocus', 'value', 'variable',
+    )
+    _conv_pixels = noconv
+    default_orient = 'horizontal'
+
+    def create(self, **kwargs):
+        return ttk.Progressbar(self.root, **kwargs)
+
+    def test_length(self):
+        widget = self.create()
+        self.checkPixelsParam(widget, 'length', 100.1, 56.7, '2i')
+
+    def test_maximum(self):
+        widget = self.create()
+        self.checkFloatParam(widget, 'maximum', 150.2, 77.7, 0, -10, conv=False)
+
+    def test_mode(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'mode', 'determinate', 'indeterminate')
+
+    def test_phase(self):
+        # XXX
+        pass
+
+    def test_value(self):
+        widget = self.create()
+        self.checkFloatParam(widget, 'value', 150.2, 77.7, 0, -10,
+                             conv=False)
+
+
+@unittest.skipIf(sys.platform == 'darwin',
+                 'ttk.Scrollbar is special on MacOSX')
+@add_standard_options(StandardTtkOptionsTests)
+class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'command', 'cursor', 'orient', 'style', 'takefocus',
+    )
+    default_orient = 'vertical'
+
+    def create(self, **kwargs):
+        return ttk.Scrollbar(self.root, **kwargs)
+
+
+@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
+class NotebookTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'cursor', 'height', 'padding', 'style', 'takefocus', 'width',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.nb = self.create(padding=0)
+        self.child1 = ttk.Label(self.root)
+        self.child2 = ttk.Label(self.root)
+        self.nb.add(self.child1, text='a')
+        self.nb.add(self.child2, text='b')
+
+    def create(self, **kwargs):
+        return ttk.Notebook(self.root, **kwargs)
+
+    def test_tab_identifiers(self):
+        self.nb.forget(0)
+        self.nb.hide(self.child2)
+        self.assertRaises(tkinter.TclError, self.nb.tab, self.child1)
+        self.assertEqual(self.nb.index('end'), 1)
+        self.nb.add(self.child2)
+        self.assertEqual(self.nb.index('end'), 1)
+        self.nb.select(self.child2)
+
+        self.assertTrue(self.nb.tab('current'))
+        self.nb.add(self.child1, text='a')
+
+        self.nb.pack()
+        self.nb.wait_visibility()
+        if sys.platform == 'darwin':
+            tb_idx = "@20,5"
+        else:
+            tb_idx = "@5,5"
+        self.assertEqual(self.nb.tab(tb_idx), self.nb.tab('current'))
+
+        for i in range(5, 100, 5):
+            try:
+                if self.nb.tab('@%d, 5' % i, text=None) == 'a':
+                    break
+            except tkinter.TclError:
+                pass
+
+        else:
+            self.fail("Tab with text 'a' not found")
+
+
+    def test_add_and_hidden(self):
+        self.assertRaises(tkinter.TclError, self.nb.hide, -1)
+        self.assertRaises(tkinter.TclError, self.nb.hide, 'hi')
+        self.assertRaises(tkinter.TclError, self.nb.hide, None)
+        self.assertRaises(tkinter.TclError, self.nb.add, None)
+        self.assertRaises(tkinter.TclError, self.nb.add, ttk.Label(self.root),
+            unknown='option')
+
+        tabs = self.nb.tabs()
+        self.nb.hide(self.child1)
+        self.nb.add(self.child1)
+        self.assertEqual(self.nb.tabs(), tabs)
+
+        child = ttk.Label(self.root)
+        self.nb.add(child, text='c')
+        tabs = self.nb.tabs()
+
+        curr = self.nb.index('current')
+        # verify that the tab gets readded at its previous position
+        child2_index = self.nb.index(self.child2)
+        self.nb.hide(self.child2)
+        self.nb.add(self.child2)
+        self.assertEqual(self.nb.tabs(), tabs)
+        self.assertEqual(self.nb.index(self.child2), child2_index)
+        self.assertEqual(str(self.child2), self.nb.tabs()[child2_index])
+        # but the tab next to it (not hidden) is the one selected now
+        self.assertEqual(self.nb.index('current'), curr + 1)
+
+
+    def test_forget(self):
+        self.assertRaises(tkinter.TclError, self.nb.forget, -1)
+        self.assertRaises(tkinter.TclError, self.nb.forget, 'hi')
+        self.assertRaises(tkinter.TclError, self.nb.forget, None)
+
+        tabs = self.nb.tabs()
+        child1_index = self.nb.index(self.child1)
+        self.nb.forget(self.child1)
+        self.assertNotIn(str(self.child1), self.nb.tabs())
+        self.assertEqual(len(tabs) - 1, len(self.nb.tabs()))
+
+        self.nb.add(self.child1)
+        self.assertEqual(self.nb.index(self.child1), 1)
+        self.assertNotEqual(child1_index, self.nb.index(self.child1))
+
+
+    def test_index(self):
+        self.assertRaises(tkinter.TclError, self.nb.index, -1)
+        self.assertRaises(tkinter.TclError, self.nb.index, None)
+
+        self.assertIsInstance(self.nb.index('end'), int)
+        self.assertEqual(self.nb.index(self.child1), 0)
+        self.assertEqual(self.nb.index(self.child2), 1)
+        self.assertEqual(self.nb.index('end'), 2)
+
+
+    def test_insert(self):
+        # moving tabs
+        tabs = self.nb.tabs()
+        self.nb.insert(1, tabs[0])
+        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
+        self.nb.insert(self.child1, self.child2)
+        self.assertEqual(self.nb.tabs(), tabs)
+        self.nb.insert('end', self.child1)
+        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
+        self.nb.insert('end', 0)
+        self.assertEqual(self.nb.tabs(), tabs)
+        # bad moves
+        self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0])
+        self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0])
+
+        # new tab
+        child3 = ttk.Label(self.root)
+        self.nb.insert(1, child3)
+        self.assertEqual(self.nb.tabs(), (tabs[0], str(child3), tabs[1]))
+        self.nb.forget(child3)
+        self.assertEqual(self.nb.tabs(), tabs)
+        self.nb.insert(self.child1, child3)
+        self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs)
+        self.nb.forget(child3)
+        self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3)
+        self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3)
+
+        # bad inserts
+        self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None)
+        self.assertRaises(tkinter.TclError, self.nb.insert, None, 0)
+        self.assertRaises(tkinter.TclError, self.nb.insert, None, None)
+
+
+    def test_select(self):
+        self.nb.pack()
+        self.nb.wait_visibility()
+
+        success = []
+        tab_changed = []
+
+        self.child1.bind('<Unmap>', lambda evt: success.append(True))
+        self.nb.bind('<<NotebookTabChanged>>',
+            lambda evt: tab_changed.append(True))
+
+        self.assertEqual(self.nb.select(), str(self.child1))
+        self.nb.select(self.child2)
+        self.assertTrue(success)
+        self.assertEqual(self.nb.select(), str(self.child2))
+
+        self.nb.update()
+        self.assertTrue(tab_changed)
+
+
+    def test_tab(self):
+        self.assertRaises(tkinter.TclError, self.nb.tab, -1)
+        self.assertRaises(tkinter.TclError, self.nb.tab, 'notab')
+        self.assertRaises(tkinter.TclError, self.nb.tab, None)
+
+        self.assertIsInstance(self.nb.tab(self.child1), dict)
+        self.assertEqual(self.nb.tab(self.child1, text=None), 'a')
+        # newer form for querying a single option
+        self.assertEqual(self.nb.tab(self.child1, 'text'), 'a')
+        self.nb.tab(self.child1, text='abc')
+        self.assertEqual(self.nb.tab(self.child1, text=None), 'abc')
+        self.assertEqual(self.nb.tab(self.child1, 'text'), 'abc')
+
+
+    def test_tabs(self):
+        self.assertEqual(len(self.nb.tabs()), 2)
+
+        self.nb.forget(self.child1)
+        self.nb.forget(self.child2)
+
+        self.assertEqual(self.nb.tabs(), ())
+
+
+    def test_traversal(self):
+        self.nb.pack()
+        self.nb.wait_visibility()
+
+        self.nb.select(0)
+
+        simulate_mouse_click(self.nb, 5, 5)
+        self.nb.focus_force()
+        self.nb.event_generate('<Control-Tab>')
+        self.assertEqual(self.nb.select(), str(self.child2))
+        self.nb.focus_force()
+        self.nb.event_generate('<Shift-Control-Tab>')
+        self.assertEqual(self.nb.select(), str(self.child1))
+        self.nb.focus_force()
+        self.nb.event_generate('<Shift-Control-Tab>')
+        self.assertEqual(self.nb.select(), str(self.child2))
+
+        self.nb.tab(self.child1, text='a', underline=0)
+        self.nb.enable_traversal()
+        self.nb.focus_force()
+        simulate_mouse_click(self.nb, 5, 5)
+        if sys.platform == 'darwin':
+            self.nb.event_generate('<Option-a>')
+        else:
+            self.nb.event_generate('<Alt-a>')
+        self.assertEqual(self.nb.select(), str(self.child1))
+
+@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
+class SpinboxTest(EntryTest, unittest.TestCase):
+    OPTIONS = (
+        'background', 'class', 'command', 'cursor', 'exportselection',
+        'font', 'foreground', 'format', 'from',  'increment',
+        'invalidcommand', 'justify', 'show', 'state', 'style',
+        'takefocus', 'textvariable', 'to', 'validate', 'validatecommand',
+        'values', 'width', 'wrap', 'xscrollcommand',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.spin = self.create()
+        self.spin.pack()
+
+    def create(self, **kwargs):
+        return ttk.Spinbox(self.root, **kwargs)
+
+    def _click_increment_arrow(self):
+        width = self.spin.winfo_width()
+        height = self.spin.winfo_height()
+        x = width - 5
+        y = height//2 - 5
+        self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
+        self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
+        self.spin.update_idletasks()
+
+    def _click_decrement_arrow(self):
+        width = self.spin.winfo_width()
+        height = self.spin.winfo_height()
+        x = width - 5
+        y = height//2 + 4
+        self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
+        self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
+        self.spin.update_idletasks()
+
+    def test_command(self):
+        success = []
+
+        self.spin['command'] = lambda: success.append(True)
+        self.spin.update()
+        self._click_increment_arrow()
+        self.spin.update()
+        self.assertTrue(success)
+
+        self._click_decrement_arrow()
+        self.assertEqual(len(success), 2)
+
+        # testing postcommand removal
+        self.spin['command'] = ''
+        self.spin.update_idletasks()
+        self._click_increment_arrow()
+        self._click_decrement_arrow()
+        self.spin.update()
+        self.assertEqual(len(success), 2)
+
+    def test_to(self):
+        self.spin['from'] = 0
+        self.spin['to'] = 5
+        self.spin.set(4)
+        self.spin.update()
+        self._click_increment_arrow()  # 5
+
+        self.assertEqual(self.spin.get(), '5')
+
+        self._click_increment_arrow()  # 5
+        self.assertEqual(self.spin.get(), '5')
+
+    def test_from(self):
+        self.spin['from'] = 1
+        self.spin['to'] = 10
+        self.spin.set(2)
+        self.spin.update()
+        self._click_decrement_arrow()  # 1
+        self.assertEqual(self.spin.get(), '1')
+        self._click_decrement_arrow()  # 1
+        self.assertEqual(self.spin.get(), '1')
+
+    def test_increment(self):
+        self.spin['from'] = 0
+        self.spin['to'] = 10
+        self.spin['increment'] = 4
+        self.spin.set(1)
+        self.spin.update()
+
+        self._click_increment_arrow()  # 5
+        self.assertEqual(self.spin.get(), '5')
+        self.spin['increment'] = 2
+        self.spin.update()
+        self._click_decrement_arrow()  # 3
+        self.assertEqual(self.spin.get(), '3')
+
+    def test_format(self):
+        self.spin.set(1)
+        self.spin['format'] = '%10.3f'
+        self.spin.update()
+        self._click_increment_arrow()
+        value = self.spin.get()
+
+        self.assertEqual(len(value), 10)
+        self.assertEqual(value.index('.'), 6)
+
+        self.spin['format'] = ''
+        self.spin.update()
+        self._click_increment_arrow()
+        value = self.spin.get()
+        self.assertTrue('.' not in value)
+        self.assertEqual(len(value), 1)
+
+    def test_wrap(self):
+        self.spin['to'] = 10
+        self.spin['from'] = 1
+        self.spin.set(1)
+        self.spin['wrap'] = True
+        self.spin.update()
+
+        self._click_decrement_arrow()
+        self.assertEqual(self.spin.get(), '10')
+
+        self._click_increment_arrow()
+        self.assertEqual(self.spin.get(), '1')
+
+        self.spin['wrap'] = False
+        self.spin.update()
+
+        self._click_decrement_arrow()
+        self.assertEqual(self.spin.get(), '1')
+
+    def test_values(self):
+        self.assertEqual(self.spin['values'],
+                         () if tcl_version < (8, 5) else '')
+        self.checkParam(self.spin, 'values', 'mon tue wed thur',
+                        expected=('mon', 'tue', 'wed', 'thur'))
+        self.checkParam(self.spin, 'values', ('mon', 'tue', 'wed', 'thur'))
+        self.checkParam(self.spin, 'values', (42, 3.14, '', 'any string'))
+        self.checkParam(
+            self.spin,
+            'values',
+            '',
+            expected='' if get_tk_patchlevel() < (8, 5, 10) else ()
+        )
+
+        self.spin['values'] = ['a', 1, 'c']
+
+        # test incrementing / decrementing values
+        self.spin.set('a')
+        self.spin.update()
+        self._click_increment_arrow()
+        self.assertEqual(self.spin.get(), '1')
+
+        self._click_decrement_arrow()
+        self.assertEqual(self.spin.get(), 'a')
+
+        # testing values with empty string set through configure
+        self.spin.configure(values=[1, '', 2])
+        self.assertEqual(self.spin['values'],
+                         ('1', '', '2') if self.wantobjects else
+                         '1 {} 2')
+
+        # testing values with spaces
+        self.spin['values'] = ['a b', 'a\tb', 'a\nb']
+        self.assertEqual(self.spin['values'],
+                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
+                         '{a b} {a\tb} {a\nb}')
+
+        # testing values with special characters
+        self.spin['values'] = [r'a\tb', '"a"', '} {']
+        self.assertEqual(self.spin['values'],
+                         (r'a\tb', '"a"', '} {') if self.wantobjects else
+                         r'a\\tb {"a"} \}\ \{')
+
+        # testing creating spinbox with empty string in values
+        spin2 = ttk.Spinbox(self.root, values=[1, 2, ''])
+        self.assertEqual(spin2['values'],
+                         ('1', '2', '') if self.wantobjects else '1 2 {}')
+        spin2.destroy()
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'columns', 'cursor', 'displaycolumns',
+        'height', 'padding', 'selectmode', 'show',
+        'style', 'takefocus', 'xscrollcommand', 'yscrollcommand',
+    )
+
+    def setUp(self):
+        super().setUp()
+        self.tv = self.create(padding=0)
+
+    def create(self, **kwargs):
+        return ttk.Treeview(self.root, **kwargs)
+
+    def test_columns(self):
+        widget = self.create()
+        self.checkParam(widget, 'columns', 'a b c',
+                        expected=('a', 'b', 'c'))
+        self.checkParam(widget, 'columns', ('a', 'b', 'c'))
+        self.checkParam(widget, 'columns', (),
+                        expected='' if get_tk_patchlevel() < (8, 5, 10) else ())
+
+    def test_displaycolumns(self):
+        widget = self.create()
+        widget['columns'] = ('a', 'b', 'c')
+        self.checkParam(widget, 'displaycolumns', 'b a c',
+                        expected=('b', 'a', 'c'))
+        self.checkParam(widget, 'displaycolumns', ('b', 'a', 'c'))
+        self.checkParam(widget, 'displaycolumns', '#all',
+                        expected=('#all',))
+        self.checkParam(widget, 'displaycolumns', (2, 1, 0))
+        self.checkInvalidParam(widget, 'displaycolumns', ('a', 'b', 'd'),
+                               errmsg='Invalid column index d')
+        self.checkInvalidParam(widget, 'displaycolumns', (1, 2, 3),
+                               errmsg='Column index 3 out of bounds')
+        self.checkInvalidParam(widget, 'displaycolumns', (1, -2),
+                               errmsg='Column index -2 out of bounds')
+
+    def test_height(self):
+        widget = self.create()
+        self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c', conv=False)
+        self.checkPixelsParam(widget, 'height', 101.2, 102.6, conv=noconv)
+
+    def test_selectmode(self):
+        widget = self.create()
+        self.checkEnumParam(widget, 'selectmode',
+                            'none', 'browse', 'extended')
+
+    def test_show(self):
+        widget = self.create()
+        self.checkParam(widget, 'show', 'tree headings',
+                        expected=('tree', 'headings'))
+        self.checkParam(widget, 'show', ('tree', 'headings'))
+        self.checkParam(widget, 'show', ('headings', 'tree'))
+        self.checkParam(widget, 'show', 'tree', expected=('tree',))
+        self.checkParam(widget, 'show', 'headings', expected=('headings',))
+
+    def test_bbox(self):
+        self.tv.pack()
+        self.assertEqual(self.tv.bbox(''), '')
+        self.tv.wait_visibility()
+        self.tv.update()
+
+        item_id = self.tv.insert('', 'end')
+        children = self.tv.get_children()
+        self.assertTrue(children)
+
+        bbox = self.tv.bbox(children[0])
+        self.assertIsBoundingBox(bbox)
+
+        # compare width in bboxes
+        self.tv['columns'] = ['test']
+        self.tv.column('test', width=50)
+        bbox_column0 = self.tv.bbox(children[0], 0)
+        root_width = self.tv.column('#0', width=None)
+        if not self.wantobjects:
+            root_width = int(root_width)
+        self.assertEqual(bbox_column0[0], bbox[0] + root_width)
+
+        # verify that bbox of a closed item is the empty string
+        child1 = self.tv.insert(item_id, 'end')
+        self.assertEqual(self.tv.bbox(child1), '')
+
+
+    def test_children(self):
+        # no children yet, should get an empty tuple
+        self.assertEqual(self.tv.get_children(), ())
+
+        item_id = self.tv.insert('', 'end')
+        self.assertIsInstance(self.tv.get_children(), tuple)
+        self.assertEqual(self.tv.get_children()[0], item_id)
+
+        # add item_id and child3 as children of child2
+        child2 = self.tv.insert('', 'end')
+        child3 = self.tv.insert('', 'end')
+        self.tv.set_children(child2, item_id, child3)
+        self.assertEqual(self.tv.get_children(child2), (item_id, child3))
+
+        # child3 has child2 as parent, thus trying to set child2 as a children
+        # of child3 should result in an error
+        self.assertRaises(tkinter.TclError,
+            self.tv.set_children, child3, child2)
+
+        # remove child2 children
+        self.tv.set_children(child2)
+        self.assertEqual(self.tv.get_children(child2), ())
+
+        # remove root's children
+        self.tv.set_children('')
+        self.assertEqual(self.tv.get_children(), ())
+
+
+    def test_column(self):
+        # return a dict with all options/values
+        self.assertIsInstance(self.tv.column('#0'), dict)
+        # return a single value of the given option
+        if self.wantobjects:
+            self.assertIsInstance(self.tv.column('#0', width=None), int)
+        # set a new value for an option
+        self.tv.column('#0', width=10)
+        # testing new way to get option value
+        self.assertEqual(self.tv.column('#0', 'width'),
+                         10 if self.wantobjects else '10')
+        self.assertEqual(self.tv.column('#0', width=None),
+                         10 if self.wantobjects else '10')
+        # check read-only option
+        self.assertRaises(tkinter.TclError, self.tv.column, '#0', id='X')
+
+        self.assertRaises(tkinter.TclError, self.tv.column, 'invalid')
+        invalid_kws = [
+            {'unknown_option': 'some value'},  {'stretch': 'wrong'},
+            {'anchor': 'wrong'}, {'width': 'wrong'}, {'minwidth': 'wrong'}
+        ]
+        for kw in invalid_kws:
+            self.assertRaises(tkinter.TclError, self.tv.column, '#0',
+                **kw)
+
+
+    def test_delete(self):
+        self.assertRaises(tkinter.TclError, self.tv.delete, '#0')
+
+        item_id = self.tv.insert('', 'end')
+        item2 = self.tv.insert(item_id, 'end')
+        self.assertEqual(self.tv.get_children(), (item_id, ))
+        self.assertEqual(self.tv.get_children(item_id), (item2, ))
+
+        self.tv.delete(item_id)
+        self.assertFalse(self.tv.get_children())
+
+        # reattach should fail
+        self.assertRaises(tkinter.TclError,
+            self.tv.reattach, item_id, '', 'end')
+
+        # test multiple item delete
+        item1 = self.tv.insert('', 'end')
+        item2 = self.tv.insert('', 'end')
+        self.assertEqual(self.tv.get_children(), (item1, item2))
+
+        self.tv.delete(item1, item2)
+        self.assertFalse(self.tv.get_children())
+
+
+    def test_detach_reattach(self):
+        item_id = self.tv.insert('', 'end')
+        item2 = self.tv.insert(item_id, 'end')
+
+        # calling detach without items is valid, although it does nothing
+        prev = self.tv.get_children()
+        self.tv.detach() # this should do nothing
+        self.assertEqual(prev, self.tv.get_children())
+
+        self.assertEqual(self.tv.get_children(), (item_id, ))
+        self.assertEqual(self.tv.get_children(item_id), (item2, ))
+
+        # detach item with children
+        self.tv.detach(item_id)
+        self.assertFalse(self.tv.get_children())
+
+        # reattach item with children
+        self.tv.reattach(item_id, '', 'end')
+        self.assertEqual(self.tv.get_children(), (item_id, ))
+        self.assertEqual(self.tv.get_children(item_id), (item2, ))
+
+        # move a children to the root
+        self.tv.move(item2, '', 'end')
+        self.assertEqual(self.tv.get_children(), (item_id, item2))
+        self.assertEqual(self.tv.get_children(item_id), ())
+
+        # bad values
+        self.assertRaises(tkinter.TclError,
+            self.tv.reattach, 'nonexistent', '', 'end')
+        self.assertRaises(tkinter.TclError,
+            self.tv.detach, 'nonexistent')
+        self.assertRaises(tkinter.TclError,
+            self.tv.reattach, item2, 'otherparent', 'end')
+        self.assertRaises(tkinter.TclError,
+            self.tv.reattach, item2, '', 'invalid')
+
+        # multiple detach
+        self.tv.detach(item_id, item2)
+        self.assertEqual(self.tv.get_children(), ())
+        self.assertEqual(self.tv.get_children(item_id), ())
+
+
+    def test_exists(self):
+        self.assertEqual(self.tv.exists('something'), False)
+        self.assertEqual(self.tv.exists(''), True)
+        self.assertEqual(self.tv.exists({}), False)
+
+        # the following will make a tk.call equivalent to
+        # tk.call(treeview, "exists") which should result in an error
+        # in the tcl interpreter since tk requires an item.
+        self.assertRaises(tkinter.TclError, self.tv.exists, None)
+
+
+    def test_focus(self):
+        # nothing is focused right now
+        self.assertEqual(self.tv.focus(), '')
+
+        item1 = self.tv.insert('', 'end')
+        self.tv.focus(item1)
+        self.assertEqual(self.tv.focus(), item1)
+
+        self.tv.delete(item1)
+        self.assertEqual(self.tv.focus(), '')
+
+        # try focusing inexistent item
+        self.assertRaises(tkinter.TclError, self.tv.focus, 'hi')
+
+
+    def test_heading(self):
+        # check a dict is returned
+        self.assertIsInstance(self.tv.heading('#0'), dict)
+
+        # check a value is returned
+        self.tv.heading('#0', text='hi')
+        self.assertEqual(self.tv.heading('#0', 'text'), 'hi')
+        self.assertEqual(self.tv.heading('#0', text=None), 'hi')
+
+        # invalid option
+        self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
+            background=None)
+        # invalid value
+        self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
+            anchor=1)
+
+    def test_heading_callback(self):
+        def simulate_heading_click(x, y):
+            simulate_mouse_click(self.tv, x, y)
+            self.tv.update()
+
+        success = [] # no success for now
+
+        self.tv.pack()
+        self.tv.wait_visibility()
+        self.tv.heading('#0', command=lambda: success.append(True))
+        self.tv.column('#0', width=100)
+        self.tv.update()
+
+        # assuming that the coords (5, 5) fall into heading #0
+        simulate_heading_click(5, 5)
+        if not success:
+            self.fail("The command associated to the treeview heading wasn't "
+                "invoked.")
+
+        success = []
+        commands = self.tv.master._tclCommands
+        self.tv.heading('#0', command=str(self.tv.heading('#0', command=None)))
+        self.assertEqual(commands, self.tv.master._tclCommands)
+        simulate_heading_click(5, 5)
+        if not success:
+            self.fail("The command associated to the treeview heading wasn't "
+                "invoked.")
+
+        # XXX The following raises an error in a tcl interpreter, but not in
+        # Python
+        #self.tv.heading('#0', command='I dont exist')
+        #simulate_heading_click(5, 5)
+
+
+    def test_index(self):
+        # item 'what' doesn't exist
+        self.assertRaises(tkinter.TclError, self.tv.index, 'what')
+
+        self.assertEqual(self.tv.index(''), 0)
+
+        item1 = self.tv.insert('', 'end')
+        item2 = self.tv.insert('', 'end')
+        c1 = self.tv.insert(item1, 'end')
+        c2 = self.tv.insert(item1, 'end')
+        self.assertEqual(self.tv.index(item1), 0)
+        self.assertEqual(self.tv.index(c1), 0)
+        self.assertEqual(self.tv.index(c2), 1)
+        self.assertEqual(self.tv.index(item2), 1)
+
+        self.tv.move(item2, '', 0)
+        self.assertEqual(self.tv.index(item2), 0)
+        self.assertEqual(self.tv.index(item1), 1)
+
+        # check that index still works even after its parent and siblings
+        # have been detached
+        self.tv.detach(item1)
+        self.assertEqual(self.tv.index(c2), 1)
+        self.tv.detach(c1)
+        self.assertEqual(self.tv.index(c2), 0)
+
+        # but it fails after item has been deleted
+        self.tv.delete(item1)
+        self.assertRaises(tkinter.TclError, self.tv.index, c2)
+
+
+    def test_insert_item(self):
+        # parent 'none' doesn't exist
+        self.assertRaises(tkinter.TclError, self.tv.insert, 'none', 'end')
+
+        # open values
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
+            open='')
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
+            open='please')
+        self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=True)))
+        self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=False)))
+
+        # invalid index
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'middle')
+
+        # trying to duplicate item id is invalid
+        itemid = self.tv.insert('', 'end', 'first-item')
+        self.assertEqual(itemid, 'first-item')
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
+            'first-item')
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
+            MockTclObj('first-item'))
+
+        # unicode values
+        value = '\xe1ba'
+        item = self.tv.insert('', 'end', values=(value, ))
+        self.assertEqual(self.tv.item(item, 'values'),
+                         (value,) if self.wantobjects else value)
+        self.assertEqual(self.tv.item(item, values=None),
+                         (value,) if self.wantobjects else value)
+
+        self.tv.item(item, values=self.root.splitlist(self.tv.item(item, values=None)))
+        self.assertEqual(self.tv.item(item, values=None),
+                         (value,) if self.wantobjects else value)
+
+        self.assertIsInstance(self.tv.item(item), dict)
+
+        # erase item values
+        self.tv.item(item, values='')
+        self.assertFalse(self.tv.item(item, values=None))
+
+        # item tags
+        item = self.tv.insert('', 'end', tags=[1, 2, value])
+        self.assertEqual(self.tv.item(item, tags=None),
+                         ('1', '2', value) if self.wantobjects else
+                         '1 2 %s' % value)
+        self.tv.item(item, tags=[])
+        self.assertFalse(self.tv.item(item, tags=None))
+        self.tv.item(item, tags=(1, 2))
+        self.assertEqual(self.tv.item(item, tags=None),
+                         ('1', '2') if self.wantobjects else '1 2')
+
+        # values with spaces
+        item = self.tv.insert('', 'end', values=('a b c',
+            '%s %s' % (value, value)))
+        self.assertEqual(self.tv.item(item, values=None),
+            ('a b c', '%s %s' % (value, value)) if self.wantobjects else
+            '{a b c} {%s %s}' % (value, value))
+
+        # text
+        self.assertEqual(self.tv.item(
+            self.tv.insert('', 'end', text="Label here"), text=None),
+            "Label here")
+        self.assertEqual(self.tv.item(
+            self.tv.insert('', 'end', text=value), text=None),
+            value)
+
+        # test for values which are not None
+        itemid = self.tv.insert('', 'end', 0)
+        self.assertEqual(itemid, '0')
+        itemid = self.tv.insert('', 'end', 0.0)
+        self.assertEqual(itemid, '0.0')
+        # this is because False resolves to 0 and element with 0 iid is already present
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', False)
+        self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', '')
+
+
+    def test_selection(self):
+        self.assertRaises(TypeError, self.tv.selection, 'spam')
+        # item 'none' doesn't exist
+        self.assertRaises(tkinter.TclError, self.tv.selection_set, 'none')
+        self.assertRaises(tkinter.TclError, self.tv.selection_add, 'none')
+        self.assertRaises(tkinter.TclError, self.tv.selection_remove, 'none')
+        self.assertRaises(tkinter.TclError, self.tv.selection_toggle, 'none')
+
+        item1 = self.tv.insert('', 'end')
+        item2 = self.tv.insert('', 'end')
+        c1 = self.tv.insert(item1, 'end')
+        c2 = self.tv.insert(item1, 'end')
+        c3 = self.tv.insert(item1, 'end')
+        self.assertEqual(self.tv.selection(), ())
+
+        self.tv.selection_set(c1, item2)
+        self.assertEqual(self.tv.selection(), (c1, item2))
+        self.tv.selection_set(c2)
+        self.assertEqual(self.tv.selection(), (c2,))
+
+        self.tv.selection_add(c1, item2)
+        self.assertEqual(self.tv.selection(), (c1, c2, item2))
+        self.tv.selection_add(item1)
+        self.assertEqual(self.tv.selection(), (item1, c1, c2, item2))
+        self.tv.selection_add()
+        self.assertEqual(self.tv.selection(), (item1, c1, c2, item2))
+
+        self.tv.selection_remove(item1, c3)
+        self.assertEqual(self.tv.selection(), (c1, c2, item2))
+        self.tv.selection_remove(c2)
+        self.assertEqual(self.tv.selection(), (c1, item2))
+        self.tv.selection_remove()
+        self.assertEqual(self.tv.selection(), (c1, item2))
+
+        self.tv.selection_toggle(c1, c3)
+        self.assertEqual(self.tv.selection(), (c3, item2))
+        self.tv.selection_toggle(item2)
+        self.assertEqual(self.tv.selection(), (c3,))
+        self.tv.selection_toggle()
+        self.assertEqual(self.tv.selection(), (c3,))
+
+        self.tv.insert('', 'end', id='with spaces')
+        self.tv.selection_set('with spaces')
+        self.assertEqual(self.tv.selection(), ('with spaces',))
+
+        self.tv.insert('', 'end', id='{brace')
+        self.tv.selection_set('{brace')
+        self.assertEqual(self.tv.selection(), ('{brace',))
+
+        self.tv.insert('', 'end', id='unicode\u20ac')
+        self.tv.selection_set('unicode\u20ac')
+        self.assertEqual(self.tv.selection(), ('unicode\u20ac',))
+
+        self.tv.insert('', 'end', id=b'bytes\xe2\x82\xac')
+        self.tv.selection_set(b'bytes\xe2\x82\xac')
+        self.assertEqual(self.tv.selection(), ('bytes\xe2\x82\xac',))
+
+        self.tv.selection_set()
+        self.assertEqual(self.tv.selection(), ())
+
+        # Old interface
+        self.tv.selection_set((c1, item2))
+        self.assertEqual(self.tv.selection(), (c1, item2))
+        self.tv.selection_add((c1, item1))
+        self.assertEqual(self.tv.selection(), (item1, c1, item2))
+        self.tv.selection_remove((item1, c3))
+        self.assertEqual(self.tv.selection(), (c1, item2))
+        self.tv.selection_toggle((c1, c3))
+        self.assertEqual(self.tv.selection(), (c3, item2))
+
+
+    def test_set(self):
+        self.tv['columns'] = ['A', 'B']
+        item = self.tv.insert('', 'end', values=['a', 'b'])
+        self.assertEqual(self.tv.set(item), {'A': 'a', 'B': 'b'})
+
+        self.tv.set(item, 'B', 'a')
+        self.assertEqual(self.tv.item(item, values=None),
+                         ('a', 'a') if self.wantobjects else 'a a')
+
+        self.tv['columns'] = ['B']
+        self.assertEqual(self.tv.set(item), {'B': 'a'})
+
+        self.tv.set(item, 'B', 'b')
+        self.assertEqual(self.tv.set(item, column='B'), 'b')
+        self.assertEqual(self.tv.item(item, values=None),
+                         ('b', 'a') if self.wantobjects else 'b a')
+
+        self.tv.set(item, 'B', 123)
+        self.assertEqual(self.tv.set(item, 'B'),
+                         123 if self.wantobjects else '123')
+        self.assertEqual(self.tv.item(item, values=None),
+                         (123, 'a') if self.wantobjects else '123 a')
+        self.assertEqual(self.tv.set(item),
+                         {'B': 123} if self.wantobjects else {'B': '123'})
+
+        # inexistent column
+        self.assertRaises(tkinter.TclError, self.tv.set, item, 'A')
+        self.assertRaises(tkinter.TclError, self.tv.set, item, 'A', 'b')
+
+        # inexistent item
+        self.assertRaises(tkinter.TclError, self.tv.set, 'notme')
+
+
+    def test_tag_bind(self):
+        events = []
+        item1 = self.tv.insert('', 'end', tags=['call'])
+        item2 = self.tv.insert('', 'end', tags=['call'])
+        self.tv.tag_bind('call', '<ButtonPress-1>',
+            lambda evt: events.append(1))
+        self.tv.tag_bind('call', '<ButtonRelease-1>',
+            lambda evt: events.append(2))
+
+        self.tv.pack()
+        self.tv.wait_visibility()
+        self.tv.update()
+
+        pos_y = set()
+        found = set()
+        for i in range(0, 100, 10):
+            if len(found) == 2: # item1 and item2 already found
+                break
+            item_id = self.tv.identify_row(i)
+            if item_id and item_id not in found:
+                pos_y.add(i)
+                found.add(item_id)
+
+        self.assertEqual(len(pos_y), 2) # item1 and item2 y pos
+        for y in pos_y:
+            simulate_mouse_click(self.tv, 0, y)
+
+        # by now there should be 4 things in the events list, since each
+        # item had a bind for two events that were simulated above
+        self.assertEqual(len(events), 4)
+        for evt in zip(events[::2], events[1::2]):
+            self.assertEqual(evt, (1, 2))
+
+
+    def test_tag_configure(self):
+        # Just testing parameter passing for now
+        self.assertRaises(TypeError, self.tv.tag_configure)
+        self.assertRaises(tkinter.TclError, self.tv.tag_configure,
+            'test', sky='blue')
+        self.tv.tag_configure('test', foreground='blue')
+        self.assertEqual(str(self.tv.tag_configure('test', 'foreground')),
+            'blue')
+        self.assertEqual(str(self.tv.tag_configure('test', foreground=None)),
+            'blue')
+        self.assertIsInstance(self.tv.tag_configure('test'), dict)
+
+    def test_tag_has(self):
+        item1 = self.tv.insert('', 'end', text='Item 1', tags=['tag1'])
+        item2 = self.tv.insert('', 'end', text='Item 2', tags=['tag2'])
+        self.assertRaises(TypeError, self.tv.tag_has)
+        self.assertRaises(TclError, self.tv.tag_has, 'tag1', 'non-existing')
+        self.assertTrue(self.tv.tag_has('tag1', item1))
+        self.assertFalse(self.tv.tag_has('tag1', item2))
+        self.assertFalse(self.tv.tag_has('tag2', item1))
+        self.assertTrue(self.tv.tag_has('tag2', item2))
+        self.assertFalse(self.tv.tag_has('tag3', item1))
+        self.assertFalse(self.tv.tag_has('tag3', item2))
+        self.assertEqual(self.tv.tag_has('tag1'), (item1,))
+        self.assertEqual(self.tv.tag_has('tag2'), (item2,))
+        self.assertEqual(self.tv.tag_has('tag3'), ())
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class SeparatorTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'cursor', 'orient', 'style', 'takefocus',
+        # 'state'?
+    )
+    default_orient = 'horizontal'
+
+    def create(self, **kwargs):
+        return ttk.Separator(self.root, **kwargs)
+
+
+@add_standard_options(StandardTtkOptionsTests)
+class SizegripTest(AbstractWidgetTest, unittest.TestCase):
+    OPTIONS = (
+        'class', 'cursor', 'style', 'takefocus',
+        # 'state'?
+    )
+
+    def create(self, **kwargs):
+        return ttk.Sizegrip(self.root, **kwargs)
+
+tests_gui = (
+        ButtonTest, CheckbuttonTest, ComboboxTest, EntryTest,
+        FrameTest, LabelFrameTest, LabelTest, MenubuttonTest,
+        NotebookTest, PanedWindowTest, ProgressbarTest,
+        RadiobuttonTest, ScaleTest, ScrollbarTest, SeparatorTest,
+        SizegripTest, SpinboxTest, TreeviewTest, WidgetTest,
+        )
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
new file mode 100644 (file)
index 0000000..573544d
--- /dev/null
@@ -0,0 +1,1660 @@
+"""Ttk wrapper.
+
+This module provides classes to allow using Tk themed widget set.
+
+Ttk is based on a revised and enhanced version of
+TIP #48 (http://tip.tcl.tk/48) specified style engine.
+
+Its basic idea is to separate, to the extent possible, the code
+implementing a widget's behavior from the code implementing its
+appearance. Widget class bindings are primarily responsible for
+maintaining the widget state and invoking callbacks, all aspects
+of the widgets appearance lies at Themes.
+"""
+
+__version__ = "0.3.1"
+
+__author__ = "Guilherme Polo <ggpolo@gmail.com>"
+
+__all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
+           "Labelframe", "LabelFrame", "Menubutton", "Notebook", "Panedwindow",
+           "PanedWindow", "Progressbar", "Radiobutton", "Scale", "Scrollbar",
+           "Separator", "Sizegrip", "Spinbox", "Style", "Treeview",
+           # Extensions
+           "LabeledScale", "OptionMenu",
+           # functions
+           "tclobjs_to_py", "setup_master"]
+
+import tkinter
+from tkinter import _flatten, _join, _stringify, _splitdict
+
+# Verify if Tk is new enough to not need the Tile package
+_REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
+
+def _load_tile(master):
+    if _REQUIRE_TILE:
+        import os
+        tilelib = os.environ.get('TILE_LIBRARY')
+        if tilelib:
+            # append custom tile path to the list of directories that
+            # Tcl uses when attempting to resolve packages with the package
+            # command
+            master.tk.eval(
+                    'global auto_path; '
+                    'lappend auto_path {%s}' % tilelib)
+
+        master.tk.eval('package require tile') # TclError may be raised here
+        master._tile_loaded = True
+
+def _format_optvalue(value, script=False):
+    """Internal function."""
+    if script:
+        # if caller passes a Tcl script to tk.call, all the values need to
+        # be grouped into words (arguments to a command in Tcl dialect)
+        value = _stringify(value)
+    elif isinstance(value, (list, tuple)):
+        value = _join(value)
+    return value
+
+def _format_optdict(optdict, script=False, ignore=None):
+    """Formats optdict to a tuple to pass it to tk.call.
+
+    E.g. (script=False):
+      {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns:
+      ('-foreground', 'blue', '-padding', '1 2 3 4')"""
+
+    opts = []
+    for opt, value in optdict.items():
+        if not ignore or opt not in ignore:
+            opts.append("-%s" % opt)
+            if value is not None:
+                opts.append(_format_optvalue(value, script))
+
+    return _flatten(opts)
+
+def _mapdict_values(items):
+    # each value in mapdict is expected to be a sequence, where each item
+    # is another sequence containing a state (or several) and a value
+    # E.g. (script=False):
+    #   [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]
+    #   returns:
+    #   ['active selected', 'grey', 'focus', [1, 2, 3, 4]]
+    opt_val = []
+    for *state, val in items:
+        # hacks for backward compatibility
+        state[0] # raise IndexError if empty
+        if len(state) == 1:
+            # if it is empty (something that evaluates to False), then
+            # format it to Tcl code to denote the "normal" state
+            state = state[0] or ''
+        else:
+            # group multiple states
+            state = ' '.join(state) # raise TypeError if not str
+        opt_val.append(state)
+        if val is not None:
+            opt_val.append(val)
+    return opt_val
+
+def _format_mapdict(mapdict, script=False):
+    """Formats mapdict to pass it to tk.call.
+
+    E.g. (script=False):
+      {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]}
+
+      returns:
+
+      ('-expand', '{active selected} grey focus {1, 2, 3, 4}')"""
+
+    opts = []
+    for opt, value in mapdict.items():
+        opts.extend(("-%s" % opt,
+                     _format_optvalue(_mapdict_values(value), script)))
+
+    return _flatten(opts)
+
+def _format_elemcreate(etype, script=False, *args, **kw):
+    """Formats args and kw according to the given element factory etype."""
+    spec = None
+    opts = ()
+    if etype in ("image", "vsapi"):
+        if etype == "image": # define an element based on an image
+            # first arg should be the default image name
+            iname = args[0]
+            # next args, if any, are statespec/value pairs which is almost
+            # a mapdict, but we just need the value
+            imagespec = _join(_mapdict_values(args[1:]))
+            spec = "%s %s" % (iname, imagespec)
+
+        else:
+            # define an element whose visual appearance is drawn using the
+            # Microsoft Visual Styles API which is responsible for the
+            # themed styles on Windows XP and Vista.
+            # Availability: Tk 8.6, Windows XP and Vista.
+            class_name, part_id = args[:2]
+            statemap = _join(_mapdict_values(args[2:]))
+            spec = "%s %s %s" % (class_name, part_id, statemap)
+
+        opts = _format_optdict(kw, script)
+
+    elif etype == "from": # clone an element
+        # it expects a themename and optionally an element to clone from,
+        # otherwise it will clone {} (empty element)
+        spec = args[0] # theme name
+        if len(args) > 1: # elementfrom specified
+            opts = (_format_optvalue(args[1], script),)
+
+    if script:
+        spec = '{%s}' % spec
+        opts = ' '.join(opts)
+
+    return spec, opts
+
+def _format_layoutlist(layout, indent=0, indent_size=2):
+    """Formats a layout list so we can pass the result to ttk::style
+    layout and ttk::style settings. Note that the layout doesn't have to
+    be a list necessarily.
+
+    E.g.:
+      [("Menubutton.background", None),
+       ("Menubutton.button", {"children":
+           [("Menubutton.focus", {"children":
+               [("Menubutton.padding", {"children":
+                [("Menubutton.label", {"side": "left", "expand": 1})]
+               })]
+           })]
+       }),
+       ("Menubutton.indicator", {"side": "right"})
+      ]
+
+      returns:
+
+      Menubutton.background
+      Menubutton.button -children {
+        Menubutton.focus -children {
+          Menubutton.padding -children {
+            Menubutton.label -side left -expand 1
+          }
+        }
+      }
+      Menubutton.indicator -side right"""
+    script = []
+
+    for layout_elem in layout:
+        elem, opts = layout_elem
+        opts = opts or {}
+        fopts = ' '.join(_format_optdict(opts, True, ("children",)))
+        head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '')
+
+        if "children" in opts:
+            script.append(head + " -children {")
+            indent += indent_size
+            newscript, indent = _format_layoutlist(opts['children'], indent,
+                indent_size)
+            script.append(newscript)
+            indent -= indent_size
+            script.append('%s}' % (' ' * indent))
+        else:
+            script.append(head)
+
+    return '\n'.join(script), indent
+
+def _script_from_settings(settings):
+    """Returns an appropriate script, based on settings, according to
+    theme_settings definition to be used by theme_settings and
+    theme_create."""
+    script = []
+    # a script will be generated according to settings passed, which
+    # will then be evaluated by Tcl
+    for name, opts in settings.items():
+        # will format specific keys according to Tcl code
+        if opts.get('configure'): # format 'configure'
+            s = ' '.join(_format_optdict(opts['configure'], True))
+            script.append("ttk::style configure %s %s;" % (name, s))
+
+        if opts.get('map'): # format 'map'
+            s = ' '.join(_format_mapdict(opts['map'], True))
+            script.append("ttk::style map %s %s;" % (name, s))
+
+        if 'layout' in opts: # format 'layout' which may be empty
+            if not opts['layout']:
+                s = 'null' # could be any other word, but this one makes sense
+            else:
+                s, _ = _format_layoutlist(opts['layout'])
+            script.append("ttk::style layout %s {\n%s\n}" % (name, s))
+
+        if opts.get('element create'): # format 'element create'
+            eopts = opts['element create']
+            etype = eopts[0]
+
+            # find where args end, and where kwargs start
+            argc = 1 # etype was the first one
+            while argc < len(eopts) and not hasattr(eopts[argc], 'items'):
+                argc += 1
+
+            elemargs = eopts[1:argc]
+            elemkw = eopts[argc] if argc < len(eopts) and eopts[argc] else {}
+            spec, opts = _format_elemcreate(etype, True, *elemargs, **elemkw)
+
+            script.append("ttk::style element create %s %s %s %s" % (
+                name, etype, spec, opts))
+
+    return '\n'.join(script)
+
+def _list_from_statespec(stuple):
+    """Construct a list from the given statespec tuple according to the
+    accepted statespec accepted by _format_mapdict."""
+    nval = []
+    for val in stuple:
+        typename = getattr(val, 'typename', None)
+        if typename is None:
+            nval.append(val)
+        else: # this is a Tcl object
+            val = str(val)
+            if typename == 'StateSpec':
+                val = val.split()
+            nval.append(val)
+
+    it = iter(nval)
+    return [_flatten(spec) for spec in zip(it, it)]
+
+def _list_from_layouttuple(tk, ltuple):
+    """Construct a list from the tuple returned by ttk::layout, this is
+    somewhat the reverse of _format_layoutlist."""
+    ltuple = tk.splitlist(ltuple)
+    res = []
+
+    indx = 0
+    while indx < len(ltuple):
+        name = ltuple[indx]
+        opts = {}
+        res.append((name, opts))
+        indx += 1
+
+        while indx < len(ltuple): # grab name's options
+            opt, val = ltuple[indx:indx + 2]
+            if not opt.startswith('-'): # found next name
+                break
+
+            opt = opt[1:] # remove the '-' from the option
+            indx += 2
+
+            if opt == 'children':
+                val = _list_from_layouttuple(tk, val)
+
+            opts[opt] = val
+
+    return res
+
+def _val_or_dict(tk, options, *args):
+    """Format options then call Tk command with args and options and return
+    the appropriate result.
+
+    If no option is specified, a dict is returned. If an option is
+    specified with the None value, the value for that option is returned.
+    Otherwise, the function just sets the passed options and the caller
+    shouldn't be expecting a return value anyway."""
+    options = _format_optdict(options)
+    res = tk.call(*(args + options))
+
+    if len(options) % 2: # option specified without a value, return its value
+        return res
+
+    return _splitdict(tk, res, conv=_tclobj_to_py)
+
+def _convert_stringval(value):
+    """Converts a value to, hopefully, a more appropriate Python object."""
+    value = str(value)
+    try:
+        value = int(value)
+    except (ValueError, TypeError):
+        pass
+
+    return value
+
+def _to_number(x):
+    if isinstance(x, str):
+        if '.' in x:
+            x = float(x)
+        else:
+            x = int(x)
+    return x
+
+def _tclobj_to_py(val):
+    """Return value converted from Tcl object to Python object."""
+    if val and hasattr(val, '__len__') and not isinstance(val, str):
+        if getattr(val[0], 'typename', None) == 'StateSpec':
+            val = _list_from_statespec(val)
+        else:
+            val = list(map(_convert_stringval, val))
+
+    elif hasattr(val, 'typename'): # some other (single) Tcl object
+        val = _convert_stringval(val)
+
+    return val
+
+def tclobjs_to_py(adict):
+    """Returns adict with its values converted from Tcl objects to Python
+    objects."""
+    for opt, val in adict.items():
+        adict[opt] = _tclobj_to_py(val)
+
+    return adict
+
+def setup_master(master=None):
+    """If master is not None, itself is returned. If master is None,
+    the default master is returned if there is one, otherwise a new
+    master is created and returned.
+
+    If it is not allowed to use the default root and master is None,
+    RuntimeError is raised."""
+    if master is None:
+        if tkinter._support_default_root:
+            master = tkinter._default_root or tkinter.Tk()
+        else:
+            raise RuntimeError(
+                    "No master specified and tkinter is "
+                    "configured to not support default root")
+    return master
+
+
+class Style(object):
+    """Manipulate style database."""
+
+    _name = "ttk::style"
+
+    def __init__(self, master=None):
+        master = setup_master(master)
+
+        if not getattr(master, '_tile_loaded', False):
+            # Load tile now, if needed
+            _load_tile(master)
+
+        self.master = master
+        self.tk = self.master.tk
+
+
+    def configure(self, style, query_opt=None, **kw):
+        """Query or sets the default value of the specified option(s) in
+        style.
+
+        Each key in kw is an option and each value is either a string or
+        a sequence identifying the value for that option."""
+        if query_opt is not None:
+            kw[query_opt] = None
+        result = _val_or_dict(self.tk, kw, self._name, "configure", style)
+        if result or query_opt:
+            return result
+
+
+    def map(self, style, query_opt=None, **kw):
+        """Query or sets dynamic values of the specified option(s) in
+        style.
+
+        Each key in kw is an option and each value should be a list or a
+        tuple (usually) containing statespecs grouped in tuples, or list,
+        or something else of your preference. A statespec is compound of
+        one or more states and then a value."""
+        if query_opt is not None:
+            return _list_from_statespec(self.tk.splitlist(
+                self.tk.call(self._name, "map", style, '-%s' % query_opt)))
+
+        return _splitdict(
+            self.tk,
+            self.tk.call(self._name, "map", style, *_format_mapdict(kw)),
+            conv=_tclobj_to_py)
+
+
+    def lookup(self, style, option, state=None, default=None):
+        """Returns the value specified for option in style.
+
+        If state is specified it is expected to be a sequence of one
+        or more states. If the default argument is set, it is used as
+        a fallback value in case no specification for option is found."""
+        state = ' '.join(state) if state else ''
+
+        return self.tk.call(self._name, "lookup", style, '-%s' % option,
+            state, default)
+
+
+    def layout(self, style, layoutspec=None):
+        """Define the widget layout for given style. If layoutspec is
+        omitted, return the layout specification for given style.
+
+        layoutspec is expected to be a list or an object different than
+        None that evaluates to False if you want to "turn off" that style.
+        If it is a list (or tuple, or something else), each item should be
+        a tuple where the first item is the layout name and the second item
+        should have the format described below:
+
+        LAYOUTS
+
+            A layout can contain the value None, if takes no options, or
+            a dict of options specifying how to arrange the element.
+            The layout mechanism uses a simplified version of the pack
+            geometry manager: given an initial cavity, each element is
+            allocated a parcel. Valid options/values are:
+
+                side: whichside
+                    Specifies which side of the cavity to place the
+                    element; one of top, right, bottom or left. If
+                    omitted, the element occupies the entire cavity.
+
+                sticky: nswe
+                    Specifies where the element is placed inside its
+                    allocated parcel.
+
+                children: [sublayout... ]
+                    Specifies a list of elements to place inside the
+                    element. Each element is a tuple (or other sequence)
+                    where the first item is the layout name, and the other
+                    is a LAYOUT."""
+        lspec = None
+        if layoutspec:
+            lspec = _format_layoutlist(layoutspec)[0]
+        elif layoutspec is not None: # will disable the layout ({}, '', etc)
+            lspec = "null" # could be any other word, but this may make sense
+                           # when calling layout(style) later
+
+        return _list_from_layouttuple(self.tk,
+            self.tk.call(self._name, "layout", style, lspec))
+
+
+    def element_create(self, elementname, etype, *args, **kw):
+        """Create a new element in the current theme of given etype."""
+        spec, opts = _format_elemcreate(etype, False, *args, **kw)
+        self.tk.call(self._name, "element", "create", elementname, etype,
+            spec, *opts)
+
+
+    def element_names(self):
+        """Returns the list of elements defined in the current theme."""
+        return tuple(n.lstrip('-') for n in self.tk.splitlist(
+            self.tk.call(self._name, "element", "names")))
+
+
+    def element_options(self, elementname):
+        """Return the list of elementname's options."""
+        return tuple(o.lstrip('-') for o in self.tk.splitlist(
+            self.tk.call(self._name, "element", "options", elementname)))
+
+
+    def theme_create(self, themename, parent=None, settings=None):
+        """Creates a new theme.
+
+        It is an error if themename already exists. If parent is
+        specified, the new theme will inherit styles, elements and
+        layouts from the specified parent theme. If settings are present,
+        they are expected to have the same syntax used for theme_settings."""
+        script = _script_from_settings(settings) if settings else ''
+
+        if parent:
+            self.tk.call(self._name, "theme", "create", themename,
+                "-parent", parent, "-settings", script)
+        else:
+            self.tk.call(self._name, "theme", "create", themename,
+                "-settings", script)
+
+
+    def theme_settings(self, themename, settings):
+        """Temporarily sets the current theme to themename, apply specified
+        settings and then restore the previous theme.
+
+        Each key in settings is a style and each value may contain the
+        keys 'configure', 'map', 'layout' and 'element create' and they
+        are expected to have the same format as specified by the methods
+        configure, map, layout and element_create respectively."""
+        script = _script_from_settings(settings)
+        self.tk.call(self._name, "theme", "settings", themename, script)
+
+
+    def theme_names(self):
+        """Returns a list of all known themes."""
+        return self.tk.splitlist(self.tk.call(self._name, "theme", "names"))
+
+
+    def theme_use(self, themename=None):
+        """If themename is None, returns the theme in use, otherwise, set
+        the current theme to themename, refreshes all widgets and emits
+        a <<ThemeChanged>> event."""
+        if themename is None:
+            # Starting on Tk 8.6, checking this global is no longer needed
+            # since it allows doing self.tk.call(self._name, "theme", "use")
+            return self.tk.eval("return $ttk::currentTheme")
+
+        # using "ttk::setTheme" instead of "ttk::style theme use" causes
+        # the variable currentTheme to be updated, also, ttk::setTheme calls
+        # "ttk::style theme use" in order to change theme.
+        self.tk.call("ttk::setTheme", themename)
+
+
+class Widget(tkinter.Widget):
+    """Base class for Tk themed widgets."""
+
+    def __init__(self, master, widgetname, kw=None):
+        """Constructs a Ttk Widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, takefocus, style
+
+        SCROLLABLE WIDGET OPTIONS
+
+            xscrollcommand, yscrollcommand
+
+        LABEL WIDGET OPTIONS
+
+            text, textvariable, underline, image, compound, width
+
+        WIDGET STATES
+
+            active, disabled, focus, pressed, selected, background,
+            readonly, alternate, invalid
+        """
+        master = setup_master(master)
+        if not getattr(master, '_tile_loaded', False):
+            # Load tile now, if needed
+            _load_tile(master)
+        tkinter.Widget.__init__(self, master, widgetname, kw=kw)
+
+
+    def identify(self, x, y):
+        """Returns the name of the element at position x, y, or the empty
+        string if the point does not lie within any element.
+
+        x and y are pixel coordinates relative to the widget."""
+        return self.tk.call(self._w, "identify", x, y)
+
+
+    def instate(self, statespec, callback=None, *args, **kw):
+        """Test the widget's state.
+
+        If callback is not specified, returns True if the widget state
+        matches statespec and False otherwise. If callback is specified,
+        then it will be invoked with *args, **kw if the widget state
+        matches statespec. statespec is expected to be a sequence."""
+        ret = self.tk.getboolean(
+                self.tk.call(self._w, "instate", ' '.join(statespec)))
+        if ret and callback:
+            return callback(*args, **kw)
+
+        return ret
+
+
+    def state(self, statespec=None):
+        """Modify or inquire widget state.
+
+        Widget state is returned if statespec is None, otherwise it is
+        set according to the statespec flags and then a new state spec
+        is returned indicating which flags were changed. statespec is
+        expected to be a sequence."""
+        if statespec is not None:
+            statespec = ' '.join(statespec)
+
+        return self.tk.splitlist(str(self.tk.call(self._w, "state", statespec)))
+
+
+class Button(Widget):
+    """Ttk Button widget, displays a textual label and/or image, and
+    evaluates a command when pressed."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Button widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, compound, cursor, image, state, style, takefocus,
+            text, textvariable, underline, width
+
+        WIDGET-SPECIFIC OPTIONS
+
+            command, default, width
+        """
+        Widget.__init__(self, master, "ttk::button", kw)
+
+
+    def invoke(self):
+        """Invokes the command associated with the button."""
+        return self.tk.call(self._w, "invoke")
+
+
+class Checkbutton(Widget):
+    """Ttk Checkbutton widget which is either in on- or off-state."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Checkbutton widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, compound, cursor, image, state, style, takefocus,
+            text, textvariable, underline, width
+
+        WIDGET-SPECIFIC OPTIONS
+
+            command, offvalue, onvalue, variable
+        """
+        Widget.__init__(self, master, "ttk::checkbutton", kw)
+
+
+    def invoke(self):
+        """Toggles between the selected and deselected states and
+        invokes the associated command. If the widget is currently
+        selected, sets the option variable to the offvalue option
+        and deselects the widget; otherwise, sets the option variable
+        to the option onvalue.
+
+        Returns the result of the associated command."""
+        return self.tk.call(self._w, "invoke")
+
+
+class Entry(Widget, tkinter.Entry):
+    """Ttk Entry widget displays a one-line text string and allows that
+    string to be edited by the user."""
+
+    def __init__(self, master=None, widget=None, **kw):
+        """Constructs a Ttk Entry widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus, xscrollcommand
+
+        WIDGET-SPECIFIC OPTIONS
+
+            exportselection, invalidcommand, justify, show, state,
+            textvariable, validate, validatecommand, width
+
+        VALIDATION MODES
+
+            none, key, focus, focusin, focusout, all
+        """
+        Widget.__init__(self, master, widget or "ttk::entry", kw)
+
+
+    def bbox(self, index):
+        """Return a tuple of (x, y, width, height) which describes the
+        bounding box of the character given by index."""
+        return self._getints(self.tk.call(self._w, "bbox", index))
+
+
+    def identify(self, x, y):
+        """Returns the name of the element at position x, y, or the
+        empty string if the coordinates are outside the window."""
+        return self.tk.call(self._w, "identify", x, y)
+
+
+    def validate(self):
+        """Force revalidation, independent of the conditions specified
+        by the validate option. Returns False if validation fails, True
+        if it succeeds. Sets or clears the invalid state accordingly."""
+        return self.tk.getboolean(self.tk.call(self._w, "validate"))
+
+
+class Combobox(Entry):
+    """Ttk Combobox widget combines a text field with a pop-down list of
+    values."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Combobox widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            exportselection, justify, height, postcommand, state,
+            textvariable, values, width
+        """
+        Entry.__init__(self, master, "ttk::combobox", **kw)
+
+
+    def current(self, newindex=None):
+        """If newindex is supplied, sets the combobox value to the
+        element at position newindex in the list of values. Otherwise,
+        returns the index of the current value in the list of values
+        or -1 if the current value does not appear in the list."""
+        if newindex is None:
+            return self.tk.getint(self.tk.call(self._w, "current"))
+        return self.tk.call(self._w, "current", newindex)
+
+
+    def set(self, value):
+        """Sets the value of the combobox to value."""
+        self.tk.call(self._w, "set", value)
+
+
+class Frame(Widget):
+    """Ttk Frame widget is a container, used to group other widgets
+    together."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Frame with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            borderwidth, relief, padding, width, height
+        """
+        Widget.__init__(self, master, "ttk::frame", kw)
+
+
+class Label(Widget):
+    """Ttk Label widget displays a textual label and/or image."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Label with parent master.
+
+        STANDARD OPTIONS
+
+            class, compound, cursor, image, style, takefocus, text,
+            textvariable, underline, width
+
+        WIDGET-SPECIFIC OPTIONS
+
+            anchor, background, font, foreground, justify, padding,
+            relief, text, wraplength
+        """
+        Widget.__init__(self, master, "ttk::label", kw)
+
+
+class Labelframe(Widget):
+    """Ttk Labelframe widget is a container used to group other widgets
+    together. It has an optional label, which may be a plain text string
+    or another widget."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Labelframe with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+            labelanchor, text, underline, padding, labelwidget, width,
+            height
+        """
+        Widget.__init__(self, master, "ttk::labelframe", kw)
+
+LabelFrame = Labelframe # tkinter name compatibility
+
+
+class Menubutton(Widget):
+    """Ttk Menubutton widget displays a textual label and/or image, and
+    displays a menu when pressed."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Menubutton with parent master.
+
+        STANDARD OPTIONS
+
+            class, compound, cursor, image, state, style, takefocus,
+            text, textvariable, underline, width
+
+        WIDGET-SPECIFIC OPTIONS
+
+            direction, menu
+        """
+        Widget.__init__(self, master, "ttk::menubutton", kw)
+
+
+class Notebook(Widget):
+    """Ttk Notebook widget manages a collection of windows and displays
+    a single one at a time. Each child window is associated with a tab,
+    which the user may select to change the currently-displayed window."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Notebook with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            height, padding, width
+
+        TAB OPTIONS
+
+            state, sticky, padding, text, image, compound, underline
+
+        TAB IDENTIFIERS (tab_id)
+
+            The tab_id argument found in several methods may take any of
+            the following forms:
+
+                * An integer between zero and the number of tabs
+                * The name of a child window
+                * A positional specification of the form "@x,y", which
+                  defines the tab
+                * The string "current", which identifies the
+                  currently-selected tab
+                * The string "end", which returns the number of tabs (only
+                  valid for method index)
+        """
+        Widget.__init__(self, master, "ttk::notebook", kw)
+
+
+    def add(self, child, **kw):
+        """Adds a new tab to the notebook.
+
+        If window is currently managed by the notebook but hidden, it is
+        restored to its previous position."""
+        self.tk.call(self._w, "add", child, *(_format_optdict(kw)))
+
+
+    def forget(self, tab_id):
+        """Removes the tab specified by tab_id, unmaps and unmanages the
+        associated window."""
+        self.tk.call(self._w, "forget", tab_id)
+
+
+    def hide(self, tab_id):
+        """Hides the tab specified by tab_id.
+
+        The tab will not be displayed, but the associated window remains
+        managed by the notebook and its configuration remembered. Hidden
+        tabs may be restored with the add command."""
+        self.tk.call(self._w, "hide", tab_id)
+
+
+    def identify(self, x, y):
+        """Returns the name of the tab element at position x, y, or the
+        empty string if none."""
+        return self.tk.call(self._w, "identify", x, y)
+
+
+    def index(self, tab_id):
+        """Returns the numeric index of the tab specified by tab_id, or
+        the total number of tabs if tab_id is the string "end"."""
+        return self.tk.getint(self.tk.call(self._w, "index", tab_id))
+
+
+    def insert(self, pos, child, **kw):
+        """Inserts a pane at the specified position.
+
+        pos is either the string end, an integer index, or the name of
+        a managed child. If child is already managed by the notebook,
+        moves it to the specified position."""
+        self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw)))
+
+
+    def select(self, tab_id=None):
+        """Selects the specified tab.
+
+        The associated child window will be displayed, and the
+        previously-selected window (if different) is unmapped. If tab_id
+        is omitted, returns the widget name of the currently selected
+        pane."""
+        return self.tk.call(self._w, "select", tab_id)
+
+
+    def tab(self, tab_id, option=None, **kw):
+        """Query or modify the options of the specific tab_id.
+
+        If kw is not given, returns a dict of the tab option values. If option
+        is specified, returns the value of that option. Otherwise, sets the
+        options to the corresponding values."""
+        if option is not None:
+            kw[option] = None
+        return _val_or_dict(self.tk, kw, self._w, "tab", tab_id)
+
+
+    def tabs(self):
+        """Returns a list of windows managed by the notebook."""
+        return self.tk.splitlist(self.tk.call(self._w, "tabs") or ())
+
+
+    def enable_traversal(self):
+        """Enable keyboard traversal for a toplevel window containing
+        this notebook.
+
+        This will extend the bindings for the toplevel window containing
+        this notebook as follows:
+
+            Control-Tab: selects the tab following the currently selected
+                         one
+
+            Shift-Control-Tab: selects the tab preceding the currently
+                               selected one
+
+            Alt-K: where K is the mnemonic (underlined) character of any
+                   tab, will select that tab.
+
+        Multiple notebooks in a single toplevel may be enabled for
+        traversal, including nested notebooks. However, notebook traversal
+        only works properly if all panes are direct children of the
+        notebook."""
+        # The only, and good, difference I see is about mnemonics, which works
+        # after calling this method. Control-Tab and Shift-Control-Tab always
+        # works (here at least).
+        self.tk.call("ttk::notebook::enableTraversal", self._w)
+
+
+class Panedwindow(Widget, tkinter.PanedWindow):
+    """Ttk Panedwindow widget displays a number of subwindows, stacked
+    either vertically or horizontally."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Panedwindow with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            orient, width, height
+
+        PANE OPTIONS
+
+            weight
+        """
+        Widget.__init__(self, master, "ttk::panedwindow", kw)
+
+
+    forget = tkinter.PanedWindow.forget # overrides Pack.forget
+
+
+    def insert(self, pos, child, **kw):
+        """Inserts a pane at the specified positions.
+
+        pos is either the string end, and integer index, or the name
+        of a child. If child is already managed by the paned window,
+        moves it to the specified position."""
+        self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw)))
+
+
+    def pane(self, pane, option=None, **kw):
+        """Query or modify the options of the specified pane.
+
+        pane is either an integer index or the name of a managed subwindow.
+        If kw is not given, returns a dict of the pane option values. If
+        option is specified then the value for that option is returned.
+        Otherwise, sets the options to the corresponding values."""
+        if option is not None:
+            kw[option] = None
+        return _val_or_dict(self.tk, kw, self._w, "pane", pane)
+
+
+    def sashpos(self, index, newpos=None):
+        """If newpos is specified, sets the position of sash number index.
+
+        May adjust the positions of adjacent sashes to ensure that
+        positions are monotonically increasing. Sash positions are further
+        constrained to be between 0 and the total size of the widget.
+
+        Returns the new position of sash number index."""
+        return self.tk.getint(self.tk.call(self._w, "sashpos", index, newpos))
+
+PanedWindow = Panedwindow # tkinter name compatibility
+
+
+class Progressbar(Widget):
+    """Ttk Progressbar widget shows the status of a long-running
+    operation. They can operate in two modes: determinate mode shows the
+    amount completed relative to the total amount of work to be done, and
+    indeterminate mode provides an animated display to let the user know
+    that something is happening."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Progressbar with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            orient, length, mode, maximum, value, variable, phase
+        """
+        Widget.__init__(self, master, "ttk::progressbar", kw)
+
+
+    def start(self, interval=None):
+        """Begin autoincrement mode: schedules a recurring timer event
+        that calls method step every interval milliseconds.
+
+        interval defaults to 50 milliseconds (20 steps/second) if omitted."""
+        self.tk.call(self._w, "start", interval)
+
+
+    def step(self, amount=None):
+        """Increments the value option by amount.
+
+        amount defaults to 1.0 if omitted."""
+        self.tk.call(self._w, "step", amount)
+
+
+    def stop(self):
+        """Stop autoincrement mode: cancels any recurring timer event
+        initiated by start."""
+        self.tk.call(self._w, "stop")
+
+
+class Radiobutton(Widget):
+    """Ttk Radiobutton widgets are used in groups to show or change a
+    set of mutually-exclusive options."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Radiobutton with parent master.
+
+        STANDARD OPTIONS
+
+            class, compound, cursor, image, state, style, takefocus,
+            text, textvariable, underline, width
+
+        WIDGET-SPECIFIC OPTIONS
+
+            command, value, variable
+        """
+        Widget.__init__(self, master, "ttk::radiobutton", kw)
+
+
+    def invoke(self):
+        """Sets the option variable to the option value, selects the
+        widget, and invokes the associated command.
+
+        Returns the result of the command, or an empty string if
+        no command is specified."""
+        return self.tk.call(self._w, "invoke")
+
+
+class Scale(Widget, tkinter.Scale):
+    """Ttk Scale widget is typically used to control the numeric value of
+    a linked variable that varies uniformly over some range."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Scale with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            command, from, length, orient, to, value, variable
+        """
+        Widget.__init__(self, master, "ttk::scale", kw)
+
+
+    def configure(self, cnf=None, **kw):
+        """Modify or query scale options.
+
+        Setting a value for any of the "from", "from_" or "to" options
+        generates a <<RangeChanged>> event."""
+        if cnf:
+            kw.update(cnf)
+        Widget.configure(self, **kw)
+        if any(['from' in kw, 'from_' in kw, 'to' in kw]):
+            self.event_generate('<<RangeChanged>>')
+
+
+    def get(self, x=None, y=None):
+        """Get the current value of the value option, or the value
+        corresponding to the coordinates x, y if they are specified.
+
+        x and y are pixel coordinates relative to the scale widget
+        origin."""
+        return self.tk.call(self._w, 'get', x, y)
+
+
+class Scrollbar(Widget, tkinter.Scrollbar):
+    """Ttk Scrollbar controls the viewport of a scrollable widget."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Scrollbar with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            command, orient
+        """
+        Widget.__init__(self, master, "ttk::scrollbar", kw)
+
+
+class Separator(Widget):
+    """Ttk Separator widget displays a horizontal or vertical separator
+    bar."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Separator with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus
+
+        WIDGET-SPECIFIC OPTIONS
+
+            orient
+        """
+        Widget.__init__(self, master, "ttk::separator", kw)
+
+
+class Sizegrip(Widget):
+    """Ttk Sizegrip allows the user to resize the containing toplevel
+    window by pressing and dragging the grip."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Sizegrip with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, state, style, takefocus
+        """
+        Widget.__init__(self, master, "ttk::sizegrip", kw)
+
+
+class Spinbox(Entry):
+    """Ttk Spinbox is an Entry with increment and decrement arrows
+
+    It is commonly used for number entry or to select from a list of
+    string values.
+    """
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Spinbox widget with the parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus, validate,
+            validatecommand, xscrollcommand, invalidcommand
+
+        WIDGET-SPECIFIC OPTIONS
+
+            to, from_, increment, values, wrap, format, command
+        """
+        Entry.__init__(self, master, "ttk::spinbox", **kw)
+
+
+    def set(self, value):
+        """Sets the value of the Spinbox to value."""
+        self.tk.call(self._w, "set", value)
+
+
+class Treeview(Widget, tkinter.XView, tkinter.YView):
+    """Ttk Treeview widget displays a hierarchical collection of items.
+
+    Each item has a textual label, an optional image, and an optional list
+    of data values. The data values are displayed in successive columns
+    after the tree label."""
+
+    def __init__(self, master=None, **kw):
+        """Construct a Ttk Treeview with parent master.
+
+        STANDARD OPTIONS
+
+            class, cursor, style, takefocus, xscrollcommand,
+            yscrollcommand
+
+        WIDGET-SPECIFIC OPTIONS
+
+            columns, displaycolumns, height, padding, selectmode, show
+
+        ITEM OPTIONS
+
+            text, image, values, open, tags
+
+        TAG OPTIONS
+
+            foreground, background, font, image
+        """
+        Widget.__init__(self, master, "ttk::treeview", kw)
+
+
+    def bbox(self, item, column=None):
+        """Returns the bounding box (relative to the treeview widget's
+        window) of the specified item in the form x y width height.
+
+        If column is specified, returns the bounding box of that cell.
+        If the item is not visible (i.e., if it is a descendant of a
+        closed item or is scrolled offscreen), returns an empty string."""
+        return self._getints(self.tk.call(self._w, "bbox", item, column)) or ''
+
+
+    def get_children(self, item=None):
+        """Returns a tuple of children belonging to item.
+
+        If item is not specified, returns root children."""
+        return self.tk.splitlist(
+                self.tk.call(self._w, "children", item or '') or ())
+
+
+    def set_children(self, item, *newchildren):
+        """Replaces item's child with newchildren.
+
+        Children present in item that are not present in newchildren
+        are detached from tree. No items in newchildren may be an
+        ancestor of item."""
+        self.tk.call(self._w, "children", item, newchildren)
+
+
+    def column(self, column, option=None, **kw):
+        """Query or modify the options for the specified column.
+
+        If kw is not given, returns a dict of the column option values. If
+        option is specified then the value for that option is returned.
+        Otherwise, sets the options to the corresponding values."""
+        if option is not None:
+            kw[option] = None
+        return _val_or_dict(self.tk, kw, self._w, "column", column)
+
+
+    def delete(self, *items):
+        """Delete all specified items and all their descendants. The root
+        item may not be deleted."""
+        self.tk.call(self._w, "delete", items)
+
+
+    def detach(self, *items):
+        """Unlinks all of the specified items from the tree.
+
+        The items and all of their descendants are still present, and may
+        be reinserted at another point in the tree, but will not be
+        displayed. The root item may not be detached."""
+        self.tk.call(self._w, "detach", items)
+
+
+    def exists(self, item):
+        """Returns True if the specified item is present in the tree,
+        False otherwise."""
+        return self.tk.getboolean(self.tk.call(self._w, "exists", item))
+
+
+    def focus(self, item=None):
+        """If item is specified, sets the focus item to item. Otherwise,
+        returns the current focus item, or '' if there is none."""
+        return self.tk.call(self._w, "focus", item)
+
+
+    def heading(self, column, option=None, **kw):
+        """Query or modify the heading options for the specified column.
+
+        If kw is not given, returns a dict of the heading option values. If
+        option is specified then the value for that option is returned.
+        Otherwise, sets the options to the corresponding values.
+
+        Valid options/values are:
+            text: text
+                The text to display in the column heading
+            image: image_name
+                Specifies an image to display to the right of the column
+                heading
+            anchor: anchor
+                Specifies how the heading text should be aligned. One of
+                the standard Tk anchor values
+            command: callback
+                A callback to be invoked when the heading label is
+                pressed.
+
+        To configure the tree column heading, call this with column = "#0" """
+        cmd = kw.get('command')
+        if cmd and not isinstance(cmd, str):
+            # callback not registered yet, do it now
+            kw['command'] = self.master.register(cmd, self._substitute)
+
+        if option is not None:
+            kw[option] = None
+
+        return _val_or_dict(self.tk, kw, self._w, 'heading', column)
+
+
+    def identify(self, component, x, y):
+        """Returns a description of the specified component under the
+        point given by x and y, or the empty string if no such component
+        is present at that position."""
+        return self.tk.call(self._w, "identify", component, x, y)
+
+
+    def identify_row(self, y):
+        """Returns the item ID of the item at position y."""
+        return self.identify("row", 0, y)
+
+
+    def identify_column(self, x):
+        """Returns the data column identifier of the cell at position x.
+
+        The tree column has ID #0."""
+        return self.identify("column", x, 0)
+
+
+    def identify_region(self, x, y):
+        """Returns one of:
+
+        heading: Tree heading area.
+        separator: Space between two columns headings;
+        tree: The tree area.
+        cell: A data cell.
+
+        * Availability: Tk 8.6"""
+        return self.identify("region", x, y)
+
+
+    def identify_element(self, x, y):
+        """Returns the element at position x, y.
+
+        * Availability: Tk 8.6"""
+        return self.identify("element", x, y)
+
+
+    def index(self, item):
+        """Returns the integer index of item within its parent's list
+        of children."""
+        return self.tk.getint(self.tk.call(self._w, "index", item))
+
+
+    def insert(self, parent, index, iid=None, **kw):
+        """Creates a new item and return the item identifier of the newly
+        created item.
+
+        parent is the item ID of the parent item, or the empty string
+        to create a new top-level item. index is an integer, or the value
+        end, specifying where in the list of parent's children to insert
+        the new item. If index is less than or equal to zero, the new node
+        is inserted at the beginning, if index is greater than or equal to
+        the current number of children, it is inserted at the end. If iid
+        is specified, it is used as the item identifier, iid must not
+        already exist in the tree. Otherwise, a new unique identifier
+        is generated."""
+        opts = _format_optdict(kw)
+        if iid is not None:
+            res = self.tk.call(self._w, "insert", parent, index,
+                "-id", iid, *opts)
+        else:
+            res = self.tk.call(self._w, "insert", parent, index, *opts)
+
+        return res
+
+
+    def item(self, item, option=None, **kw):
+        """Query or modify the options for the specified item.
+
+        If no options are given, a dict with options/values for the item
+        is returned. If option is specified then the value for that option
+        is returned. Otherwise, sets the options to the corresponding
+        values as given by kw."""
+        if option is not None:
+            kw[option] = None
+        return _val_or_dict(self.tk, kw, self._w, "item", item)
+
+
+    def move(self, item, parent, index):
+        """Moves item to position index in parent's list of children.
+
+        It is illegal to move an item under one of its descendants. If
+        index is less than or equal to zero, item is moved to the
+        beginning, if greater than or equal to the number of children,
+        it is moved to the end. If item was detached it is reattached."""
+        self.tk.call(self._w, "move", item, parent, index)
+
+    reattach = move # A sensible method name for reattaching detached items
+
+
+    def next(self, item):
+        """Returns the identifier of item's next sibling, or '' if item
+        is the last child of its parent."""
+        return self.tk.call(self._w, "next", item)
+
+
+    def parent(self, item):
+        """Returns the ID of the parent of item, or '' if item is at the
+        top level of the hierarchy."""
+        return self.tk.call(self._w, "parent", item)
+
+
+    def prev(self, item):
+        """Returns the identifier of item's previous sibling, or '' if
+        item is the first child of its parent."""
+        return self.tk.call(self._w, "prev", item)
+
+
+    def see(self, item):
+        """Ensure that item is visible.
+
+        Sets all of item's ancestors open option to True, and scrolls
+        the widget if necessary so that item is within the visible
+        portion of the tree."""
+        self.tk.call(self._w, "see", item)
+
+
+    def selection(self):
+        """Returns the tuple of selected items."""
+        return self.tk.splitlist(self.tk.call(self._w, "selection"))
+
+
+    def _selection(self, selop, items):
+        if len(items) == 1 and isinstance(items[0], (tuple, list)):
+            items = items[0]
+
+        self.tk.call(self._w, "selection", selop, items)
+
+
+    def selection_set(self, *items):
+        """The specified items becomes the new selection."""
+        self._selection("set", items)
+
+
+    def selection_add(self, *items):
+        """Add all of the specified items to the selection."""
+        self._selection("add", items)
+
+
+    def selection_remove(self, *items):
+        """Remove all of the specified items from the selection."""
+        self._selection("remove", items)
+
+
+    def selection_toggle(self, *items):
+        """Toggle the selection state of each specified item."""
+        self._selection("toggle", items)
+
+
+    def set(self, item, column=None, value=None):
+        """Query or set the value of given item.
+
+        With one argument, return a dictionary of column/value pairs
+        for the specified item. With two arguments, return the current
+        value of the specified column. With three arguments, set the
+        value of given column in given item to the specified value."""
+        res = self.tk.call(self._w, "set", item, column, value)
+        if column is None and value is None:
+            return _splitdict(self.tk, res,
+                              cut_minus=False, conv=_tclobj_to_py)
+        else:
+            return res
+
+
+    def tag_bind(self, tagname, sequence=None, callback=None):
+        """Bind a callback for the given event sequence to the tag tagname.
+        When an event is delivered to an item, the callbacks for each
+        of the item's tags option are called."""
+        self._bind((self._w, "tag", "bind", tagname), sequence, callback, add=0)
+
+
+    def tag_configure(self, tagname, option=None, **kw):
+        """Query or modify the options for the specified tagname.
+
+        If kw is not given, returns a dict of the option settings for tagname.
+        If option is specified, returns the value for that option for the
+        specified tagname. Otherwise, sets the options to the corresponding
+        values for the given tagname."""
+        if option is not None:
+            kw[option] = None
+        return _val_or_dict(self.tk, kw, self._w, "tag", "configure",
+            tagname)
+
+
+    def tag_has(self, tagname, item=None):
+        """If item is specified, returns 1 or 0 depending on whether the
+        specified item has the given tagname. Otherwise, returns a list of
+        all items which have the specified tag.
+
+        * Availability: Tk 8.6"""
+        if item is None:
+            return self.tk.splitlist(
+                self.tk.call(self._w, "tag", "has", tagname))
+        else:
+            return self.tk.getboolean(
+                self.tk.call(self._w, "tag", "has", tagname, item))
+
+
+# Extensions
+
+class LabeledScale(Frame):
+    """A Ttk Scale widget with a Ttk Label widget indicating its
+    current value.
+
+    The Ttk Scale can be accessed through instance.scale, and Ttk Label
+    can be accessed through instance.label"""
+
+    def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
+        """Construct a horizontal LabeledScale with parent master, a
+        variable to be associated with the Ttk Scale widget and its range.
+        If variable is not specified, a tkinter.IntVar is created.
+
+        WIDGET-SPECIFIC OPTIONS
+
+            compound: 'top' or 'bottom'
+                Specifies how to display the label relative to the scale.
+                Defaults to 'top'.
+        """
+        self._label_top = kw.pop('compound', 'top') == 'top'
+
+        Frame.__init__(self, master, **kw)
+        self._variable = variable or tkinter.IntVar(master)
+        self._variable.set(from_)
+        self._last_valid = from_
+
+        self.label = Label(self)
+        self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
+        self.scale.bind('<<RangeChanged>>', self._adjust)
+
+        # position scale and label according to the compound option
+        scale_side = 'bottom' if self._label_top else 'top'
+        label_side = 'top' if scale_side == 'bottom' else 'bottom'
+        self.scale.pack(side=scale_side, fill='x')
+        tmp = Label(self).pack(side=label_side) # place holder
+        self.label.place(anchor='n' if label_side == 'top' else 's')
+
+        # update the label as scale or variable changes
+        self.__tracecb = self._variable.trace_variable('w', self._adjust)
+        self.bind('<Configure>', self._adjust)
+        self.bind('<Map>', self._adjust)
+
+
+    def destroy(self):
+        """Destroy this widget and possibly its associated variable."""
+        try:
+            self._variable.trace_vdelete('w', self.__tracecb)
+        except AttributeError:
+            pass
+        else:
+            del self._variable
+        super().destroy()
+        self.label = None
+        self.scale = None
+
+
+    def _adjust(self, *args):
+        """Adjust the label position according to the scale."""
+        def adjust_label():
+            self.update_idletasks() # "force" scale redraw
+
+            x, y = self.scale.coords()
+            if self._label_top:
+                y = self.scale.winfo_y() - self.label.winfo_reqheight()
+            else:
+                y = self.scale.winfo_reqheight() + self.label.winfo_reqheight()
+
+            self.label.place_configure(x=x, y=y)
+
+        from_ = _to_number(self.scale['from'])
+        to = _to_number(self.scale['to'])
+        if to < from_:
+            from_, to = to, from_
+        newval = self._variable.get()
+        if not from_ <= newval <= to:
+            # value outside range, set value back to the last valid one
+            self.value = self._last_valid
+            return
+
+        self._last_valid = newval
+        self.label['text'] = newval
+        self.after_idle(adjust_label)
+
+    @property
+    def value(self):
+        """Return current scale value."""
+        return self._variable.get()
+
+    @value.setter
+    def value(self, val):
+        """Set new scale value."""
+        self._variable.set(val)
+
+
+class OptionMenu(Menubutton):
+    """Themed OptionMenu, based after tkinter's OptionMenu, which allows
+    the user to select a value from a menu."""
+
+    def __init__(self, master, variable, default=None, *values, **kwargs):
+        """Construct a themed OptionMenu widget with master as the parent,
+        the resource textvariable set to variable, the initially selected
+        value specified by the default parameter, the menu values given by
+        *values and additional keywords.
+
+        WIDGET-SPECIFIC OPTIONS
+
+            style: stylename
+                Menubutton style.
+            direction: 'above', 'below', 'left', 'right', or 'flush'
+                Menubutton direction.
+            command: callback
+                A callback that will be invoked after selecting an item.
+        """
+        kw = {'textvariable': variable, 'style': kwargs.pop('style', None),
+              'direction': kwargs.pop('direction', None)}
+        Menubutton.__init__(self, master, **kw)
+        self['menu'] = tkinter.Menu(self, tearoff=False)
+
+        self._variable = variable
+        self._callback = kwargs.pop('command', None)
+        if kwargs:
+            raise tkinter.TclError('unknown option -%s' % (
+                next(iter(kwargs.keys()))))
+
+        self.set_menu(default, *values)
+
+
+    def __getitem__(self, item):
+        if item == 'menu':
+            return self.nametowidget(Menubutton.__getitem__(self, item))
+
+        return Menubutton.__getitem__(self, item)
+
+
+    def set_menu(self, default=None, *values):
+        """Build a new menu of radiobuttons with *values and optionally
+        a default value."""
+        menu = self['menu']
+        menu.delete(0, 'end')
+        for val in values:
+            menu.add_radiobutton(label=val,
+                command=tkinter._setit(self._variable, val, self._callback),
+                variable=self._variable)
+
+        if default:
+            self._variable.set(default)
+
+
+    def destroy(self):
+        """Destroy this widget and its associated variable."""
+        try:
+            del self._variable
+        except AttributeError:
+            pass
+        super().destroy()
index 8f4610145aca353591433aac407f09bdb7b8ee15..a3f75af52795cae5201b54f2516a23e32c019c1d 100644 (file)
@@ -526,7 +526,8 @@ class TestCase(object):
         """Fail if the two objects are unequal as determined by their
            difference rounded to the given number of decimal places
            (default 7) and comparing to zero, or by comparing that the
-           between the two objects is more than the given delta.
+           difference between the two objects is more than the given
+           delta.
 
            Note that decimal places (from zero) are usually not the same
            as significant digits (measured from the most significant digit).
@@ -564,7 +565,7 @@ class TestCase(object):
         """Fail if the two objects are equal as determined by their
            difference rounded to the given number of decimal places
            (default 7) and comparing to zero, or by comparing that the
-           between the two objects is less than the given delta.
+           difference between the two objects is less than the given delta.
 
            Note that decimal places (from zero) are usually not the same
            as significant digits (measured from the most significant digit).
index 7432032df04fa3d8bf5c10814a75cb686ee86667..618bc6385cfcb9ead418bf4526e7237b7fae1db4 100644 (file)
@@ -339,8 +339,9 @@ def _find_mac(command, args, hw_identifiers, get_index):
 def _ifconfig_getnode():
     """Get the hardware address on Unix by running ifconfig."""
     # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
+    keywords = ('hwaddr', 'ether', 'address:', 'lladdr')
     for args in ('', '-a', '-av'):
-        mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1)
+        mac = _find_mac('ifconfig', args, keywords, lambda i: i+1)
         if mac:
             return mac
 
@@ -353,7 +354,20 @@ def _arp_getnode():
         return None
 
     # Try getting the MAC addr from arp based on our IP address (Solaris).
-    return _find_mac('arp', '-an', [ip_addr], lambda i: -1)
+    mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1)
+    if mac:
+        return mac
+
+    # This works on OpenBSD
+    mac = _find_mac('arp', '-an', [ip_addr], lambda i: i+1)
+    if mac:
+        return mac
+
+    # This works on Linux, FreeBSD and NetBSD
+    mac = _find_mac('arp', '-an', ['(%s)' % ip_addr],
+                    lambda i: i+2)
+    if mac:
+        return mac
 
 def _lanscan_getnode():
     """Get the hardware address on Unix by running lanscan."""
index 6f6b20a013f23066160e8093a60602d9dab18896..32e7edc8f48f03bab9a5076a12d2994bf25f1510 100644 (file)
@@ -1,7 +1,15 @@
 Building a Python Mac OS X distribution
 =======================================
 
-The ``build-install.py`` script creates Python distributions, including
+WARNING
+-------
+
+The instructions in this README are incomplete and not up-to-date.
+In particular, they do not explain how to create a modern flat installer
+package from the now obsolete bundle-format installer package produced
+by ``build-installer.py``.
+
+The ``build-installer.py`` script creates Python distributions, including
 certain third-party libraries as necessary.  It builds a complete 
 framework-based Python out-of-tree, installs it in a funny place with 
 $DESTROOT, massages that installation to remove .pyc files and such, creates 
index cf395fb38f6b7b14abecbfa75fce3de24330407d..7875bc8ef419f900e90a95c1432447110fa1606e 100755 (executable)
@@ -1,30 +1,36 @@
 #!/usr/bin/env python
 """
-This script is used to build "official" universal installers on Mac OS X.
-It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for
-32-bit builds.  64-bit or four-way universal builds require at least
-OS X 10.5 and the 10.5 SDK.
+This script is used to build "official" universal installers on macOS.
+
+NEW for 3.6.5:
+- support Intel 64-bit-only () and 32-bit-only installer builds
+- build and link with private Tcl/Tk 8.6 for 10.9+ builds
+- deprecate use of explicit SDK (--sdk-path=) since all but the oldest
+  versions of Xcode support implicit setting of an SDK via environment
+  variables (SDKROOT and friends, see the xcrun man page for more info).
+  The SDK stuff was primarily needed for building universal installers
+  for 10.4; so as of 3.6.5, building installers for 10.4 is no longer
+  supported with build-installer.
+- use generic "gcc" as compiler (CC env var) rather than "gcc-4.2"
 
 Please ensure that this script keeps working with Python 2.5, to avoid
-bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5).  Sphinx,
-which is used to build the documentation, currently requires at least
-Python 2.4.  However, as of Python 3.4.1, Doc builds require an external
-sphinx-build and the current versions of Sphinx now require at least
-Python 2.6.
-
-In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script
-requires an installed third-party version of
-Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5
+bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5).  Doc builds
+use current versions of Sphinx and require a reasonably current python3.
+Sphinx and dependencies are installed into a venv using the python3's pip
+so will fetch them from PyPI if necessary.  Since python3 is now used for
+Sphinx, build-installer.py should also be converted to use python3!
+
+For 10.9 or greater deployment targets, build-installer builds and links
+with its own copy of Tcl/Tk 8.5 and the rest of this paragraph does not
+apply.  Otherwise, build-installer requires an installed third-party version
+of Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5
 (for 10.6 or later) installed in /Library/Frameworks.  When installed,
 the Python built by this script will attempt to dynamically link first to
 Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall
 back to the ones in /System/Library/Framework.  For the build, we recommend
-installing the most recent ActiveTcl 8.4 or 8.5 version.
-
-32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5
-and the installation of additional components, such as a newer Python
-(2.5 is needed for Python parser updates) and for the documentation
-build either svn (pre-3.4.1) or sphinx-build (3.4.1 and later).
+installing the most recent ActiveTcl 8.5 or 8.4 version, depending
+on the deployment target.  The actual version linked to depends on the
+path of /Library/Frameworks/{Tcl,Tk}.framework/Versions/Current.
 
 Usage: see USAGE variable in the script.
 """
@@ -101,6 +107,7 @@ def getFullVersion():
 
 FW_PREFIX = ["Library", "Frameworks", "Python.framework"]
 FW_VERSION_PREFIX = "--undefined--" # initialized in parseOptions
+FW_SSL_DIRECTORY = "--undefined--" # initialized in parseOptions
 
 # The directory we'll use to create the build (will be erased and recreated)
 WORKDIR = "/tmp/_py"
@@ -110,32 +117,19 @@ WORKDIR = "/tmp/_py"
 DEPSRC = os.path.join(WORKDIR, 'third-party')
 DEPSRC = os.path.expanduser('~/Universal/other-sources')
 
-# Location of the preferred SDK
-
-### There are some issues with the SDK selection below here,
-### The resulting binary doesn't work on all platforms that
-### it should. Always default to the 10.4u SDK until that
-### issue is resolved.
-###
-##if int(os.uname()[2].split('.')[0]) == 8:
-##    # Explicitly use the 10.4u (universal) SDK when
-##    # building on 10.4, the system headers are not
-##    # useable for a universal build
-##    SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk"
-##else:
-##    SDKPATH = "/"
-
-SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk"
-
 universal_opts_map = { '32-bit': ('i386', 'ppc',),
                        '64-bit': ('x86_64', 'ppc64',),
                        'intel':  ('i386', 'x86_64'),
+                       'intel-32':  ('i386',),
+                       'intel-64':  ('x86_64',),
                        '3-way':  ('ppc', 'i386', 'x86_64'),
                        'all':    ('i386', 'ppc', 'x86_64', 'ppc64',) }
 default_target_map = {
         '64-bit': '10.5',
         '3-way': '10.5',
         'intel': '10.5',
+        'intel-32': '10.4',
+        'intel-64': '10.5',
         'all': '10.5',
 }
 
@@ -153,23 +147,23 @@ SRCDIR = os.path.dirname(
         ))))
 
 # $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level
-DEPTARGET = '10.3'
+DEPTARGET = '10.5'
 
 def getDeptargetTuple():
     return tuple([int(n) for n in DEPTARGET.split('.')[0:2]])
 
 def getTargetCompilers():
     target_cc_map = {
-        '10.3': ('gcc-4.0', 'g++-4.0'),
         '10.4': ('gcc-4.0', 'g++-4.0'),
-        '10.5': ('gcc-4.2', 'g++-4.2'),
-        '10.6': ('gcc-4.2', 'g++-4.2'),
+        '10.5': ('gcc', 'g++'),
+        '10.6': ('gcc', 'g++'),
     }
-    return target_cc_map.get(DEPTARGET, ('clang', 'clang++') )
+    return target_cc_map.get(DEPTARGET, ('gcc', 'g++') )
 
 CC, CXX = getTargetCompilers()
 
-PYTHON_3 = getVersionMajorMinor() >= (3, 0)
+PYTHON_2 = getVersionMajorMinor()[0] == 2
+PYTHON_3 = getVersionMajorMinor()[0] == 3
 
 USAGE = textwrap.dedent("""\
     Usage: build_python [options]
@@ -179,9 +173,9 @@ USAGE = textwrap.dedent("""\
     -b DIR
     --build-dir=DIR:     Create build here (default: %(WORKDIR)r)
     --third-party=DIR:   Store third-party sources here (default: %(DEPSRC)r)
-    --sdk-path=DIR:      Location of the SDK (default: %(SDKPATH)r)
+    --sdk-path=DIR:      Location of the SDK (deprecated, use SDKROOT env variable)
     --src-dir=DIR:       Location of the Python sources (default: %(SRCDIR)r)
-    --dep-target=10.n    OS X deployment target (default: %(DEPTARGET)r)
+    --dep-target=10.n    macOS deployment target (default: %(DEPTARGET)r)
     --universal-archs=x  universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r)
 """)% globals()
 
@@ -193,6 +187,11 @@ USAGE = textwrap.dedent("""\
 #                       '/Library/Frameworks/Tk.framework/Versions/8.5/Tk']
 EXPECTED_SHARED_LIBS = {}
 
+# Are we building and linking with our own copy of Tcl/TK?
+#   For now, do so if deployment target is 10.9+.
+def internalTk():
+    return getDeptargetTuple() >= (10, 9)
+
 # List of names of third party software built with this installer.
 # The names will be inserted into the rtf version of the License.
 THIRD_PARTY_LIBS = []
@@ -206,61 +205,27 @@ def library_recipes():
 
     LT_10_5 = bool(getDeptargetTuple() < (10, 5))
 
-    if not (10, 5) < getDeptargetTuple() < (10, 10):
-        # The OpenSSL libs shipped with OS X 10.5 and earlier are
-        # hopelessly out-of-date and do not include Apple's tie-in to
-        # the root certificates in the user and system keychains via TEA
-        # that was introduced in OS X 10.6.  Note that this applies to
-        # programs built and linked with a 10.5 SDK even when run on
-        # newer versions of OS X.
-        #
-        # Dealing with CAs is messy.  For now, just supply a
-        # local libssl and libcrypto for the older installer variants
-        # (e.g. the python.org 10.5+ 32-bit-only installer) that use the
-        # same default ssl certfile location as the system libs do:
-        #   /System/Library/OpenSSL/cert.pem
-        # Then at least TLS connections can be negotiated with sites that
-        # use sha-256 certs like python.org, assuming the proper CA certs
-        # have been supplied.  The default CA cert management issues for
-        # 10.5 and earlier builds are the same as before, other than it is
-        # now more obvious with cert checking enabled by default in the
-        # standard library.
-        #
-        # For builds with 10.6 through 10.9 SDKs,
-        # continue to use the deprecated but
-        # less out-of-date Apple 0.9.8 libs for now.  While they are less
-        # secure than using an up-to-date 1.0.1 version, doing so
-        # avoids the big problems of forcing users to have to manage
-        # default CAs themselves, thanks to the Apple libs using private TEA
-        # APIs for cert validation from keychains if validation using the
-        # standard OpenSSL locations (/System/Library/OpenSSL, normally empty)
-        # fails.
-        #
-        # Since Apple removed the header files for the deprecated system
-        # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not
-        # have much choice but to build our own copy here, too.
+    # Since Apple removed the header files for the deprecated system
+    # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not
+    # have much choice but to build our own copy here, too.
 
-        result.extend([
+    result.extend([
           dict(
-              name="OpenSSL 1.0.2k",
-              url="https://www.openssl.org/source/openssl-1.0.2k.tar.gz",
-              checksum='f965fc0bf01bf882b31314b61391ae65',
-              patches=[
-                  "openssl_sdk_makedepend.patch",
-                   ],
+              name="OpenSSL 1.0.2o",
+              url="https://www.openssl.org/source/openssl-1.0.2o.tar.gz",
+              checksum='44279b8557c3247cbe324e2322ecd114',
               buildrecipe=build_universal_openssl,
               configure=None,
               install=None,
           ),
-        ])
+    ])
 
-#   Disable for now
-    if False:   # if getDeptargetTuple() > (10, 5):
+    if internalTk():
         result.extend([
           dict(
-              name="Tcl 8.5.15",
-              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz",
-              checksum='f3df162f92c69b254079c4d0af7a690f',
+              name="Tcl 8.6.8",
+              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl8.6.8-src.tar.gz",
+              checksum='81656d3367af032e0ae6157eff134f89',
               buildDir="unix",
               configure_pre=[
                     '--enable-shared',
@@ -270,15 +235,15 @@ def library_recipes():
               useLDFlags=False,
               install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
                   "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
-                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
+                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
                   },
               ),
           dict(
-              name="Tk 8.5.15",
-              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz",
-              checksum='55b8e33f903210a4e1c8bce0f820657f',
+              name="Tk 8.6.8",
+              url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk8.6.8-src.tar.gz",
+              checksum='5e0faecba458ee1386078fb228d008ba',
               patches=[
-                  "issue19373_tk_8_5_15_source.patch",
+                  "tk868_on_10_8_10_9.patch",
                    ],
               buildDir="unix",
               configure_pre=[
@@ -290,8 +255,8 @@ def library_recipes():
               useLDFlags=False,
               install='make TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
                   "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
-                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
-                  "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())),
+                  "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
+                  "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.6'%(getVersion())),
                   },
                 ),
         ])
@@ -299,9 +264,9 @@ def library_recipes():
     if PYTHON_3:
         result.extend([
           dict(
-              name="XZ 5.0.5",
-              url="http://tukaani.org/xz/xz-5.0.5.tar.gz",
-              checksum='19d924e066b6fff0bc9d1981b4e53196',
+              name="XZ 5.2.3",
+              url="http://tukaani.org/xz/xz-5.2.3.tar.gz",
+              checksum='ef68674fb47a8b8e741b34e429d86e9d',
               configure_pre=[
                     '--disable-dependency-tracking',
               ]
@@ -344,12 +309,14 @@ def library_recipes():
                   ),
           ),
           dict(
-              name="SQLite 3.8.3.1",
-              url="http://www.sqlite.org/2014/sqlite-autoconf-3080301.tar.gz",
-              checksum='509ff98d8dc9729b618b7e96612079c6',
+              name="SQLite 3.22.0",
+              url="https://www.sqlite.org/2018/sqlite-autoconf-3220000.tar.gz",
+              checksum='96b5648d542e8afa6ab7ffb8db8ddc3d',
               extra_cflags=('-Os '
+                            '-DSQLITE_ENABLE_FTS5 '
                             '-DSQLITE_ENABLE_FTS4 '
                             '-DSQLITE_ENABLE_FTS3_PARENTHESIS '
+                            '-DSQLITE_ENABLE_JSON1 '
                             '-DSQLITE_ENABLE_RTREE '
                             '-DSQLITE_TCL=0 '
                  '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]),
@@ -370,11 +337,10 @@ def library_recipes():
               url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz",
               checksum='00b516f4704d4a7cb50a1d97e6e8e15b',
               configure=None,
-              install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+              install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s"'%(
                   CC, CXX,
                   shellQuote(os.path.join(WORKDIR, 'libraries')),
                   ' -arch '.join(ARCHLIST),
-                  SDKPATH,
               ),
           ),
           dict(
@@ -382,11 +348,10 @@ def library_recipes():
               url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz",
               checksum='debc62758716a169df9f62e6ab2bc634',
               configure=None,
-              install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+              install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s"'%(
                   CC, CXX,
                   shellQuote(os.path.join(WORKDIR, 'libraries')),
                   ' -arch '.join(ARCHLIST),
-                  SDKPATH,
               ),
           ),
           dict(
@@ -433,8 +398,7 @@ def pkg_recipes():
             source="/Library/Frameworks/Python.framework",
             readme="""\
                 This package installs Python.framework, that is the python
-                interpreter and the standard library. This also includes Python
-                wrappers for lots of Mac OS X API's.
+                interpreter and the standard library.
             """,
             postflight="scripts/postflight.framework",
             selected='selected',
@@ -511,24 +475,6 @@ def pkg_recipes():
         ),
     ]
 
-    if getDeptargetTuple() < (10, 4) and not PYTHON_3:
-        result.append(
-            dict(
-                name="PythonSystemFixes",
-                long_name="Fix system Python",
-                readme="""\
-                    This package updates the system python installation on
-                    Mac OS X 10.3 to ensure that you can build new python extensions
-                    using that copy of python after installing this version.
-                    """,
-                postflight="../Tools/fixapplepython23.py",
-                topdir="/Library/Frameworks/Python.framework",
-                source="/empty-dir",
-                required=False,
-                selected=unselected_for_python3,
-            )
-        )
-
     return result
 
 def fatal(msg):
@@ -593,55 +539,54 @@ def checkEnvironment():
     Check that we're running on a supported system.
     """
 
-    if sys.version_info[0:2] < (2, 4):
-        fatal("This script must be run with Python 2.4 or later")
+    if sys.version_info[0:2] < (2, 5):
+        fatal("This script must be run with Python 2.5 (or later)")
 
     if platform.system() != 'Darwin':
-        fatal("This script should be run on a Mac OS X 10.4 (or later) system")
+        fatal("This script should be run on a macOS 10.5 (or later) system")
 
     if int(platform.release().split('.')[0]) < 8:
-        fatal("This script should be run on a Mac OS X 10.4 (or later) system")
-
-    if not os.path.exists(SDKPATH):
-        fatal("Please install the latest version of Xcode and the %s SDK"%(
-            os.path.basename(SDKPATH[:-4])))
+        fatal("This script should be run on a macOS 10.5 (or later) system")
 
     # Because we only support dynamic load of only one major/minor version of
+    # Tcl/Tk, if we are not using building and using our own private copy of
     # Tcl/Tk, ensure:
-    # 1. there are no user-installed frameworks of Tcl/Tk with version
-    #       higher than the Apple-supplied system version in
-    #       SDKROOT/System/Library/Frameworks
-    # 2. there is a user-installed framework (usually ActiveTcl) in (or linked
-    #       in) SDKROOT/Library/Frameworks with the same version as the system
-    #       version. This allows users to choose to install a newer patch level.
-
-    frameworks = {}
-    for framework in ['Tcl', 'Tk']:
-        fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
-        sysfw = os.path.join(SDKPATH, 'System', fwpth)
-        libfw = os.path.join(SDKPATH, fwpth)
-        usrfw = os.path.join(os.getenv('HOME'), fwpth)
-        frameworks[framework] = os.readlink(sysfw)
-        if not os.path.exists(libfw):
-            fatal("Please install a link to a current %s %s as %s so "
-                    "the user can override the system framework."
-                    % (framework, frameworks[framework], libfw))
-        if os.readlink(libfw) != os.readlink(sysfw):
-            fatal("Version of %s must match %s" % (libfw, sysfw) )
-        if os.path.exists(usrfw):
-            fatal("Please rename %s to avoid possible dynamic load issues."
-                    % usrfw)
-
-    if frameworks['Tcl'] != frameworks['Tk']:
-        fatal("The Tcl and Tk frameworks are not the same version.")
-
-    # add files to check after build
-    EXPECTED_SHARED_LIBS['_tkinter.so'] = [
-            "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
-                % frameworks['Tcl'],
-            "/Library/Frameworks/Tk.framework/Versions/%s/Tk"
-                % frameworks['Tk'],
-            ]
+    # 1. there is a user-installed framework (usually ActiveTcl) in (or linked
+    #       in) SDKROOT/Library/Frameworks.  As of Python 3.6.5, we no longer
+    #       enforce that the version of the user-installed framework also
+    #       exists in the system-supplied Tcl/Tk frameworks.  Time to support
+    #       Tcl/Tk 8.6 even if Apple does not.
+    if not internalTk():
+        frameworks = {}
+        for framework in ['Tcl', 'Tk']:
+            fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
+            libfw = os.path.join('/', fwpth)
+            usrfw = os.path.join(os.getenv('HOME'), fwpth)
+            frameworks[framework] = os.readlink(libfw)
+            if not os.path.exists(libfw):
+                fatal("Please install a link to a current %s %s as %s so "
+                        "the user can override the system framework."
+                        % (framework, frameworks[framework], libfw))
+            if os.path.exists(usrfw):
+                fatal("Please rename %s to avoid possible dynamic load issues."
+                        % usrfw)
+
+        if frameworks['Tcl'] != frameworks['Tk']:
+            fatal("The Tcl and Tk frameworks are not the same version.")
+
+        print(" -- Building with external Tcl/Tk %s frameworks"
+                    % frameworks['Tk'])
+
+        # add files to check after build
+        EXPECTED_SHARED_LIBS['_tkinter.so'] = [
+                "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
+                    % frameworks['Tcl'],
+                "/Library/Frameworks/Tk.framework/Versions/%s/Tk"
+                    % frameworks['Tk'],
+                ]
+    else:
+        print(" -- Building private copy of Tcl/Tk")
+    print("")
 
     # Remove inherited environment variables which might influence build
     environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
@@ -663,17 +608,19 @@ def checkEnvironment():
         base_path = base_path + ':' + OLD_DEVELOPER_TOOLS
     os.environ['PATH'] = base_path
     print("Setting default PATH: %s"%(os.environ['PATH']))
-    # Ensure we have access to sphinx-build.
-    # You may have to create a link in /usr/bin for it.
-    runCommand('sphinx-build --version')
+    if PYTHON_2:
+        # Ensure we have access to sphinx-build.
+        # You may have to define SDK_TOOLS_BIN and link to it there,
+        runCommand('sphinx-build --version')
 
 def parseOptions(args=None):
     """
     Parse arguments and update global settings.
     """
-    global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET
+    global WORKDIR, DEPSRC, SRCDIR, DEPTARGET
     global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX
     global FW_VERSION_PREFIX
+    global FW_SSL_DIRECTORY
 
     if args is None:
         args = sys.argv[1:]
@@ -703,7 +650,7 @@ def parseOptions(args=None):
             DEPSRC=v
 
         elif k in ('--sdk-path',):
-            SDKPATH=v
+            print(" WARNING: --sdk-path is no longer supported")
 
         elif k in ('--src-dir',):
             SRCDIR=v
@@ -719,7 +666,7 @@ def parseOptions(args=None):
                 if deptarget is None:
                     # Select alternate default deployment
                     # target
-                    DEPTARGET = default_target_map.get(v, '10.3')
+                    DEPTARGET = default_target_map.get(v, '10.5')
             else:
                 raise NotImplementedError(v)
 
@@ -728,17 +675,16 @@ def parseOptions(args=None):
 
     SRCDIR=os.path.abspath(SRCDIR)
     WORKDIR=os.path.abspath(WORKDIR)
-    SDKPATH=os.path.abspath(SDKPATH)
     DEPSRC=os.path.abspath(DEPSRC)
 
     CC, CXX = getTargetCompilers()
 
     FW_VERSION_PREFIX = FW_PREFIX[:] + ["Versions", getVersion()]
+    FW_SSL_DIRECTORY = FW_VERSION_PREFIX[:] + ["etc", "openssl"]
 
     print("-- Settings:")
     print("   * Source directory:    %s" % SRCDIR)
     print("   * Build directory:     %s" % WORKDIR)
-    print("   * SDK location:        %s" % SDKPATH)
     print("   * Third-party source:  %s" % DEPSRC)
     print("   * Deployment target:   %s" % DEPTARGET)
     print("   * Universal archs:     %s" % str(ARCHLIST))
@@ -870,20 +816,19 @@ def build_universal_openssl(basedir, archList):
             "enable-tlsext",
             "no-ssl2",
             "no-ssl3",
-            "no-ssl3-method",
             # "enable-unit-test",
             "shared",
             "--install_prefix=%s"%shellQuote(archbase),
             "--prefix=%s"%os.path.join("/", *FW_VERSION_PREFIX),
-            "--openssldir=/System/Library/OpenSSL",
+            "--openssldir=%s"%os.path.join("/", *FW_SSL_DIRECTORY),
         ]
         if no_asm:
             configure_opts.append("no-asm")
         runCommand(" ".join(["perl", "Configure"]
                         + arch_opts[arch] + configure_opts))
-        runCommand("make depend OSX_SDK=%s" % SDKPATH)
-        runCommand("make all OSX_SDK=%s" % SDKPATH)
-        runCommand("make install_sw OSX_SDK=%s" % SDKPATH)
+        runCommand("make depend")
+        runCommand("make all")
+        runCommand("make install_sw")
         # runCommand("make test")
         return
 
@@ -1042,27 +987,24 @@ def buildRecipe(recipe, basedir, archList):
 
         if recipe.get('useLDFlags', 1):
             configure_args.extend([
-                "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
+                "CFLAGS=%s-mmacosx-version-min=%s -arch %s "
                             "-I%s/usr/local/include"%(
                         recipe.get('extra_cflags', ''),
                         DEPTARGET,
                         ' -arch '.join(archList),
-                        shellQuote(SDKPATH)[1:-1],
                         shellQuote(basedir)[1:-1],),
-                "LDFLAGS=-mmacosx-version-min=%s -isysroot %s -L%s/usr/local/lib -arch %s"%(
+                "LDFLAGS=-mmacosx-version-min=%s -L%s/usr/local/lib -arch %s"%(
                     DEPTARGET,
-                    shellQuote(SDKPATH)[1:-1],
                     shellQuote(basedir)[1:-1],
                     ' -arch '.join(archList)),
             ])
         else:
             configure_args.extend([
-                "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
+                "CFLAGS=%s-mmacosx-version-min=%s -arch %s "
                             "-I%s/usr/local/include"%(
                         recipe.get('extra_cflags', ''),
                         DEPTARGET,
                         ' -arch '.join(archList),
-                        shellQuote(SDKPATH)[1:-1],
                         shellQuote(basedir)[1:-1],),
             ])
 
@@ -1107,7 +1049,7 @@ def buildLibraries():
 
 def buildPythonDocs():
     # This stores the documentation as Resources/English.lproj/Documentation
-    # inside the framwork. pydoc and IDLE will pick it up there.
+    # inside the framework. pydoc and IDLE will pick it up there.
     print("Install python documentation")
     rootDir = os.path.join(WORKDIR, '_root')
     buildDir = os.path.join('../../Doc')
@@ -1115,8 +1057,14 @@ def buildPythonDocs():
     curDir = os.getcwd()
     os.chdir(buildDir)
     runCommand('make clean')
-    # Assume sphinx-build is on our PATH, checked in checkEnvironment
-    runCommand('make html')
+    if PYTHON_2:
+        # Python 2 doc builds do not use blurb nor do they have a venv target.
+        # Assume sphinx-build is on our PATH, checked in checkEnvironment
+        runCommand('make html')
+    else:
+        # Create virtual environment for docs builds with blurb and sphinx
+        runCommand('make venv')
+        runCommand('make html PYTHON=venv/bin/python')
     os.chdir(curDir)
     if not os.path.exists(docdir):
         os.mkdir(docdir)
@@ -1139,10 +1087,6 @@ def buildPython():
     curdir = os.getcwd()
     os.chdir(buildDir)
 
-    # Not sure if this is still needed, the original build script
-    # claims that parts of the install assume python.exe exists.
-    os.symlink('python', os.path.join(buildDir, 'python.exe'))
-
     # Extract the version from the configure file, needed to calculate
     # several paths.
     version = getVersion()
@@ -1153,16 +1097,22 @@ def buildPython():
     os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR,
                                         'libraries', 'usr', 'local', 'lib')
     print("Running configure...")
-    runCommand("%s -C --enable-framework --enable-universalsdk=%s "
+    runCommand("%s -C --enable-framework --enable-universalsdk=/ "
                "--with-universal-archs=%s "
                "%s "
                "%s "
+               "%s "
+               "%s "
                "LDFLAGS='-g -L%s/libraries/usr/local/lib' "
                "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%(
-        shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH),
+        shellQuote(os.path.join(SRCDIR, 'configure')),
         UNIVERSALARCHS,
         (' ', '--with-computed-gotos ')[PYTHON_3],
         (' ', '--without-ensurepip ')[PYTHON_3],
+        (' ', "--with-tcltk-includes='-I%s/libraries/usr/local/include'"%(
+                            shellQuote(WORKDIR)[1:-1],))[internalTk()],
+        (' ', "--with-tcltk-libs='-L%s/libraries/usr/local/lib -ltcl8.6 -ltk8.6'"%(
+                            shellQuote(WORKDIR)[1:-1],))[internalTk()],
         shellQuote(WORKDIR)[1:-1],
         shellQuote(WORKDIR)[1:-1]))
 
@@ -1197,21 +1147,31 @@ def buildPython():
     del os.environ['DYLD_LIBRARY_PATH']
     print("Copying required shared libraries")
     if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
-        runCommand("mv %s/* %s"%(
-            shellQuote(os.path.join(
+        build_lib_dir = os.path.join(
                 WORKDIR, 'libraries', 'Library', 'Frameworks',
-                'Python.framework', 'Versions', getVersion(),
-                'lib')),
-            shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks',
-                'Python.framework', 'Versions', getVersion(),
-                'lib'))))
+                'Python.framework', 'Versions', getVersion(), 'lib')
+        fw_lib_dir = os.path.join(
+                WORKDIR, '_root', 'Library', 'Frameworks',
+                'Python.framework', 'Versions', getVersion(), 'lib')
+        if internalTk():
+            # move Tcl and Tk pkgconfig files
+            runCommand("mv %s/pkgconfig/* %s/pkgconfig"%(
+                        shellQuote(build_lib_dir),
+                        shellQuote(fw_lib_dir) ))
+            runCommand("rm -r %s/pkgconfig"%(
+                        shellQuote(build_lib_dir), ))
+        runCommand("mv %s/* %s"%(
+                    shellQuote(build_lib_dir),
+                    shellQuote(fw_lib_dir) ))
 
-    path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks',
-                                'Python.framework', 'Versions',
-                                version, 'lib', 'python%s'%(version,))
+    frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
+    frmDirVersioned = os.path.join(frmDir, 'Versions', version)
+    path_to_lib = os.path.join(frmDirVersioned, 'lib', 'python%s'%(version,))
+    # create directory for OpenSSL certificates
+    sslDir = os.path.join(frmDirVersioned, 'etc', 'openssl')
+    os.makedirs(sslDir)
 
     print("Fix file modes")
-    frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
     gid = grp.getgrnam('admin').gr_gid
 
     shared_lib_error = False
@@ -1261,6 +1221,8 @@ def buildPython():
         LDVERSION = LDVERSION.replace('$(VERSION)', VERSION)
         LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS)
         config_suffix = '-' + LDVERSION
+        if getVersionMajorMinor() >= (3, 6):
+            config_suffix = config_suffix + '-darwin'
     else:
         config_suffix = ''      # Python 2.x
 
@@ -1286,7 +1248,7 @@ def buildPython():
     fp.write(data)
     fp.close()
 
-    # fix _sysconfigdata if it exists
+    # fix _sysconfigdata
     #
     # TODO: make this more robust!  test_sysconfig_module of
     # distutils.tests.test_sysconfig.SysconfigTestCase tests that
@@ -1300,28 +1262,31 @@ def buildPython():
     # _sysconfigdata.py).
 
     import pprint
-    path = os.path.join(path_to_lib, '_sysconfigdata.py')
-    if os.path.exists(path):
-        fp = open(path, 'r')
-        data = fp.read()
-        fp.close()
-        # create build_time_vars dict
-        exec(data)
-        vars = {}
-        for k, v in build_time_vars.items():
-            if type(v) == type(''):
-                for p in (include_path, lib_path):
-                    v = v.replace(' ' + p, '')
-                    v = v.replace(p + ' ', '')
-            vars[k] = v
-
-        fp = open(path, 'w')
-        # duplicated from sysconfig._generate_posix_vars()
-        fp.write('# system configuration generated and used by'
-                    ' the sysconfig module\n')
-        fp.write('build_time_vars = ')
-        pprint.pprint(vars, stream=fp)
-        fp.close()
+    if getVersionMajorMinor() >= (3, 6):
+        # XXX this is extra-fragile
+        path = os.path.join(path_to_lib, '_sysconfigdata_m_darwin_darwin.py')
+    else:
+        path = os.path.join(path_to_lib, '_sysconfigdata.py')
+    fp = open(path, 'r')
+    data = fp.read()
+    fp.close()
+    # create build_time_vars dict
+    exec(data)
+    vars = {}
+    for k, v in build_time_vars.items():
+        if type(v) == type(''):
+            for p in (include_path, lib_path):
+                v = v.replace(' ' + p, '')
+                v = v.replace(p + ' ', '')
+        vars[k] = v
+
+    fp = open(path, 'w')
+    # duplicated from sysconfig._generate_posix_vars()
+    fp.write('# system configuration generated and used by'
+                ' the sysconfig module\n')
+    fp.write('build_time_vars = ')
+    pprint.pprint(vars, stream=fp)
+    fp.close()
 
     # Add symlinks in /usr/local/bin, using relative links
     usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin')
@@ -1648,6 +1613,8 @@ def main():
     patchFile("resources/ReadMe.rtf",  fn)
     fn = os.path.join(folder, "Update Shell Profile.command")
     patchScript("scripts/postflight.patch-profile",  fn)
+    fn = os.path.join(folder, "Install Certificates.command")
+    patchScript("resources/install_certificates.command",  fn)
     os.chmod(folder, STAT_0o755)
     setIcon(folder, "../Icons/Python Folder.icns")
 
diff --git a/Mac/BuildScript/issue19373_tk_8_5_15_source.patch b/Mac/BuildScript/issue19373_tk_8_5_15_source.patch
deleted file mode 100644 (file)
index de5d08e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Issue #19373: Patch to Tk 8.5.15 to correct refresh problem on OS x 10.9.
-From upstream checkin https://core.tcl.tk/tk/info/5a5abf71f9
-
---- tk8.5.15/macosx/tkMacOSXDraw.c     2013-09-16 09:41:21.000000000 -0700
-+++ Tk_Source_Code-5a5abf71f9fdb0da/macosx/tkMacOSXDraw.c      2013-10-27 13:27:00.000000000 -0700
-@@ -1688,6 +1688,7 @@
- {
-     if (dcPtr->context) {
-       CGContextSynchronize(dcPtr->context);
-+      [[dcPtr->view window] setViewsNeedDisplay:YES];
-       [[dcPtr->view window] enableFlushWindow];
-       if (dcPtr->focusLocked) {
-           [dcPtr->view unlockFocus];
diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch
deleted file mode 100644 (file)
index 0caac0a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# HG changeset patch
-#
-#      using openssl 1.0.2k
-#
-# - support building with an OS X SDK
-
-diff Configure
-
-diff --git a/Configure b/Configure
---- a/Configure
-+++ b/Configure
-@@ -642,12 +642,12 @@
- ##### MacOS X (a.k.a. Rhapsody or Darwin) setup
- "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
--"darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin-ppc-cc","cc:-arch ppc -isysroot \$(OSX_SDK) -O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin64-ppc-cc","cc:-arch ppc64 -isysroot \$(OSX_SDK) -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin-i386-cc","cc:-arch i386 -isysroot \$(OSX_SDK) -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"debug-darwin-i386-cc","cc:-arch i386 -isysroot \$(OSX_SDK) -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin64-x86_64-cc","cc:-arch x86_64 -isysroot \$(OSX_SDK) -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"debug-darwin64-x86_64-cc","cc:-arch x86_64 -isysroot \$(OSX_SDK) -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
- "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
- # iPhoneOS/iOS
- "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-@@ -1728,8 +1728,7 @@
-               s/^AR=\s*ar/AR= $ar/;
-               s/^RANLIB=.*/RANLIB= $ranlib/;
-               s/^RC=.*/RC= $windres/;
--              s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc";
--              s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
-+              s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/;
-               }
-       s/^CFLAG=.*$/CFLAG= $cflags/;
-       s/^DEPFLAG=.*$/DEPFLAG=$depflags/;
diff --git a/Mac/BuildScript/resources/Conclusion.rtf b/Mac/BuildScript/resources/Conclusion.rtf
new file mode 100644 (file)
index 0000000..9e0fa9f
--- /dev/null
@@ -0,0 +1,20 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 LucidaGrande-Bold;\f2\fnil\fcharset0 LucidaGrande;
+\f3\fnil\fcharset0 Monaco;}
+{\colortbl;\red255\green255\blue255;}
+{\*\expandedcolortbl;;}
+\margl1440\margr1440\vieww10540\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs28 \cf0 Congratulations!
+\fs24   
+\f1\b\fs28 Python $FULL_VERSION for macOS $MACOSX_DEPLOYMENT_TARGET
+\f2\b0  was successfully installed.
+\fs24 \
+\
+One more thing: to verify the identity of secure network connections, this Python needs a set of SSL root certificates.  You can download and install a current curated set from {\field{\*\fldinst{HYPERLINK "https://pypi.org/project/certifi/"}}{\fldrslt the Certifi project}} by double-clicking on the 
+\f3 Install Certificates
+\f2  icon in {\field{\*\fldinst{HYPERLINK "file://localhost/Applications/Python%20$VERSION/"}}{\fldrslt the Finder window}}.  See {\field{\*\fldinst{HYPERLINK "file://localhost/Applications/Python%20$VERSION/ReadMe.rtf"}}{\fldrslt the 
+\f3 ReadMe
+\f2  file}} for more information.\
+}
\ No newline at end of file
index 67c056ce64444f65d06592bb641854a727bb98ae..ebabb242241fe1d765793a2f9306d3048a5ceda7 100644 (file)
@@ -1,47 +1,78 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf750
+{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400
 {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
 {\colortbl;\red255\green255\blue255;}
 {\*\expandedcolortbl;;}
 \margl1440\margr1440\vieww15240\viewh15540\viewkind0
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\f0\fs24 \cf0 This package will install Python $FULL_VERSION for Mac OS X $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\
+\f0\fs24 \cf0 This package will install Python $FULL_VERSION for macOS $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\
 \
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\b \cf0 \ul \ulc0 Which installer variant should I use?
+\b \cf0 \ul \ulc0 Which installer variant should I use? [CHANGED in 2.7.15]
 \b0 \ulnone \
 \
-Python.org provides two installer variants for download: one that installs a 
-\i 64-bit/32-bit Intel
-\i0  Python capable of running on 
-\i Mac OS X 10.6 (Snow Leopard)
+
+\b **NEW**
+\b0  With Python 2.7.15, the python.org website now provides two installer variants for download: one that installs a 
+\i 64-bit-only 
+\i0 Python capable of running on 
+\i macOS 10.9 (Mavericks)
 \i0  or later; and one that installs a 
-\i 32-bit-only (Intel and PPC)
+\i 64-bit/32-bit Intel
 \i0  Python capable of running on 
-\i Mac OS X 10.5 (Leopard)
-\i0  or later.  This ReadMe was installed with the 
+\i macOS 10.6 (Snow Leopard)
+\i0  or later.  (This ReadMe was installed with the 
 \i $MACOSX_DEPLOYMENT_TARGET
-\i0  variant.  Unless you are installing to an 10.5 system or you need to build applications that can run on 10.5 systems, use the 10.6 variant if possible.  There are some additional operating system functions that are supported starting with 10.6 and you may see better performance using 64-bit mode.  By default, Python will automatically run in 64-bit mode if your system supports it.  Also see 
-\i Certificate verification and OpenSSL
-\i0  below.  The Pythons installed by these installers are built with private copies of some third-party libraries not included with or newer than those in OS X itself.  The list of these libraries varies by installer variant and is included at the end of the License.rtf file.
+\i0  variant.)  Previous Python 2.7.x releases provided the 10.6 or later installer and a 10.5 or later 32-bit-only variant. If you are running on macOS 10.9 or later and if you have no need for compatibility with older systems, use the 10.9 variant.  Use the 10.6 variant if you are running on macOS 10.6 through 10.8, if you need to maintain compatibility with previous 2.7.x releases, or if you want to produce standalone applications that can run on systems from 10.6.  The Pythons installed by these installers are built with private copies of some third-party libraries not included with or newer than those in macOS itself.  The list of these libraries varies by installer variant and is included at the end of the 
+\f1 License.rtf
+\f0  file.\
+
 \b \ul \
+Certificate verification and OpenSSL_[CHANGED in 2.7.15]\
+
+\b0 \ulnone \
+This variant of Python 2.7 now includes its own private copy of OpenSSL 1.0.2.  Unlike previous releases, the deprecated Apple-supplied OpenSSL libraries are no longer used.  This also means that the trust certificates in system and user keychains managed by the 
+\i Keychain Access 
+\i0 application and the 
+\i security
+\i0  command line utility are no longer used as defaults by the Python 
+\f1 ssl
+\f0  module.  A sample command script is included in 
+\f1 /Applications/Python 2.7
+\f0  to install a curated bundle of default root certificates from the third-party 
+\f1 certifi
+\f0  package ({\field{\*\fldinst{HYPERLINK "https://pypi.python.org/pypi/certifi"}}{\fldrslt https://pypi.python.org/pypi/certifi}}).  Click on 
+\f1 Install Certificates
+\f0  to run it.  If you choose to use 
+\f1 certifi
+\f0 , you should consider subscribing to the{\field{\*\fldinst{HYPERLINK "https://certifi.io/en/latest/"}}{\fldrslt  project's email update service}} to be notified when the certificate bundle is updated.\
+\
+The bundled 
+\f1 pip
+\f0  included with the Python 2.7 installer has its own default certificate store for verifying download connections.\
 \
-Update your version of Tcl/Tk to use IDLE or other Tk applications
+
+\b \ul Using IDLE or other Tk applications [NEW/CHANGED in 2.7.15] 
 \b0 \ulnone \
 \
-To use IDLE or other programs that use the Tkinter graphical user interface toolkit, you need to install a newer third-party version of the 
+The 10.9+ installer variant comes with its own private version of Tcl/Tk 8.6. It does not use system-supplied or third-party supplied versions of Tcl/Tk.\
+\
+For the 10.6+ variant, you continue to need to install a newer third-party version of the 
 \i Tcl/Tk
-\i0  frameworks.  Visit {\field{\*\fldinst{HYPERLINK "https://www.python.org/download/mac/tcltk/"}}{\fldrslt https://www.python.org/download/mac/tcltk/}} for current information about supported and recommended versions of 
+\i0  8.5 (not 8.6) frameworks to use IDLE or other programs that use the Tkinter graphical user interface toolkit.  Visit {\field{\*\fldinst{HYPERLINK "https://www.python.org/download/mac/tcltk/"}}{\fldrslt https://www.python.org/download/mac/tcltk/}} for current information about supported and recommended versions of 
 \i Tcl/Tk
-\i0  for this version of Python and of Mac OS X.\
+\i0  for this version of Python and of macOS.\
 
 \b \ul \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 Packages installed with the system Python 2.7 are no longer searched for\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [CHANGED for Python 2.7.13]
-\b0 \
+Binary installer support for Mac OS X 10.5 and earlier discontinued [CHANGED for Python 2.7.15]
+\b0 \ulnone \
+\
+As of Python 2.7.15, binary installers from python.org no longer support Mac OS X 10.5 (Leopard) systems.   Binary installer support for Mac OS X 10.3.9 (Panther) and 10.4.x (Tiger) systems was previously dropped in Python 2.7.9.  Mac OS X 10.5 was originally released by Apple in 2007 and last updated in 2009 and was the last OS X release for PPC machines (G4 and G5).  If needed, it is still possible to build Python from source for 10.3.9, 10.4, or 10.5.\
+\
+
+\b \ul Packages installed with the system Python 2.7 are no longer searched for [CHANGED for Python 2.7.13]
+\b0 \ulnone \
 \
 As of Python 2.7.0, user-installed Python 2.7 versions from python.org installers added the system-wide site-packages directory for the Apple-supplied Python 2.7 to the end of their search path.  This meant that packages installed with the system Python 2.7 could also be used by the user-installed Python 2.7.  While sometimes convenient, this also often caused confusion with the implicit coupling between the two Python instances.  Separately, as of macOS 10.12, Apple changed the layout of the system site-packages directory, 
 \f1 /Library/Python/2.7/site-packages
@@ -53,36 +84,27 @@ As of Python 2.7.0, user-installed Python 2.7 versions from python.org installer
 \f1 sys.path
 \f0 .  If you are using a package with both a user-installed Python 2.7 and the system Python 2.7, you will now need to ensure that separate copies of the package are installed for each instance.\
 \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\b \cf0 \ul Installing on OS X 10.8 (Mountain Lion) or later systems\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [CHANGED for Python 2.7.9]
-\b0 \
+\b \ul Installing on OS X 10.8 (Mountain Lion) or later systems [CHANGED for Python 2.7.9]
+\b0 \ulnone \
 \
-As of Python 2.7.9, installer packages from python.org are now compatible with the Gatekeeper security feature introduced in OS X 10.8.   Downloaded packages can now be directly installed by double-clicking with the default system security settings.  Python.org installer packages for OS X are signed with the Developer ID of the builder, as identified on {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt the download page}} for this release.  To inspect the digital signature of the package, click on the lock icon in the upper right corner of the 
+As of Python 2.7.9, installer packages from python.org are now compatible with the Gatekeeper security feature introduced in OS X 10.8.   Downloaded packages can now be directly installed by double-clicking with the default system security settings.  Python.org installer packages for macOS are signed with the Developer ID of the builder, as identified on {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt the download page}} for this release.  To inspect the digital signature of the package, click on the lock icon in the upper right corner of the 
 \i Install Python
 \i0  installer window.  Refer to Apple\'92s support pages for {\field{\*\fldinst{HYPERLINK "http://support.apple.com/kb/ht5290"}}{\fldrslt more information on Gatekeeper}}.\
 \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\b \cf0 \ul Simplified web-based installs\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [NEW for Python 2.7.9]
-\b0 \
+\b \ul Simplified web-based installs [NEW for Python 2.7.9]
+\b0 \ulnone \
 \
 With the change to the newer flat format installer package, the download file now has a 
 \f1 .pkg
 \f0  extension as it is no longer necessary to embed the installer within a disk image (
 \f1 .dmg
-\f0 ) container.   If you download the Python installer through a web browser, the OS X installer application may open automatically to allow you to perform the install.  If your browser settings do not allow automatic open, double click on the downloaded installer file.\
+\f0 ) container.   If you download the Python installer through a web browser, the macOS installer application may open automatically to allow you to perform the install.  If your browser settings do not allow automatic open, double click on the downloaded installer file.\
 \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\b \cf0 \ul New Installation Options and Defaults\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [NEW for Python 2.7.9]
-\b0 \
+\b \ul New Installation Options and Defaults [NEW for Python 2.7.9]
+\b0 \ulnone \
 \
 The Python installer now includes an option to automatically install or upgrade 
 \f1 pip
@@ -96,74 +118,8 @@ The Python installer now includes an option to automatically install or upgrade
 \i Release Notes
 \i0  link for this release at {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt https://www.python.org/downloads/}}.\
 \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
-\b \cf0 \ul Certificate verification and OpenSSL\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [CHANGED for Python 2.7.9]
-\b0 \
-\
-Python 2.7.9 includes a number of network security enhancements that have been approved for inclusion in Python 2.7 maintenance releases.  {\field{\*\fldinst{HYPERLINK "https://www.python.org/dev/peps/pep-0476/"}}{\fldrslt PEP 476}} changes several standard library modules, like 
-\i httplib
-\i0 , 
-\i urllib2
-\i0 , and 
-\i xmlrpclib
-\i0 , to by default verify certificates presented by servers over secure (TLS) connections.  The verification is performed by the OpenSSL libraries that Python is linked to.  Prior to 2.7.9, the python.org installers dynamically linked with Apple-supplied OpenSSL libraries shipped with OS X.  OS X provides a multiple level security framework that stores trust certificates in system and user keychains managed by the 
-\i Keychain Access 
-\i0 application and the 
-\i security
-\i0  command line utility.\
-\
-For OS X 10.5, Apple provides 
-\i OpenSSL 0.9.7
-\i0  libraries.  This version of Apple's OpenSSL 
-\b does not
-\b0  use the certificates from the system security framework, even when used on newer versions of OS X.  Instead it consults a traditional OpenSSL concatenated certificate file (
-\i cafile
-\i0 ) or certificate directory (
-\i capath
-\i0 ), located in 
-\f1 /System/Library/OpenSSL
-\f0 .  These directories are typically empty and not managed by OS X; you must manage them yourself or supply your own SSL contexts.  OpenSSL 0.9.7 is obsolete by current security standards, lacking a number of important features found in later versions.  Among the problems this causes is the inability to verify higher-security certificates now used by python.org services, including 
-\i t{\field{\*\fldinst{HYPERLINK "https://pypi.python.org/pypi"}}{\fldrslt he Python Package Index, PyPI}}
-\i0 .  To solve this problem, as of 2.7.9 the 
-\i 10.5+ 32-bit-only python.org variant
-\i0  is linked with a private copy of 
-\i OpenSSL 1.0
-\i0 ; it consults the same default certificate directory, 
-\f1 /System/Library/OpenSSL
-\f0 .   As before, it is still necessary to manage certificates yourself when you use this Python variant and, with certificate verification now enabled by default, you may now need to take additional steps to ensure your Python programs have access to CA certificates you trust.  If you use this Python variant to build standalone applications with third-party tools like {\field{\*\fldinst{HYPERLINK "https://pypi.python.org/pypi/py2app/"}}{\fldrslt 
-\f1 py2app}}, you may now need to bundle CA certificates in them or otherwise supply non-default SSL contexts.\
-\
-For OS X 10.6+, Apple also provides 
-\i OpenSSL
-\i0  
-\i 0.9.8 libraries
-\i0 .  Apple's 0.9.8 version includes an important additional feature: if a certificate cannot be verified using the manually administered certificates in 
-\f1 /System/Library/OpenSSL
-\f0 , the certificates managed by the system security framework In the user and system keychains are also consulted (using Apple private APIs).  For this reason, for 2.7.9 the 
-\i 64-bit/32-bit 10.6+ python.org variant
-\i0  continues to be dynamically linked with Apple's OpenSSL 0.9.8 since it was felt that the loss of the system-provided certificates and management tools outweighs the additional security features provided by newer versions of OpenSSL.  This will likely change in future releases of the python.org installers as Apple has deprecated use of the system-supplied OpenSSL libraries.  If you do need features from newer versions of OpenSSL, there are third-party OpenSSL wrapper packages available through 
-\i PyPI
-\i0 .\
-\
-The bundled 
-\f1 pip
-\f0  included with 2.7.9 has its own default certificate store for verifying download connections.\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-
-\b \cf0 \ul \
-Binary installer support for OS X 10.4 and 10.3.9 discontinued\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-\cf0 \ulnone [CHANGED for Python 2.7.9]
-\b0 \
-\
-As previously announced, binary installers for Python 2.7.9 from python.org no longer support Mac OS X 10.3.9 (Panther) and 10.4.x (Tiger) systems.  These systems were last updated by Apple in 2005 and 2007.  As of 2.7.9, the 32-bit-only installer supports PPC and Intel Macs running OS X 10.5 (Leopard).  10.5 was the last OS X release for PPC machines (G4 and G5).  The 64-/32-bit installer configuration remains unchanged and should normally be used on OS X 10.6 (Snow Leopard) and later systems.  This aligns Python 2.7.x installer configurations with those currently provided with Python 3.x.  If needed, it is still possible to build Python from source for 10.3.9 and 10.4.\
-\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
-
-\b \cf0 \ul Python 3 and Python 2 Co-existence\
+\b \ul Python 3 and Python 2 Co-existence\
 
 \b0 \ulnone \
 Python.org Python 2.7 and 3.x versions can both be installed on your system and will not conflict.  Python 2.7 command names contain a 2 or no digit: 
@@ -190,6 +146,9 @@ Python.org Python 2.7 and 3.x versions can both be installed on your system and
 \f1 idle3
 \f0 , 
 \f1 pip3
-\f0 , etc.\
+\f0 , etc.  Also, installing a python.org Python 2.7 does not alter or remove any Apple-supplied system Pythons, found in 
+\f1 /usr/bin
+\f0 .\
+\
 \
 }
\ No newline at end of file
index ea15e0b5ea7659b5f4fa97f79f0fd79b3e231deb..fcf9e042dc360fc3b05806e354366b06e89f7c2a 100644 (file)
@@ -1,37 +1,28 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf160
+{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400
 \cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
 {\colortbl;\red255\green255\blue255;}
-\paperw11905\paperh16837\margl1440\margr1440\vieww11180\viewh10860\viewkind0
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
+{\*\expandedcolortbl;;}
+\paperw11905\paperh16837\margl1440\margr1440\vieww13360\viewh10920\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
 
 \f0\fs24 \cf0 This package will install 
 \b Python $FULL_VERSION
 \b0  for 
-\b Mac OS X $MACOSX_DEPLOYMENT_TARGET
+\b macOS $MACOSX_DEPLOYMENT_TARGET
 \b0 .\
-\
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\partightenfactor0
+\cf0 \
 
-\b Python for Mac OS X
-\b0  consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac OS X users including an integrated development environment 
+\b Python for macOS
+\b0  consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for macOS users including an integrated development environment 
 \b IDLE
 \b0 .\
 \
 
-\b NEW for Python 2.7.9: 
-\b0 This package installs a version of 
-\f1 pip
-\f0 , the recommended tool for installing and managing Python packages.   Type 
-\f1 pip2.7 --help
-\f0  for an overview.  2.7.9 also includes a number of network security enhancements that may require changes to your Python applications.  See the 
-\f1 ReadMe
-\f0  file and {\field{\*\fldinst{HYPERLINK "https://docs.python.org/2/whatsnew/2.7.html#new-features-added-to-python-2-7-maintenance-releases"}}{\fldrslt the Python documentation}} for more information.\
-\
-
-\b IMPORTANT:
-\b0  
-\b IDLE
-\b0  and other programs using the 
-\b tkinter
-\b0  graphical user interface toolkit require specific versions of the 
-\b Tcl/Tk
-\b0  platform independent windowing toolkit.  Visit {\field{\*\fldinst{HYPERLINK "https://www.python.org/download/mac/tcltk/"}}{\fldrslt https://www.python.org/download/mac/tcltk/}} for current information on supported and recommended versions of Tcl/Tk for this version of Python and Mac OS X.}
\ No newline at end of file
+\b NEW in 2.7.15: 
+\b0 two installer variants (10.9+ 64-bit-only, 10.6+ 64-/32-bit), built-in Tcl/Tk 8.6 support in the 10.9+ variant (no additional third-party downloads!), updated  
+\f1 pip,
+\f0  built-in OpenSSL 1.0.2 (click on 
+\f1 Install Certificates
+\f0  for root certificates)\
+}
\ No newline at end of file
diff --git a/Mac/BuildScript/resources/install_certificates.command b/Mac/BuildScript/resources/install_certificates.command
new file mode 100755 (executable)
index 0000000..6cae65c
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+/Library/Frameworks/Python.framework/Versions/@PYVER@/bin/python@PYVER@ << "EOF"
+
+# install_certifi.py
+#
+# sample script to install or update a set of default Root Certificates
+# for the ssl module.  Uses the certificates provided by the certifi package:
+#       https://pypi.python.org/pypi/certifi
+
+import os
+import os.path
+import ssl
+import stat
+import subprocess
+import sys
+
+STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
+             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
+             | stat.S_IROTH |                stat.S_IXOTH )
+
+def main():
+    openssl_dir, openssl_cafile = os.path.split(
+        ssl.get_default_verify_paths().openssl_cafile)
+
+    print(" -- pip install --upgrade certifi")
+    subprocess.check_call([sys.executable,
+        "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
+
+    import certifi
+
+    # change working directory to the default SSL directory
+    os.chdir(openssl_dir)
+    relpath_to_certifi_cafile = os.path.relpath(certifi.where())
+    print(" -- removing any existing file or link")
+    try:
+        os.remove(openssl_cafile)
+    except OSError:
+        pass
+    print(" -- creating symlink to certifi certificate bundle")
+    os.symlink(relpath_to_certifi_cafile, openssl_cafile)
+    print(" -- setting permissions")
+    os.chmod(openssl_cafile, STAT_0o775)
+    print(" -- update complete")
+
+if __name__ == '__main__':
+    main()
+EOF
index b9f28a5152156bf3814d9283f4c393548ada1030..3cbbc1bf10ca2a5af343fd62be3987a4aef95d39 100755 (executable)
@@ -12,6 +12,7 @@ SHARE_DOCDIR_TO_FWK="../../.."
 # make link in /Applications/Python m.n/ for Finder users
 if [ -d "${APPDIR}" ]; then
     ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html"
+    open "${APPDIR}" || true  # open the applications folder
 fi
 
 # make share/doc link in framework for command line users
diff --git a/Mac/BuildScript/tk868_on_10_8_10_9.patch b/Mac/BuildScript/tk868_on_10_8_10_9.patch
new file mode 100644 (file)
index 0000000..8fe1060
--- /dev/null
@@ -0,0 +1,18 @@
+Fix build failure with +quartz variant on OS X 10.8 and 10.9.
+Even though Gestalt was deprecated in OS X 10.8, it should work fine
+through OS X 10.9, and its replacement NSOperatingSystemVersion was
+not introduced until OS X 10.10.
+
+Patch from MacPorts project and reported upstream:
+https://trac.macports.org/ticket/55649
+--- tk8.6.8/macosx/tkMacOSXXStubs.c.orig       2017-12-06 09:25:08.000000000 -0600
++++ tk8.6.8-patched/macosx/tkMacOSXXStubs.c    2018-01-06 19:34:17.000000000 -0600
+@@ -175,7 +175,7 @@
+     {
+       int major, minor, patch;
+-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
++#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+       Gestalt(gestaltSystemVersionMajor, (SInt32*)&major);
+       Gestalt(gestaltSystemVersionMinor, (SInt32*)&minor);
+       Gestalt(gestaltSystemVersionBugFix, (SInt32*)&patch);
index 98590ab0029ac397ba003193d11e072ee90d9f21..2be3a3758dbe6499c331e8a8243323ddef47f830 100644 (file)
@@ -11,7 +11,6 @@ LIBDEST=$(prefix)/lib/python$(VERSION)
 UNIVERSALSDK=@UNIVERSALSDK@
 builddir=      ../..
 PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
-LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
 
 
 RUNSHARED=      @RUNSHARED@
@@ -71,10 +70,6 @@ IDLE.app:  \
                --resource=$(srcdir)/../Icons/PythonCompiled.icns \
                --python=$(prefix)/Resources/Python.app/Contents/MacOS/Python \
                build
-ifneq ($(LIPO_32BIT_FLAGS),)
-       rm "IDLE.app/Contents/MacOS/Python"
-       lipo $(LIPO_32BIT_FLAGS) -output "IDLE.app/Contents/MacOS/Python" "$(BUILDPYTHON)"
-endif
 
 Info.plist: $(srcdir)/Info.plist.in
        sed 's/%VERSION%/'"`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(srcdir)/Info.plist.in > Info.plist
index 1a8e2b44553d5f241431aa3e9c49f87c79d0358c..b84fffeec64a7daeb76f51c352112c71b5e32ef5 100644 (file)
@@ -40,7 +40,7 @@
        <key>CFBundleExecutable</key>
        <string>PythonLauncher</string>
        <key>CFBundleGetInfoString</key>
-       <string>%VERSION%, © 2001-2017 Python Software Foundation</string>
+       <string>%VERSION%, © 2001-2018 Python Software Foundation</string>
        <key>CFBundleIconFile</key>
        <string>PythonLauncher.icns</string>
        <key>CFBundleIdentifier</key>
index ec2cd2743ecefa6cf3e2180a2790c0a08a2c0658..51e69ef6e86a37c5f46ede42e6df442262ee124f 100644 (file)
@@ -7,7 +7,7 @@ Python on Mac OS X README
     Ronald Oussoren (2010-04),
     Ned Deily (2014-05)
 
-:Version: 2.7.7
+:Version: 2.7.15
 
 This document provides a quick overview of some Mac OS X specific features in
 the Python distribution.
@@ -19,7 +19,7 @@ OS X specific arguments to configure
 
   If this argument is specified the build will create a Python.framework rather
   than a traditional Unix install. See the section
-  _`Building and using a framework-based Python on Mac OS X` for more 
+  _`Building and using a framework-based Python on Mac OS X` for more
   information on frameworks.
 
   If the optional directory argument is specified the framework is installed
@@ -44,10 +44,12 @@ OS X specific arguments to configure
   regular and framework builds.
 
   The optional argument specifies which OS X SDK should be used to perform the
-  build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``.  When building
-  on OS X 10.5 or later, you can specify ``/`` to use the installed system
-  headers rather than an SDK.  As of OS X 10.9, you should install the optional
-  system headers from the Command Line Tools component using ``xcode-select``::
+  build.  If xcodebuild is available and configured, this defaults to
+  the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk``
+  if available or ``/`` if not.  When building on OS X 10.5 or later, you can
+  specify ``/`` to use the installed system headers rather than an SDK.  As of
+  OS X 10.9, you should install the optional system headers from the Command
+  Line Tools component using ``xcode-select``::
 
      $ sudo xcode-select --install
 
@@ -56,10 +58,11 @@ OS X specific arguments to configure
 
 * ``--with-universal-archs=VALUE``
 
-  Specify the kind of universal binary that should be created. This option is 
-  only valid when ``--enable-universalsdk`` is specified.
+  Specify the kind of universal binary that should be created. This option is
+  only valid when ``--enable-universalsdk`` is specified.  The default is
+  ``32-bit`` if a building with a SDK that supports PPC, otherwise defaults
+  to ``intel``.
 
-  
 
 Building and using a universal binary of Python on Mac OS X
 ===========================================================
@@ -91,30 +94,30 @@ unix build. Universal builds were first supported with OS X 10.4 with Xcode 2.1
 and the 10.4u SDK.  Starting with Xcode 3 and OS X 10.5, more configurations are
 available.
 
-The option ``--enable-universalsdk`` has an optional argument to specify an
-SDK, which defaults to the 10.4u SDK. When you build on OS X 10.5 or later
-you can use the system headers instead of an SDK::
-
-  $ ./configure --enable-universalsdk=/
-
 In general, universal builds depend on specific features provided by the
 Apple-supplied compilers and other build tools included in Apple's Xcode
 development tools.  You should install Xcode and the command line tools
 component appropriate for the OS X release you are running on.  See the
-Python Developer's Guide (http://docs.python.org/devguide/setup.html)
+Python Developer's Guide (https://devguide.python.org/setup/)
 for more information.
 
 2.1 Flavors of universal binaries
 .................................
 
 It is possible to build a number of flavors of the universal binary build,
-the default is a 32-bit only binary (i386 and ppc). Note that starting with
-Xcode 4, the build tools no longer support ppc. The flavor can be
-specified using the option ``--with-universal-archs=VALUE``. The following
+the default is a 32-bit only binary (i386 and ppc) in build environments that
+support ppc (10.4 with Xcode 2, 10.5 and 10.6 with Xcode 3) or an
+Intel-32/-64-bit binary (i386 and X86_64) in build environments that do not
+support ppc (Xcode 4 on 10.6 and later systems).  The flavor can be specified
+using the configure option ``--with-universal-archs=VALUE``. The following
 values are available:
 
   * ``intel``:   ``i386``, ``x86_64``
 
+  * ``intel-32``: ``i386``
+
+  * ``intel-64``: ``x86_64``
+
   * ``32-bit``:   ``ppc``, ``i386``
 
   * ``3-way``:   ``i386``, ``x86_64``, ``ppc``
@@ -178,14 +181,14 @@ Building and using a framework-based Python on Mac OS X.
 --------------------------------------------------------------------------
 
 The main reason is because you want to create GUI programs in Python. With the
-exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run 
+exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
 from a Mac OS X application bundle (".app").
 
 While it is technically possible to create a .app without using frameworks you
 will have to do the work yourself if you really want this.
 
 A second reason for using frameworks is that they put Python-related items in
-only two places: "/Library/Framework/Python.framework" and 
+only two places: "/Library/Framework/Python.framework" and
 "/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.4",
 "2.7", etc.  This simplifies matters for users installing
 Python from a binary distribution if they want to get rid of it again. Moreover,
@@ -222,7 +225,7 @@ If you want Cocoa you need to get PyObjC.
 This directory contains a Makefile that will create a couple of python-related
 applications (full-blown OS X .app applications, that is) in
 "/Applications/Python <VERSION>", and a hidden helper application Python.app
-inside the Python.framework, and unix tools "python" and "pythonw" into
+inside the Python.framework, and unix tools including "python" into
 /usr/local/bin.  In addition it has a target "installmacsubtree" that installs
 the relevant portions of the Mac subtree into the Python.framework.
 
@@ -232,11 +235,11 @@ in the sequence
  1. ./configure --enable-framework
 
  2. make
+
  3. make install
 
 This sequence will put the framework in ``/Library/Framework/Python.framework``,
-the applications in ``/Applications/Python <VERSION>`` and the unix tools in 
+the applications in ``/Applications/Python <VERSION>`` and the unix tools in
 ``/usr/local/bin``.
 
 Installing in another place, for instance ``$HOME/Library/Frameworks`` if you
@@ -313,7 +316,7 @@ All of this is normally done completely isolated in /tmp/_py, so it does not
 use your normal build directory nor does it install into /.
 
 Because of the way the script locates the files it needs you have to run it
-from within the BuildScript directory. The script accepts a number of 
+from within the BuildScript directory. The script accepts a number of
 command-line arguments, run it with --help for more information.
 
 Configure warnings
@@ -363,4 +366,4 @@ Resources
 
   *  http://www.python.org/community/sigs/current/pythonmac-sig/
 
-  *  http://docs.python.org/devguide/
+  *  https://devguide.python.org/
index a23166e6d32d87e1b0057e5107733408f2e7bd82..abe9ae23e341a766eb60a23f10c102781540534e 100644 (file)
@@ -37,7 +37,7 @@
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleLongVersionString</key>
-       <string>%version%, (c) 2001-2017 Python Software Foundation.</string>
+       <string>%version%, (c) 2001-2018 Python Software Foundation.</string>
        <key>CFBundleName</key>
        <string>Python</string>
        <key>CFBundlePackageType</key>
index 7a64619e295f65b24a46c6a5894fe71e46b4444e..c1ea9f6889209b416fa552816832a5b1b668c72f 100644 (file)
@@ -17,9 +17,9 @@
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
        <key>CFBundleShortVersionString</key>
-       <string>%VERSION%, (c) 2001-2017 Python Software Foundation.</string>
+       <string>%VERSION%, (c) 2001-2018 Python Software Foundation.</string>
        <key>CFBundleLongVersionString</key>
-       <string>%VERSION%, (c) 2001-2017 Python Software Foundation.</string>
+       <string>%VERSION%, (c) 2001-2018 Python Software Foundation.</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 54e9480e215d2edeb450a6b7201b415dd8c37188..9297e7fc89c4ad7359b99682c71e0ff7498e1b78 100644 (file)
@@ -401,7 +401,16 @@ LIBRARY_OBJS=      \
 
 # Default target
 all:           @DEF_MAKE_ALL_RULE@
-build_all:     $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
+build_all:     check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
+
+# Check that the source is clean when building out of source.
+check-clean-src:
+       @if test -n "$(VPATH)" -a -f "$(srcdir)/Modules/python.o"; then \
+               echo "Error: The source directory ($(srcdir)) is not clean" ; \
+               echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
+               echo "Try to run: make -C \"$(srcdir)\" clean" ; \
+               exit 1; \
+       fi
 
 # Compile a binary with profile guided optimization.
 profile-opt:
@@ -428,7 +437,7 @@ build_all_generate_profile:
 
 run_profile_task:
        : # FIXME: can't run for a cross build
-       $(LLVM_PROF_FILE) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
+       $(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
 
 build_all_merge_profile:
        $(LLVM_PROF_MERGER)
@@ -898,6 +907,14 @@ memtest:   @DEF_MAKE_RULE@ platform
                -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
                $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
 
+# SSL tests
+.PHONY: multisslcompile multissltest
+multisslcompile: build_all
+       $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py --compile-only
+
+multissltest: build_all
+       $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py
+
 # Install everything
 install:       @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@
        if test "x$(ENSUREPIP)" != "xno"  ; then \
@@ -920,7 +937,7 @@ altinstall: commoninstall
                        $$ensurepip --root=$(DESTDIR)/ ; \
        fi
 
-commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
+commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
                altbininstall libinstall inclinstall libainstall \
                sharedinstall oldsharedinstall altmaninstall \
                @FRAMEWORKALTINSTALLLAST@
@@ -1361,10 +1378,9 @@ autoconf:
 
 # Create a tags file for vi
 tags::
-       cd $(srcdir); \
-       ctags -w Include/*.h; \
-       for i in $(SRCDIRS); do ctags -f tags -w -a $$i/*.[ch]; \
-       done; \
+       ctags -w $(srcdir)/Include/*.h
+       for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done
+       ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch]
        LC_ALL=C sort -o tags tags
 
 # Create a tags file for GNU Emacs
@@ -1464,7 +1480,7 @@ patchcheck:
 Python/thread.o: @THREADHEADERS@
 
 # Declare targets that aren't real files
-.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
+.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest memtest
 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
index 229a874ffc2bcbd36785609c35e4bce20af2a8ad..28255740c7f0bcdc078a8e696fcfd8a84c03a6b4 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -262,6 +262,7 @@ Brad Clements
 Robbie Clemons
 Steve Clift
 Hervé Coatanhay
+Riccardo Coccioli
 Nick Coghlan
 Josh Cogliati
 Dave Cole
@@ -316,6 +317,9 @@ Kushal Das
 Jonathan Dasteel
 Pierre-Yves David
 A. Jesse Jiryu Davis
+Jake Davis
+Jamie (James C.) Davis
+Ratnadeep Debnath
 Merlijn van Deen
 John DeGood
 Ned Deily
@@ -323,6 +327,7 @@ Vincent Delft
 Arnaud Delobelle
 Konrad Delong
 Erik Demaine
+Jeroen Demeyer
 Martin Dengler
 John Dennis
 L. Peter Deutsch
@@ -762,6 +767,7 @@ Jerzy Kozera
 Maksim Kozyarchuk
 Stefan Krah
 Bob Kras
+Oleg Krasnikov
 Sebastian Kreft
 Holger Krekel
 Michael Kremer
@@ -771,6 +777,7 @@ Pedro Kroger
 Hannu Krosing
 Andrej Krpic
 Ivan Krstić
+Anselm Kruis
 Steven Kryskalla
 Andrew Kuchling
 Dave Kuhlman
@@ -1229,6 +1236,7 @@ James Rutherford
 Chris Ryland
 Constantina S.
 Matthieu S
+Cheryl Sabella
 Patrick Sabin
 Sébastien Sablé
 Suman Saha
@@ -1341,6 +1349,7 @@ Nicholas Spies
 Per Spilling
 Joshua Spoerri
 Noah Spurrier
+Zackery Spytz
 Nathan Srebro
 RajGopal Srinivasan
 Tage Stabell-Kulo
index b5d5dd945f1cdd1a6e10a752e42276ca98d85d09..a3abb9aa9594ea571c710e4f9406db05fc074171 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
 Python News
 +++++++++++
 
-What's New in Python 2.7.14?
-============================
+What's New in Python 2.7.15 final?
+==================================
 
-*Release date: 2017-09-16*
+*Release date: 2018-04-29*
 
-Extension Modules
+Core and Builtins
 -----------------
 
-- bpo-31170: Update vendorized expat to 2.2.4.
+- bpo-33374: Tweak the definition of PyGC_Head, so compilers do not believe
+  it is always 16-byte aligned on x86. This prevents crashes with more
+  aggressive optimizations present in GCC 8.
 
 
-What's New in Python 2.7.14 release candidate 1?
+What's New in Python 2.7.15 release candidate 1?
 ================================================
 
-*Release date: 2017-08-26*
+*Release date: 2018-04-14*
+
+Security
+--------
+
+- bpo-32997: A regex in fpformat was vulnerable to catastrophic
+  backtracking. This regex was a potential DOS vector (REDOS). Based on
+  typical uses of fpformat the risk seems low. The regex has been refactored
+  and is now safe. Patch by Jamie Davis.
+
+- bpo-32981: Regexes in difflib and poplib were vulnerable to catastrophic
+  backtracking. These regexes formed potential DOS vectors (REDOS). They
+  have been refactored. This resolves CVE-2018-1060 and CVE-2018-1061. Patch
+  by Jamie Davis.
+
+- bpo-31339: Rewrite time.asctime() and time.ctime(). Backport and adapt the
+  _asctime() function from the master branch to not depend on the
+  implementation of asctime() and ctime() from the external C library. This
+  change fixes a bug when Python is run using the musl C library.
+
+- bpo-30730: Prevent environment variables injection in subprocess on
+  Windows.  Prevent passing other environment variables and command
+  arguments.
+
+- bpo-30694: Upgrade expat copy from 2.2.0 to 2.2.1 to get fixes of multiple
+  security vulnerabilities including: CVE-2017-9233 (External entity
+  infinite loop DoS), CVE-2016-9063 (Integer overflow, re-fix),
+  CVE-2016-0718 (Fix regression bugs from 2.2.0's fix to CVE-2016-0718) and
+  CVE-2012-0876 (Counter hash flooding with SipHash). Note: the
+  CVE-2016-5300 (Use os- specific entropy sources like getrandom) doesn't
+  impact Python, since Python already gets entropy from the OS to set the
+  expat secret using ``XML_SetHashSalt()``.
+
+- bpo-30500: Fix urllib.splithost() to correctly parse fragments. For
+  example, ``splithost('//127.0.0.1#@evil.com/')`` now correctly returns the
+  ``127.0.0.1`` host, instead of treating ``@evil.com`` as the host in an
+  authentification (``login@host``).
+
+- bpo-29591: Update expat copy from 2.1.1 to 2.2.0 to get fixes of
+  CVE-2016-0718 and CVE-2016-4472. See
+  https://sourceforge.net/p/expat/bugs/537/ for more information.
 
 Core and Builtins
 -----------------
 
-- bpo-30657: Fixed possible integer overflow in PyString_DecodeEscape.
-  Patch by Jay Bosamiya.
+- bpo-33026: Fixed jumping out of "with" block by setting f_lineno.
+
+- bpo-17288: Prevent jumps from 'return' and 'exception' trace events.
+
+- bpo-18533: ``repr()`` on a dict containing its own ``viewvalues()`` or
+  ``viewitems()`` no longer raises ``RuntimeError``.  Instead, use ``...``,
+  as for other recursive structures.  Patch by Ben North.
+
+- bpo-10544: Yield expressions are now deprecated in comprehensions and
+  generator expressions when checking Python 3 compatibility. They are still
+  permitted in the definition of the outermost iterable, as that is
+  evaluated directly in the enclosing scope.
+
+- bpo-32137: The repr of deeply nested dict now raises a RecursionError
+  instead of crashing due to a stack overflow.
+
+- bpo-20047: Bytearray methods partition() and rpartition() now accept only
+  bytes-like objects as separator, as documented.  In particular they now
+  raise TypeError rather of returning a bogus result when an integer is
+  passed as a separator.
+
+- bpo-31733: Add a new PYTHONSHOWREFCOUNT environment variable. In debug
+  mode, Python now only print the total reference count if
+  PYTHONSHOWREFCOUNT is set.
+
+- bpo-31692: Add a new PYTHONSHOWALLOCCOUNT environment variable. When
+  Python is compiled with COUNT_ALLOCS, PYTHONSHOWALLOCCOUNT now has to be
+  set to dump allocation counts into stderr on shutdown. Moreover,
+  allocations statistics are now dumped into stderr rather than stdout.
+
+- bpo-31478: Prevent unwanted behavior in `_random.Random.seed()` in case
+  the argument has a bad ``__abs__()`` method. Patch by Oren Milman.
+
+- bpo-31530: Fixed crashes when iterating over a file on multiple threads.
+
+- bpo-31490: Fix an assertion failure in `ctypes` class definition, in case
+  the class has an attribute whose name is specified in ``_anonymous_`` but
+  not in ``_fields_``. Patch by Oren Milman.
+
+- bpo-31411: Raise a TypeError instead of SystemError in case
+  warnings.onceregistry is not a dictionary. Patch by Oren Milman.
+
+- bpo-31343: Include sys/sysmacros.h for major(), minor(), and makedev().
+  GNU C libray plans to remove the functions from sys/types.h.
+
+- bpo-31311: Fix a crash in the ``__setstate__()`` method of
+  `ctypes._CData`, in case of a bad ``__dict__``. Patch by Oren Milman.
+
+- bpo-31243: Fix a crash in some methods of `io.TextIOWrapper`, when the
+  decoder's state is invalid. Patch by Oren Milman.
+
+- bpo-31095: Fix potential crash during GC caused by ``tp_dealloc`` which
+  doesn't call ``PyObject_GC_UnTrack()``.
+
+- bpo-30657: Fixed possible integer overflow in PyString_DecodeEscape. Patch
+  by Jay Bosamiya.
 
 - bpo-27945: Fixed various segfaults with dict when input collections are
   mutated during searching, inserting or comparing.  Based on patches by
   Duane Griffin and Tim Mitchell.
 
-- bpo-25794: Fixed type.__setattr__() and type.__delattr__() for
-  non-interned or unicode attribute names.  Based on patch by Eryk Sun.
+- bpo-25794: Fixed type.__setattr__() and type.__delattr__() for non-
+  interned or unicode attribute names.  Based on patch by Eryk Sun.
 
 - bpo-29935: Fixed error messages in the index() method of tuple and list
   when pass indices of wrong type.
 
 - bpo-28598: Support __rmod__ for subclasses of str being called before
-  str.__mod__.  Patch by Martijn Pieters.
+  str.__mod__. Patch by Martijn Pieters.
 
-- bpo-29602: Fix incorrect handling of signed zeros in complex constructor for
-  complex subclasses and for inputs having a __complex__ method. Patch
+- bpo-29602: Fix incorrect handling of signed zeros in complex constructor
+  for complex subclasses and for inputs having a __complex__ method. Patch
   by Serhiy Storchaka.
 
-- bpo-29347: Fixed possibly dereferencing undefined pointers
-  when creating weakref objects.
+- bpo-29347: Fixed possibly dereferencing undefined pointers when creating
+  weakref objects.
 
-- Issue #14376: Allow sys.exit to accept longs as well as ints. Patch
-  by Gareth Rees.
+- bpo-14376: Allow sys.exit to accept longs as well as ints. Patch by Gareth
+  Rees.
 
-- Issue #29028: Fixed possible use-after-free bugs in the subscription of the
+- bpo-29028: Fixed possible use-after-free bugs in the subscription of the
   buffer object with custom index object.
 
-- Issue #29145: Fix overflow checks in string, bytearray and unicode.
-  Patch by jan matejek and Xiang Zhang.
-
-- Issue #28932: Do not include <sys/random.h> if it does not exist.
+- bpo-29145: Fix overflow checks in string, bytearray and unicode. Patch by
+  jan matejek and Xiang Zhang.
 
-Extension Modules
------------------
-
-- Issue #29169: Update zlib to 1.2.11.
+- bpo-28932: Do not include <sys/random.h> if it does not exist.
 
 Library
 -------
 
+- bpo-33096: Allow ttk.Treeview.insert to insert iid that has a false
+  boolean value. Note iid=0 and iid=False would be same. Patch by Garvit
+  Khatri.
+
+- bpo-33127: The ssl module now compiles with LibreSSL 2.7.1.
+
+- bpo-30622: The ssl module now detects missing NPN support in LibreSSL.
+
+- bpo-21060: Rewrite confusing message from setup.py upload from "No dist
+  file created in earlier command" to the more helpful "Must create and
+  upload files in one command".
+
+- bpo-30157: Fixed guessing quote and delimiter in csv.Sniffer.sniff() when
+  only the last field is quoted.  Patch by Jake Davis.
+
+- bpo-32647: The ctypes module used to depend on indirect linking for
+  dlopen. The shared extension is now explicitly linked against libdl on
+  platforms with dl.
+
+- bpo-32304: distutils' upload command no longer corrupts tar files ending
+  with a CR byte, and no longer tries to convert CR to CRLF in any of the
+  upload text fields.
+
+- bpo-31848: Fix the error handling in Aifc_read.initfp() when the SSND
+  chunk is not found. Patch by Zackery Spytz.
+
+- bpo-32521: The nis module is now compatible with new libnsl and headers
+  location.
+
+- bpo-32539: Fix ``OSError`` for ``os.listdir`` with deep paths (starting
+  with ``\\?\``) on windows.  Patch by Anthony Sottile.
+
+- bpo-32521: glibc has removed Sun RPC. Use replacement libtirpc headers and
+  library in nis module.
+
+- bpo-18035: ``telnetlib``: ``select.error`` doesn't have an ``errno``
+  attribute. Patch by Segev Finer.
+
+- bpo-32185: The SSL module no longer sends IP addresses in SNI TLS
+  extension on platforms with OpenSSL 1.0.2+ or inet_pton.
+
+- bpo-32186: Creating io.FileIO() and builtin file() objects now release the
+  GIL when checking the file descriptor. io.FileIO.readall(),
+  io.FileIO.read(), and file.read() now release the GIL when getting the
+  file size.  Fixed hang of all threads with inaccessible NFS server.  Patch
+  by Nir Soffer.
+
+- bpo-32110: ``codecs.StreamReader.read(n)`` now returns not more than *n*
+  characters/bytes for non-negative *n*. This makes it compatible with
+  ``read()`` methods of other file-like objects.
+
+- bpo-21149: Silence a `'NoneType' object is not callable` in
+  `_removeHandlerRef` error that could happen when a logging Handler is
+  destroyed as part of cyclic garbage collection during process shutdown.
+
+- bpo-31764: Prevent a crash in ``sqlite3.Cursor.close()`` in case the
+  ``Cursor`` object is uninitialized. Patch by Oren Milman.
+
+- bpo-31955: Fix CCompiler.set_executable() of distutils to handle properly
+  Unicode strings.
+
+- bpo-9678: Fixed determining the MAC address in the uuid module:
+
+  * Using ifconfig on NetBSD and OpenBSD.
+  * Using arp on Linux, FreeBSD, NetBSD and OpenBSD.
+
+  Based on patch by Takayuki Shimizukawa.
+
+- bpo-30057: Fix potential missed signal in signal.signal().
+
+- bpo-31927: Fixed reading arbitrary data when parse a AF_BLUETOOTH address
+  on NetBSD and DragonFly BSD.
+
+- bpo-27666: Fixed stack corruption in curses.box() and curses.ungetmouse()
+  when the size of types chtype or mmask_t is less than the size of C long.
+  curses.box() now accepts characters as arguments.  Based on patch by Steve
+  Fink.
+
+- bpo-25720: Fix the method for checking pad state of curses WINDOW. Patch
+  by Masayuki Yamamoto.
+
+- bpo-31893: Fixed the layout of the kqueue_event structure on OpenBSD and
+  NetBSD. Fixed the comparison of the kqueue_event objects.
+
+- bpo-31891: Fixed building the curses module on NetBSD.
+
+- bpo-30058: Fixed buffer overflow in select.kqueue.control().
+
+- bpo-31770: Prevent a crash when calling the ``__init__()`` method of a
+  ``sqlite3.Cursor`` object more than once. Patch by Oren Milman.
+
+- bpo-31728: Prevent crashes in `_elementtree` due to unsafe cleanup of
+  `Element.text` and `Element.tail`. Patch by Oren Milman.
+
+- bpo-31752: Fix possible crash in timedelta constructor called with custom
+  integers.
+
+- bpo-31681: Fix pkgutil.get_data to avoid leaking open files.
+
+- bpo-31675: Fixed memory leaks in Tkinter's methods splitlist() and split()
+  when pass a string larger than 2 GiB.
+
+- bpo-30806: Fix the string representation of a netrc object.
+
+- bpo-30347: Stop crashes when concurrently iterate over itertools.groupby()
+  iterators.
+
+- bpo-25732: `functools.total_ordering()` now implements the `__ne__`
+  method.
+
+- bpo-31351: python -m ensurepip now exits with non-zero exit code if pip
+  bootstrapping has failed.
+
+- bpo-31544: The C accelerator module of ElementTree ignored exceptions
+  raised when looking up TreeBuilder target methods in XMLParser().
+
+- bpo-31455: The C accelerator module of ElementTree ignored exceptions
+  raised when looking up TreeBuilder target methods in XMLParser().
+
+- bpo-25404: SSLContext.load_dh_params() now supports non-ASCII path.
+
+- bpo-28958: ssl.SSLContext() now uses OpenSSL error information when a
+  context cannot be instantiated.
+
+- bpo-27448: Work around a `gc.disable()` race condition in the `subprocess`
+  module that could leave garbage collection disabled when multiple threads
+  are spawning subprocesses at once.  Users are *strongly encouraged* to use
+  the `subprocess32` module from PyPI on Python 2.7 instead, it is much more
+  reliable.
+
+- bpo-31170: expat: Update libexpat from 2.2.3 to 2.2.4. Fix copying of
+  partial characters for UTF-8 input (libexpat bug 115):
+  https://github.com/libexpat/libexpat/issues/115
+
+- bpo-29136: Add TLS 1.3 cipher suites and OP_NO_TLSv1_3.
+
+- bpo-31334: Fix ``poll.poll([timeout])`` in the ``select`` module for
+  arbitrary negative timeouts on all OSes where it can only be a non-
+  negative integer or -1. Patch by Riccardo Coccioli.
+
+- bpo-10746: Fix ctypes producing wrong PEP 3118 type codes for integer
+  types.
+
+- bpo-30102: The ssl and hashlib modules now call
+  OPENSSL_add_all_algorithms_noconf() on OpenSSL < 1.1.0. The function
+  detects CPU features and enables optimizations on some CPU architectures
+  such as POWER8. Patch is based on research from Gustavo Serra Scalet.
+
+- bpo-30502: Fix handling of long oids in ssl.  Based on patch by Christian
+  Heimes.
+
+- bpo-25684: Change ``ttk.OptionMenu`` radiobuttons to be unique across
+  instances of ``OptionMenu``.
+
+- bpo-29169: Update zlib to 1.2.11.
+
 - bpo-30746: Prohibited the '=' character in environment variable names in
   ``os.putenv()`` and ``os.spawn*()``.
 
-- [Security] bpo-30730: Prevent environment variables injection in subprocess on
-  Windows.  Prevent passing other environment variables and command arguments.
-
-- [Security] bpo-30694: Upgrade expat copy from 2.2.0 to 2.2.1 to get fixes
-  of multiple security vulnerabilities including: CVE-2017-9233 (External
-  entity infinite loop DoS), CVE-2016-9063 (Integer overflow, re-fix),
-  CVE-2016-0718 (Fix regression bugs from 2.2.0's fix to CVE-2016-0718)
-  and CVE-2012-0876 (Counter hash flooding with SipHash).
-  Note: the CVE-2016-5300 (Use os-specific entropy sources like getrandom)
-  doesn't impact Python, since Python already gets entropy from the OS to set
-  the expat secret using ``XML_SetHashSalt()``.
-
-- [Security] bpo-30500: Fix urllib.splithost() to correctly parse
-  fragments. For example, ``splithost('//127.0.0.1#@evil.com/')`` now
-  correctly returns the ``127.0.0.1`` host, instead of treating ``@evil.com``
-  as the host in an authentification (``login@host``).
-
-- [Security] bpo-29591: Update expat copy from 2.1.1 to 2.2.0 to get fixes
-  of CVE-2016-0718 and CVE-2016-4472. See
-  https://sourceforge.net/p/expat/bugs/537/ for more information.
-
-- bpo-28994: The traceback no longer displayed for SystemExit raised in
-  a callback registered by atexit.
+- bpo-28994: The traceback no longer displayed for SystemExit raised in a
+  callback registered by atexit.
 
-- bpo-30418: On Windows, subprocess.Popen.communicate() now also ignore EINVAL
-  on stdin.write() if the child process is still running but closed the pipe.
+- bpo-30418: On Windows, subprocess.Popen.communicate() now also ignore
+  EINVAL on stdin.write() if the child process is still running but closed
+  the pipe.
 
 - bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
   handle IPv6 addresses.
 
-- bpo-29960: Preserve generator state when _random.Random.setstate()
-  raises an exception.  Patch by Bryan Olson.
+- bpo-29960: Preserve generator state when _random.Random.setstate() raises
+  an exception. Patch by Bryan Olson.
 
 - bpo-30310: tkFont now supports unicode options (e.g. font family).
 
-- bpo-30414: multiprocessing.Queue._feed background running
-  thread do not break from main loop on exception.
+- bpo-30414: multiprocessing.Queue._feed background running thread do not
+  break from main loop on exception.
 
-- bpo-30003: Fix handling escape characters in HZ codec.  Based on patch
-  by Ma Lin.
+- bpo-30003: Fix handling escape characters in HZ codec.  Based on patch by
+  Ma Lin.
 
 - bpo-30375: Warnings emitted when compile a regular expression now always
-  point to the line in the user code.  Previously they could point into inners
-  of the re module if emitted from inside of groups or conditionals.
+  point to the line in the user code.  Previously they could point into
+  inners of the re module if emitted from inside of groups or conditionals.
 
 - bpo-30363: Running Python with the -3 option now warns about regular
-  expression syntax that is invalid or has different semantic in Python 3
-  or will change the behavior in future Python versions.
+  expression syntax that is invalid or has different semantic in Python 3 or
+  will change the behavior in future Python versions.
 
-- bpo-30365: Running Python with the -3 option now emits deprecation warnings
-  for getchildren() and getiterator() methods of the Element class in the
-  xml.etree.cElementTree module and when pass the html argument to
+- bpo-30365: Running Python with the -3 option now emits deprecation
+  warnings for getchildren() and getiterator() methods of the Element class
+  in the xml.etree.cElementTree module and when pass the html argument to
   xml.etree.ElementTree.XMLParser().
 
 - bpo-30365: Fixed a deprecation warning about the doctype() method of the
   xml.etree.ElementTree.XMLParser class.  Now it is emitted only when define
   the doctype() method in the subclass of XMLParser.
 
-- bpo-30329: imaplib now catchs the Windows socket WSAEINVAL error
-  (code 10022) on shutdown(SHUT_RDWR): An invalid operation was attempted.
-  This error occurs sometimes on SSL connections.
+- bpo-30329: imaplib now catchs the Windows socket WSAEINVAL error (code
+  10022) on shutdown(SHUT_RDWR): An invalid operation was attempted. This
+  error occurs sometimes on SSL connections.
 
 - bpo-30342: Fix sysconfig.is_python_build() if Python is built with Visual
   Studio 2008 (VS 9.0).
 
-- bpo-29990: Fix range checking in GB18030 decoder.  Original patch by Ma Lin.
+- bpo-29990: Fix range checking in GB18030 decoder.  Original patch by Ma
+  Lin.
 
 - bpo-30243: Removed the __init__ methods of _json's scanner and encoder.
-  Misusing them could cause memory leaks or crashes.  Now scanner and encoder
-  objects are completely initialized in the __new__ methods.
+  Misusing them could cause memory leaks or crashes.  Now scanner and
+  encoder objects are completely initialized in the __new__ methods.
 
-- Revert bpo-26293 for zipfile breakage. See also bpo-29094.
+- bpo-26293: Change resulted because of zipfile breakage. (See also:
+  bpo-29094)
 
-- bpo-30070: Fixed leaks and crashes in errors handling in the parser module.
+- bpo-30070: Fixed leaks and crashes in errors handling in the parser
+  module.
 
 - bpo-30061: Fixed crashes in IOBase methods next() and readlines() when
-  readline() or next() respectively return non-sizeable object.
-  Fixed possible other errors caused by not checking results of PyObject_Size(),
+  readline() or next() respectively return non-sizeable object. Fixed
+  possible other errors caused by not checking results of PyObject_Size(),
   PySequence_Size(), or PyMapping_Size().
 
 - bpo-30011: Fixed race condition in HTMLParser.unescape().
 
-- bpo-30068: _io._IOBase.readlines will check if it's closed first when
-  hint is present.
+- bpo-30068: _io._IOBase.readlines will check if it's closed first when hint
+  is present.
 
 - bpo-27863: Fixed multiple crashes in ElementTree caused by race conditions
   and wrong types.
@@ -164,94 +394,98 @@ Library
   too many objects.
 
 - bpo-29110: Fix file object leak in aifc.open() when file is given as a
-  filesystem path and is not in valid AIFF format.
-  Original patch by Anthony Zhang.
+  filesystem path and is not in valid AIFF format. Original patch by Anthony
+  Zhang.
 
-- Issue #29354: Fixed inspect.getargs() for parameters which are cell
+- bpo-29354: Fixed inspect.getargs() for parameters which are cell
   variables.
 
-- Issue #29335: Fix subprocess.Popen.wait() when the child process has
-  exited to a stopped instead of terminated state (ex: when under ptrace).
+- bpo-29335: Fix subprocess.Popen.wait() when the child process has exited
+  to a stopped instead of terminated state (ex: when under ptrace).
 
-- Issue #29219: Fixed infinite recursion in the repr of uninitialized
+- bpo-29219: Fixed infinite recursion in the repr of uninitialized
   ctypes.CDLL instances.
 
-- Issue #29082: Fixed loading libraries in ctypes by unicode names on Windows.
+- bpo-29082: Fixed loading libraries in ctypes by unicode names on Windows.
   Original patch by Chi Hsuan Yen.
 
-- Issue #29188: Support glibc 2.24 on Linux: don't use getentropy() function
-  but read from /dev/urandom to get random bytes, for example in os.urandom().
-  On Linux, getentropy() is implemented which getrandom() is blocking mode,
-  whereas os.urandom() should not block.
+- bpo-29188: Support glibc 2.24 on Linux: don't use getentropy() function
+  but read from /dev/urandom to get random bytes, for example in
+  os.urandom(). On Linux, getentropy() is implemented which getrandom() is
+  blocking mode, whereas os.urandom() should not block.
 
-- Issue #29142: In urllib, suffixes in no_proxy environment variable with
-  leading dots could match related hostnames again (e.g. .b.c matches a.b.c).
-  Patch by Milan Oberkirch.
+- bpo-29142: In urllib, suffixes in no_proxy environment variable with
+  leading dots could match related hostnames again (e.g. .b.c matches
+  a.b.c). Patch by Milan Oberkirch.
 
-- Issue #13051: Fixed recursion errors in large or resized
+- bpo-13051: Fixed recursion errors in large or resized
   curses.textpad.Textbox.  Based on patch by Tycho Andersen.
 
-- Issue #9770: curses.ascii predicates now work correctly with negative
+- bpo-9770: curses.ascii predicates now work correctly with negative
   integers.
 
-- Issue #28427: old keys should not remove new values from
-  WeakValueDictionary when collecting from another thread.
+- bpo-28427: old keys should not remove new values from WeakValueDictionary
+  when collecting from another thread.
 
-- Issue #28998: More APIs now support longs as well as ints.
+- bpo-28998: More APIs now support longs as well as ints.
 
-- Issue 28923: Remove editor artifacts from Tix.py,
-  including encoding not recognized by codecs.lookup.
+- bpo-28923: Remove editor artifacts from Tix.py, including encoding not
+  recognized by codecs.lookup.
 
-- Issue #29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
+- bpo-29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
   Original patch by Rasmus Villemoes.
 
-- Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and
-  WeakValueDictionary.pop() when a GC collection happens in another
-  thread.
+- bpo-19542: Fix bugs in WeakValueDictionary.setdefault() and
+  WeakValueDictionary.pop() when a GC collection happens in another thread.
 
-- Issue #28925: cPickle now correctly propagates errors when unpickle instances
+- bpo-28925: cPickle now correctly propagates errors when unpickle instances
   of old-style classes.
 
 Documentation
 -------------
 
-- bpo-30176: Add missing attribute related constants in curses documentation.
-
-- bpo-28929: Link the documentation to its source file on GitHub.
+- bpo-27212: Modify documentation for the :func:`islice` recipe to consume
+  initial values up to the start index.
 
-- Issue #26355: Add canonical header link on each page to corresponding major
-  version of the documentation. Patch by Matthias Bussonnier.
+- bpo-32800: Update link to w3c doc for xml default namespaces.
 
-- Issue #12067: Rewrite Comparisons section in the Expressions chapter of the
-  language reference. Some of the details of comparing mixed types were
-  incorrect or ambiguous. Added default behaviour and consistency suggestions
-  for user-defined classes. Based on patch from Andy Maier.
-
-Build
------
+- bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile and
+  their C-API counterparts regarding which type of events are received in
+  each function. Patch by Pablo Galindo Salgado.
 
- bpo-29243: Prevent unnecessary rebuilding of Python during ``make test``,
-  ``make install`` and some other make targets when configured with
-  ``--enable-optimizations``.
+- bpo-8243: Add a note about curses.addch and curses.addstr exception
+  behavior when writing outside a window, or pad.
 
-- bpo-23404: Don't regenerate generated files based on file modification time
-  anymore: the action is now explicit. Replace ``make touch`` with
-  ``make regen-all``.
+- bpo-21649: Add RFC 7525 and Mozilla server side TLS links to SSL
+  documentation.
 
-- bpo-27593: sys.version and the platform module python_build(),
-  python_branch(), and python_revision() functions now use
-  git information rather than hg when building from a repo.
+- bpo-30176: Add missing attribute related constants in curses
+  documentation.
 
-- bpo-29643: Fix ``--enable-optimization`` configure option didn't work.
+- bpo-28929: Link the documentation to its source file on GitHub.
 
-- bpo-29572: Update Windows build and OS X installers to use OpenSSL 1.0.2k.
+- bpo-26355: Add canonical header link on each page to corresponding major
+  version of the documentation. Patch by Matthias Bussonnier.
 
-- Issue #28768: Fix implicit declaration of function _setmode. Patch by
-  Masayuki Yamamoto
+- bpo-12067: Rewrite Comparisons section in the Expressions chapter of the
+  language reference. Some of the details of comparing mixed types were
+  incorrect or ambiguous. Added default behaviour and consistency
+  suggestions for user- defined classes. Based on patch from Andy Maier.
 
 Tests
 -----
 
+- bpo-31719: Fix test_regrtest.test_crashed() on s390x. Add a new
+  _testcapi._read_null() function to crash Python in a reliable way on
+  s390x. On s390x, ctypes.string_at(0) returns an empty string rather than
+  crashing.
+
+- bpo-31518: Debian Unstable has disabled TLS 1.0 and 1.1 for
+  SSLv23_METHOD(). Change TLS/SSL protocol of some tests to PROTOCOL_TLS or
+  PROTOCOL_TLSv1_2 to make them pass on Debian.
+
+- bpo-25674: Remove sha256.tbs-internet.com ssl test
+
 - bpo-11790: Fix sporadic failures in
   test_multiprocessing.WithProcessesTestCondition.
 
@@ -264,32 +498,210 @@ Tests
 
 - bpo-30207: To simplify backports from Python 3, the test.test_support
   module was converted into a package and renamed to test.support.  The
-  test.script_helper module was moved into the test.support package.
-  Names test.test_support and test.script_helper are left as aliases to
+  test.script_helper module was moved into the test.support package. Names
+  test.test_support and test.script_helper are left as aliases to
   test.support and test.support.script_helper.
 
 - bpo-30197: Enhanced function swap_attr() in the test.test_support module.
-  It now works when delete replaced attribute inside the with statement.  The
-  old value of the attribute (or None if it doesn't exist) now will be
-  assigned to the target of the "as" clause, if there is one.
-  Also backported function swap_item().
+  It now works when delete replaced attribute inside the with statement.
+  The old value of the attribute (or None if it doesn't exist) now will be
+  assigned to the target of the "as" clause, if there is one. Also
+  backported function swap_item().
 
-- bpo-28087: Skip test_asyncore and test_eintr poll failures on macOS.
-  Skip some tests of select.poll when running on macOS due to unresolved
-  issues with the underlying system poll function on some macOS versions.
+- bpo-28087: Skip test_asyncore and test_eintr poll failures on macOS. Skip
+  some tests of select.poll when running on macOS due to unresolved issues
+  with the underlying system poll function on some macOS versions.
 
 - bpo-15083: Convert ElementTree doctests to unittests.
 
+Build
+-----
+
+- bpo-33163: Upgrade pip to 9.0.3 and setuptools to v39.0.1.
+
+- bpo-32616: Disable computed gotos by default for clang < 5.0. It caused
+  significant performance regression.
+
+- bpo-32635: Fix segfault of the crypt module when libxcrypt is provided
+  instead of libcrypt at the system.
+
+- bpo-31934: Abort the build when building out of a not clean source tree.
 
-What's New in Python 2.7.13
-===========================
+- bpo-31474: Fix -Wint-in-bool-context warnings in PyMem_MALLOC and
+  PyMem_REALLOC macros
+
+- bpo-29243: Prevent unnecessary rebuilding of Python during ``make test``,
+  ``make install`` and some other make targets when configured with
+  ``--enable- optimizations``.
+
+- bpo-23404: Don't regenerate generated files based on file modification
+  time anymore: the action is now explicit. Replace ``make touch`` with
+  ``make regen-all``.
+
+- bpo-27593: sys.version and the platform module python_build(),
+  python_branch(), and python_revision() functions now use git information
+  rather than hg when building from a repo.
+
+- bpo-29643: Fix ``--enable-optimization`` configure option didn't work.
+
+- bpo-29572: Update Windows build and OS X installers to use OpenSSL 1.0.2k.
+
+- bpo-28768: Fix implicit declaration of function _setmode. Patch by
+  Masayuki Yamamoto
+
+Windows
+-------
+
+- bpo-33184: Update Windows build to use OpenSSL 1.0.2o.
+
+- bpo-32903: Fix a memory leak in os.chdir() on Windows if the current
+  directory is set to a UNC path.
+
+- bpo-30855: Bump Tcl/Tk to 8.5.19.
+
+- bpo-30450: Pull build dependencies from GitHub rather than svn.python.org.
+
+macOS
+-----
+
+- bpo-32726: Provide an additional, more modern macOS installer variant that
+  supports macOS 10.9+ systems in 64-bit mode only. Upgrade the supplied
+  third-party libraries to OpenSSL 1.0.2n and SQLite 3.22.0. The 10.9+
+  installer now supplies its own private copy of Tcl/Tk 8.6.8.
+
+- bpo-24414: Default macOS deployment target is now set by ``configure`` to
+  the build system's OS version (as is done by Python 3), not ``10.4``;
+  override with, for example, ``./configure MACOSX_DEPLOYMENT_TARGET=10.4``.
+
+- bpo-17128: All 2.7 macOS installer variants now supply their own version
+  of ``OpenSSL 1.0.2``; the Apple-supplied SSL libraries and root
+  certificates are not longer used.  The ``Installer Certificate`` command
+  in ``/Applications/Python 2.7`` may be used to download and install a
+  default set of root certificates from the third-party ``certifi`` package.
+
+- bpo-11485: python.org macOS Pythons no longer supply a default SDK value
+  (e.g. ``-isysroot /``) or specific compiler version default (e.g.
+  ``gcc-4.2``) when building extension modules.  Use ``CC``, ``SDKROOT``,
+  and ``DEVELOPER_DIR`` environment variables to override compilers or to
+  use an SDK.  See Apple's ``xcrun`` man page for more info.
+
+- bpo-33184: Update macOS installer build to use OpenSSL 1.0.2o.
+
+Tools/Demos
+-----------
+
+- bpo-31920: Fixed handling directories as arguments in the ``pygettext``
+  script. Based on patch by Oleg Krasnikov.
+
+- bpo-30109: Fixed Tools/scripts/reindent.py for non-ASCII files. It now
+  processes files as binary streams. This also fixes "make reindent".
+
+- bpo-24960: 2to3 and lib2to3 can now read pickled grammar files using
+  pkgutil.get_data() rather than probing the filesystem. This lets 2to3 and
+  lib2to3 work when run from a zipfile.
+
+C API
+-----
+
+- bpo-20891: Fix PyGILState_Ensure(). When PyGILState_Ensure() is called in
+  a non-Python thread before PyEval_InitThreads(), only call
+  PyEval_InitThreads() after calling PyThreadState_New() to fix a crash.
+
+- bpo-31626: When Python is built in debug mode, the memory debug hooks now
+  fail with a fatal error if realloc() fails to shrink a memory block,
+  because the debug hook just erased freed bytes without keeping a copy of
+  them.
+
+
+What's New in Python 2.7.14 release candidate 1?
+================================================
+
+*Release date: 2017-08-26*
+
+Security
+--------
+
+- bpo-30947: Upgrade libexpat embedded copy from version 2.2.1 to 2.2.3 to
+  get security fixes.
+
+Core and Builtins
+-----------------
+
+- bpo-30765: Avoid blocking in pthread_mutex_lock() when
+  PyThread_acquire_lock() is asked not to block.
+
+Library
+-------
+
+- bpo-31135: ttk: Fix LabeledScale and OptionMenu destroy() method. Call the
+  parent destroy() method even if the used attribute doesn't exist. The
+  LabeledScale.destroy() method now also explicitly clears label and scale
+  attributes to help the garbage collector to destroy all widgets.
+
+- bpo-31107: Fix `copy_reg._slotnames()` mangled attribute calculation for
+  classes whose name begins with an underscore. Patch by Shane Harvey.
+
+- bpo-29519: Fix weakref spewing exceptions during interpreter shutdown when
+  used with a rare combination of multiprocessing and custom codecs.
+
+- bpo-30119: ftplib.FTP.putline() now throws ValueError on commands that
+  contains CR or LF. Patch by Dong-hee Na.
+
+- bpo-30595: multiprocessing.Queue.get() with a timeout now polls its reader
+  in non- blocking mode if it succeeded to aquire the lock but the acquire
+  took longer than the timeout.
+
+- bpo-29902: Py3k deprecation warning now is emitted when pickling or
+  copying some builtin and extension objects that don't support pickling
+  explicitly and are pickled incorrectly by default (like memoryview or
+  staticmethod).  This is a TypeError in Python 3.6.
+
+- bpo-29854: Fix segfault in readline when using readline's history-size
+  option.  Patch by Nir Soffer.
+
+- bpo-30807: signal.setitimer() may disable the timer when passed a tiny
+  value.
+
+  Tiny values (such as 1e-6) are valid non-zero values for setitimer(),
+  which is specified as taking microsecond-resolution intervals. However, on
+  some platform, our conversion routine could convert 1e-6 into a zero
+  interval, therefore disabling the timer instead of (re-)scheduling it.
+
+Tests
+-----
+
+- bpo-30715: Address ALPN callback changes for OpenSSL 1.1.0f. The latest
+  version behaves like OpenSSL 1.0.2 and no longer aborts handshake.
+
+- bpo-30822: Fix regrtest command line parser to allow passing -u
+  extralargefile to run test_zipfile64.
+
+- bpo-30283: regrtest: Enhance regrtest and backport features from the
+  master branch.
+
+  Add options: --coverage, --testdir, --list-tests (list test files, don't
+  run them), --list-cases (list test identifiers, don't run them,
+  :issue:`30523`), --matchfile (load a list of test filters from a text
+  file, :issue:`30540`), --slowest (alias to --slow).
+
+  Enhance output: add timestamp, test result, currently running tests,
+  "Tests result: xxx" summary with total duration, etc.
+
+  Fix reference leak hunting in regrtest, --huntrleaks: regrtest now warms
+  up caches, create explicitly all internal singletons which are created on
+  demand to prevent false positives when checking for reference leaks.
+  (:issue:`30675`).
+
+
+What's New in Python 2.7.13 final?
+==================================
 
 *Release date: 2016-12-17*
 
 Core and Builtins
 -----------------
 
-- Revert a37cc3d926ec (Issue #5322).
+- bpo-5322: Revert a37cc3d926ec.
 
 
 What's New in Python 2.7.13 release candidate 1?
@@ -300,362 +712,368 @@ What's New in Python 2.7.13 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #5322: Fixed setting __new__ to a PyCFunction inside Python code.
+- bpo-5322: Fixed setting __new__ to a PyCFunction inside Python code.
   Original patch by Andreas Stührk.
 
-- Issue #28847: dumbdbm no longer writes the index file in when it is not
+- bpo-28847: dumbdbm no longer writes the index file in when it is not
   changed and supports reading read-only files.
 
-- Issue #11145: Fixed miscellaneous issues with C-style formatting of types
+- bpo-11145: Fixed miscellaneous issues with C-style formatting of types
   with custom __oct__ and __hex__.
 
-- Issue #24469: Fixed memory leak caused by int subclasses without overridden
+- bpo-24469: Fixed memory leak caused by int subclasses without overridden
   tp_free (e.g. C-inherited Cython classes).
 
-- Issue #19398: Extra slash no longer added to sys.path components in case of
-  empty compile-time PYTHONPATH components.
+- bpo-19398: Extra slash no longer added to sys.path components in case of
+  empty compile- time PYTHONPATH components.
 
-- Issue #21720: Improve exception message when the type of fromlist is unicode.
+- bpo-21720: Improve exception message when the type of fromlist is unicode.
   fromlist parameter of __import__() only accepts str in Python 2 and this
   will help to identify the problem especially when the unicode_literals
   future import is used.
 
-- Issue #26906: Resolving special methods of uninitialized type now causes
+- bpo-26906: Resolving special methods of uninitialized type now causes
   implicit initialization of the type instead of a fail.
 
-- Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
-  Original patch by Niklas Koep.
+- bpo-18287: PyType_Ready() now checks that tp_name is not NULL. Original
+  patch by Niklas Koep.
 
-- Issue #24098: Fixed possible crash when AST is changed in process of
+- bpo-24098: Fixed possible crash when AST is changed in process of
   compiling it.
 
-- Issue #28350: String constants with null character no longer interned.
+- bpo-28350: String constants with null character no longer interned.
 
-- Issue #27942: String constants now interned recursively in tuples and frozensets.
+- bpo-27942: String constants now interned recursively in tuples and
+  frozensets.
 
-- Issue #15578: Correctly incref the parent module while importing.
+- bpo-15578: Correctly incref the parent module while importing.
 
-- Issue #26307: The profile-opt build now applies PGO to the built-in modules.
+- bpo-26307: The profile-opt build now applies PGO to the built-in modules.
 
-- Issue #26020: set literal evaluation order did not match documented behaviour.
+- bpo-26020: set literal evaluation order did not match documented
+  behaviour.
 
-- Issue #27870: A left shift of zero by a large integer no longer attempts
-  to allocate large amounts of memory.
+- bpo-27870: A left shift of zero by a large integer no longer attempts to
+  allocate large amounts of memory.
 
-- Issue #25604: Fix a minor bug in integer true division; this bug could
+- bpo-25604: Fix a minor bug in integer true division; this bug could
   potentially have caused off-by-one-ulp results on platforms with
   unreliable ldexp implementations.
 
-- Issue #27473: Fixed possible integer overflow in str, unicode and bytearray
+- bpo-27473: Fixed possible integer overflow in str, unicode and bytearray
   concatenations and repetitions.  Based on patch by Xiang Zhang.
 
-- Issue #27507: Add integer overflow check in bytearray.extend().  Patch by
+- bpo-27507: Add integer overflow check in bytearray.extend().  Patch by
   Xiang Zhang.
 
-- Issue #27581: Don't rely on wrapping for overflow check in
+- bpo-27581: Don't rely on wrapping for overflow check in
   PySequence_Tuple().  Patch by Xiang Zhang.
 
-- Issue #23908: os functions, open() and the io.FileIO constructor now reject
+- bpo-23908: os functions, open() and the io.FileIO constructor now reject
   unicode paths with embedded null character on Windows instead of silently
   truncating them.
 
-- Issue #27514: Make having too many statically nested blocks a SyntaxError
+- bpo-27514: Make having too many statically nested blocks a SyntaxError
   instead of SystemError.
 
 Library
 -------
 
-- Issue #25659: In ctypes, prevent a crash calling the from_buffer() and
+- bpo-25659: In ctypes, prevent a crash calling the from_buffer() and
   from_buffer_copy() methods on abstract classes like Array.
 
-- Issue #28563: Fixed possible DoS and arbitrary code execution when handle
+- bpo-28563: Fixed possible DoS and arbitrary code execution when handle
   plural form selections in the gettext module.  The expression parser now
   supports exact syntax supported by GNU gettext.
 
-- Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
-  the garbage collector is invoked in other thread.  Based on patch by
-  Sebastian Cufre.
+- bpo-28387: Fixed possible crash in _io.TextIOWrapper deallocator when the
+  garbage collector is invoked in other thread.  Based on patch by Sebastian
+  Cufre.
 
-- Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
-  file with compression before trying to open it without compression.  Otherwise
-  it had 50% chance failed with ignore_zeros=True.
+- bpo-28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
+  file with compression before trying to open it without compression.
+  Otherwise it had 50% chance failed with ignore_zeros=True.
 
-- Issue #25464: Fixed HList.header_exists() in Tix module by adding
-  workaround to Tix library bug.
+- bpo-25464: Fixed HList.header_exists() in Tix module by adding a
+  workaround to Tix library bug.
 
-- Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive.
+- bpo-28488: shutil.make_archive() no longer adds entry "./" to ZIP archive.
 
-- Issue #28480: Fix error building _sqlite3 module when multithreading is
+- bpo-28480: Fix error building _sqlite3 module when multithreading is
   disabled.
 
-- Issue #24452: Make webbrowser support Chrome on Mac OS X.
+- bpo-24452: Make webbrowser support Chrome on Mac OS X.
 
-- Issue #26293: Fixed writing ZIP files that starts not from the start of the
+- bpo-26293: Fixed writing ZIP files that starts not from the start of the
   file.  Offsets in ZIP file now are relative to the start of the archive in
   conforming to the specification.
 
 - Fix possible integer overflows and crashes in the mmap module with unusual
   usage patterns.
 
-- Issue #27897: Fixed possible crash in sqlite3.Connection.create_collation()
-  if pass invalid string-like object as a name.  Original patch by Xiang Zhang.
+- bpo-27897: Fixed possible crash in sqlite3.Connection.create_collation()
+  if pass invalid string-like object as a name.  Original patch by Xiang
+  Zhang.
 
-- Issue #1703178: Fix the ability to pass the --link-objects option to the
+- bpo-1703178: Fix the ability to pass the --link-objects option to the
   distutils build_ext command.
 
-- Issue #28253: Fixed calendar functions for extreme months: 0001-01
-  and 9999-12.
+- bpo-28253: Fixed calendar functions for extreme months: 0001-01 and
+  9999-12.
 
-  Methods itermonthdays() and itermonthdays2() are reimplemented so
-  that they don't call itermonthdates() which can cause datetime.date
+  Methods itermonthdays() and itermonthdays2() are reimplemented so that
+  they don't call itermonthdates() which can cause datetime.date
   under/overflow.
 
-- Issue #27963: Fixed possible null pointer dereference in
-  ctypes.set_conversion_mode().  Patch by Xiang Zhang.
+- bpo-27963: Fixed possible null pointer dereference in
+  ctypes.set_conversion_mode(). Patch by Xiang Zhang.
 
-- Issue #28284: Strengthen resistance of ``_json.encode_basestring_ascii()`` to
+- bpo-28284: Strengthen resistance of ``_json.encode_basestring_ascii()`` to
   integer overflow.
 
-- Issue #27611: Fixed support of default root window in the Tix module.
+- bpo-27611: Fixed support of default root window in the Tix module.
 
-- Issue #24363: When parsing HTTP header fields, if an invalid line is
+- bpo-24363: When parsing HTTP header fields, if an invalid line is
   encountered, skip it and continue parsing.  Previously, no more header
   fields were parsed, which could lead to fields for HTTP framing like
-  Content-Length and Transfer-Encoding being overlooked.
+  Content-Length and Transfer- Encoding being overlooked.
 
-- Issue #27599: Fixed buffer overrun in binascii.b2a_qp() and binascii.a2b_qp().
+- bpo-27599: Fixed buffer overrun in binascii.b2a_qp() and
+  binascii.a2b_qp().
 
-- Issue #25969: Update the lib2to3 grammar to handle the unpacking
+- bpo-25969: Update the lib2to3 grammar to handle the unpacking
   generalizations added in 3.5.
 
-- Issue #24594: Validates persist parameter when opening MSI database
+- bpo-24594: Validates persist parameter when opening MSI database
 
-- Issue #27570: Avoid zero-length memcpy() etc calls with null source
-  pointers in the "ctypes" and "array" modules.
+- bpo-27570: Avoid zero-length memcpy() etc calls with null source pointers
+  in the "ctypes" and "array" modules.
 
-- Issue #22450: urllib now includes an "Accept: */*" header among the
-  default headers.  This makes the results of REST API requests more
-  consistent and predictable especially when proxy servers are involved.
+- bpo-22450: urllib now includes an "Accept: */*" header among the default
+  headers.  This makes the results of REST API requests more consistent and
+  predictable especially when proxy servers are involved.
 
 - lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
   between runs given the same Grammar.txt input regardless of the hash
   randomization setting.
 
-- Issue #27691: Fix ssl module's parsing of GEN_RID subject alternative name
+- bpo-27691: Fix ssl module's parsing of GEN_RID subject alternative name
   fields in X.509 certs.
 
-- Issue #27850: Remove 3DES from ssl module's default cipher list to counter
+- bpo-27850: Remove 3DES from ssl module's default cipher list to counter
   measure sweet32 attack (CVE-2016-2183).
 
-- Issue #27766: Add ChaCha20 Poly1305 to ssl module's default ciper list.
+- bpo-27766: Add ChaCha20 Poly1305 to ssl module's default ciper list.
   (Required OpenSSL 1.1.0 or LibreSSL).
 
-- Issue #26470: Port ssl and hashlib module to OpenSSL 1.1.0.
+- bpo-26470: Port ssl and hashlib module to OpenSSL 1.1.0.
 
-- Issue #27944: Fix some memory-corruption bugs in the log reading code of the
+- bpo-27944: Fix some memory-corruption bugs in the log reading code of the
   _hotshot module.
 
-- Issue #27934: Use ``float.__repr__`` instead of plain ``repr`` when JSON-
+- bpo-27934: Use ``float.__repr__`` instead of plain ``repr`` when JSON-
   encoding an instance of a float subclass. Thanks Eddie James.
 
-- Issue #27861: Fixed a crash in sqlite3.Connection.cursor() when a factory
+- bpo-27861: Fixed a crash in sqlite3.Connection.cursor() when a factory
   creates not a cursor.  Patch by Xiang Zhang.
 
-- Issue #19884: Avoid spurious output on OS X with Gnu Readline.
+- bpo-19884: Avoid spurious output on OS X with Gnu Readline.
 
-- Issue #10513: Fix a regression in Connection.commit().  Statements should
-  not be reset after a commit.
+- bpo-10513: Fix a regression in Connection.commit().  Statements should not
+  be reset after a commit.
 
-- Issue #2466: posixpath.ismount now correctly recognizes mount points which
+- bpo-2466: posixpath.ismount now correctly recognizes mount points which
   the user does not have permission to access.
 
-- Issue #27783: Fix possible usage of uninitialized memory in operator.methodcaller.
+- bpo-27783: Fix possible usage of uninitialized memory in
+  operator.methodcaller.
 
-- Issue #27774: Fix possible Py_DECREF on unowned object in _sre.
+- bpo-27774: Fix possible Py_DECREF on unowned object in _sre.
 
-- Issue #27760: Fix possible integer overflow in binascii.b2a_qp.
+- bpo-27760: Fix possible integer overflow in binascii.b2a_qp.
 
-- In the curses module, raise an error if window.getstr() or window.instr() is
-  passed a negative value.
+- In the curses module, raise an error if window.getstr() or window.instr()
+  is passed a negative value.
 
-- Issue #27758: Fix possible integer overflow in the _csv module for large record
-  lengths.
+- bpo-27758: Fix possible integer overflow in the _csv module for large
+  record lengths.
 
-- Issue #23369: Fixed possible integer overflow in
+- bpo-23369: Fixed possible integer overflow in
   _json.encode_basestring_ascii.
 
-- Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the
-  HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates
-  that the script is in CGI mode.
+- bpo-27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the
+  HTTP_PROXY variable when REQUEST_METHOD environment is set, which
+  indicates that the script is in CGI mode.
 
-- Issue #27130: In the "zlib" module, fix handling of large buffers
-  (typically 2 or 4 GiB).  Previously, inputs were limited to 2 GiB, and
-  compression and decompression operations did not properly handle results of
-  2 or 4 GiB.
+- bpo-27130: In the "zlib" module, fix handling of large buffers (typically
+  2 or 4 GiB). Previously, inputs were limited to 2 GiB, and compression and
+  decompression operations did not properly handle results of 2 or 4 GiB.
 
-- Issue #23804: Fix SSL zero-length recv() calls to not block and not raise
-  an error about unclean EOF.
+- bpo-23804: Fix SSL zero-length recv() calls to not block and not raise an
+  error about unclean EOF.
 
-- Issue #27466: Change time format returned by http.cookie.time2netscape,
+- bpo-27466: Change time format returned by http.cookie.time2netscape,
   confirming the netscape cookie format and making it consistent with
   documentation.
 
-- Issue #22115: Fixed tracing Tkinter variables: trace_vdelete() with wrong
+- bpo-22115: Fixed tracing Tkinter variables: trace_vdelete() with wrong
   mode no longer break tracing, trace_vinfo() now always returns a list of
   pairs of strings.
 
-- Issue #27079: Fixed curses.ascii functions isblank(), iscntrl() and ispunct().
+- bpo-27079: Fixed curses.ascii functions isblank(), iscntrl() and
+  ispunct().
 
-- Issue #22636: Avoid shell injection problems with
-  ctypes.util.find_library().
+- bpo-22636: Avoid shell injection problems with ctypes.util.find_library().
 
-- Issue #27330: Fixed possible leaks in the ctypes module.
+- bpo-27330: Fixed possible leaks in the ctypes module.
 
-- Issue #27238: Got rid of bare excepts in the turtle module.  Original patch
+- bpo-27238: Got rid of bare excepts in the turtle module.  Original patch
   by Jelle Zijlstra.
 
-- Issue #26386: Fixed ttk.TreeView selection operations with item id's
+- bpo-26386: Fixed ttk.TreeView selection operations with item id's
   containing spaces.
 
-- Issue #25455: Fixed a crash in repr of cElementTree.Element with recursive tag.
+- bpo-25455: Fixed a crash in repr of cElementTree.Element with recursive
+  tag.
 
-- Issue #21201: Improves readability of multiprocessing error message.  Thanks
+- bpo-21201: Improves readability of multiprocessing error message.  Thanks
   to Wojciech Walczak for patch.
 
 IDLE
 ----
 
-- Issue #27854: Make Help => IDLE Help work again on Windows.
-  Include idlelib/help.html in 2.7 Windows installer.
+- bpo-27854: Make Help => IDLE Help work again on Windows. Include
+  idlelib/help.html in 2.7 Windows installer.
 
-- Issue #25507: Add back import needed for 2.x encoding warning box.
-  Add pointer to 'Encoding declaration' in Language Reference.
+- bpo-25507: Add back import needed for 2.x encoding warning box. Add
+  pointer to 'Encoding declaration' in Language Reference.
 
-- Issue #15308: Add 'interrupt execution' (^C) to Shell menu.
-  Patch by Roger Serwy, updated by Bayard Randel.
+- bpo-15308: Add 'interrupt execution' (^C) to Shell menu. Patch by Roger
+  Serwy, updated by Bayard Randel.
 
-- Issue #27922: Stop IDLE tests from 'flashing' gui widgets on the screen.
+- bpo-27922: Stop IDLE tests from 'flashing' gui widgets on the screen.
 
-- Issue #17642: add larger font sizes for classroom projection.
+- bpo-17642: add larger font sizes for classroom projection.
 
 - Add version to title of IDLE help window.
 
-- Issue #25564: In section on IDLE -- console differences, mention that
-  using exec means that __builtins__ is defined for each statement.
+- bpo-25564: In section on IDLE -- console differences, mention that using
+  exec means that __builtins__ is defined for each statement.
 
-- Issue #27714: text_textview and test_autocomplete now pass when re-run
-  in the same process.  This occurs when test_idle fails when run with the
-  -w option but without -jn.  Fix warning from test_config.
+- bpo-27714: text_textview and test_autocomplete now pass when re-run in the
+  same process.  This occurs when test_idle fails when run with the -w
+  option but without -jn.  Fix warning from test_config.
 
-- Issue #27452: add line counter and crc to IDLE configHandler test dump.
+- bpo-27452: add line counter and crc to IDLE configHandler test dump.
 
-- Issue #27365: Allow non-ascii chars in IDLE NEWS.txt, for contributor names.
+- bpo-27365: Allow non-ascii chars in IDLE NEWS.txt, for contributor names.
 
-- Issue #27245: IDLE: Cleanly delete custom themes and key bindings.
+- bpo-27245: IDLE: Cleanly delete custom themes and key bindings.
   Previously, when IDLE was started from a console or by import, a cascade
-  of warnings was emitted.  Patch by Serhiy Storchaka.
+  of warnings was emitted. Patch by Serhiy Storchaka.
 
 Documentation
 -------------
 
-- Issue #28513: Documented command-line interface of zipfile.
+- bpo-28513: Documented command-line interface of zipfile.
 
-- Issue #16484: Change the default PYTHONDOCS URL to "https:", and fix the
+- bpo-16484: Change the default PYTHONDOCS URL to "https:", and fix the
   resulting links to use lowercase.  Patch by Sean Rodman, test by Kaushik
   Nadikuditi.
 
 Tests
 -----
 
-- Issue #28666: Now test.test_support.rmtree is able to remove unwritable or
+- bpo-28666: Now test.test_support.rmtree is able to remove unwritable or
   unreadable directories.
 
-- Issue #23839: Various caches now are cleared before running every test file.
+- bpo-23839: Various caches now are cleared before running every test file.
 
-- Issue #27369: In test_pyexpat, avoid testing an error message detail that
+- bpo-27369: In test_pyexpat, avoid testing an error message detail that
   changed in Expat 2.2.0.
 
 Build
 -----
 
-- Issue #10656: Fix out-of-tree building on AIX.  Patch by Tristan Carel and
+- bpo-10656: Fix out-of-tree building on AIX.  Patch by Tristan Carel and
   Michael Haubenwallner.
 
-- Issue #26359: Rename --with-optimiations to --enable-optimizations.
+- bpo-26359: Rename --with-optimiations to --enable-optimizations.
 
-- Issue #28248: Update Windows build and OS X installers to use OpenSSL 1.0.2j.
+- bpo-28248: Update Windows build and OS X installers to use OpenSSL 1.0.2j.
 
-- Issue #28258: Fixed build with Estonian locale (distclean target in
+- bpo-28258: Fixed build with Estonian locale (distclean target in
   Makefile).  Patch by Arfrever Frehtes Taifersar Arahesis.
 
-- Issue #26661: setup.py now detects system libffi with multiarch wrapper.
+- bpo-26661: setup.py now detects system libffi with multiarch wrapper.
 
-- Issue #15819: The Include directory in the build tree is already searched;
+- bpo-15819: The Include directory in the build tree is already searched;
   drop unused code trying to add it again.
 
-- Issue #27566: Fix clean target in freeze makefile (patch by Lisa Roach)
+- bpo-27566: Fix clean target in freeze makefile (patch by Lisa Roach)
 
-- Issue #27983: Cause lack of llvm-profdata tool when using clang as
-  required for PGO linking to be a configure time error rather than
-  make time when --with-optimizations is enabled.  Also improve our
-  ability to find the llvm-profdata tool on MacOS and some Linuxes.
+- bpo-27983: Cause lack of llvm-profdata tool when using clang as required
+  for PGO linking to be a configure time error rather than make time when
+  --with- optimizations is enabled.  Also improve our ability to find the
+  llvm- profdata tool on MacOS and some Linuxes.
 
-- Issue #26359: Add the --with-optimizations configure flag.
+- bpo-26359: Add the --with-optimizations configure flag.
 
-- Issue #10910: Avoid C++ compilation errors on FreeBSD and OS X.
-  Also update FreedBSD version checks for the original ctype UTF-8 workaround.
+- bpo-10910: Avoid C++ compilation errors on FreeBSD and OS X. Also update
+  FreedBSD version checks for the original ctype UTF-8 workaround.
 
-- Issue #27806: Fix 32-bit builds on macOS Sierra 10.12 broken by removal of
+- bpo-27806: Fix 32-bit builds on macOS Sierra 10.12 broken by removal of
   deprecated QuickTime/QuickTime.h header file.  Patch by Aleks Bunin.
 
-- Issue #28676: Prevent missing 'getentropy' declaration warning on macOS.
+- bpo-28676: Prevent missing 'getentropy' declaration warning on macOS.
   Initial patch by Gareth Rees.
 
 Tools/Demos
 -----------
 
-- Issue #27952: Get Tools/scripts/fixcid.py working with the current "re"
+- bpo-27952: Get Tools/scripts/fixcid.py working with the current "re"
   module, avoid invalid Python backslash escapes, and fix a bug parsing
   escaped C quote signs.
 
 Windows
 -------
 
-- Issue #27932: Prevent memory leak in win32_ver().
+- bpo-27932: Prevent memory leak in win32_ver().
 
-- Issue #27888: Prevent Windows installer from displaying console windows and
+- bpo-27888: Prevent Windows installer from displaying console windows and
   failing when pip cannot be installed/uninstalled.
 
-Mac OS X
---------
+macOS
+-----
 
-- Issue #28440: No longer add /Library/Python/site-packages, the Apple-supplied
-  system Python site-packages directory, to sys.path for macOS framework builds.
-  The coupling between the two Python instances often caused confusion and, as
-  of macOS 10.12, changes to the site-packages layout can cause pip component
-  installations to fail.  This change reverts the effects introduced in 2.7.0
-  by Issue #4865.  If you are using a package with both the Apple system Python
-  2.7 and a user-installed Python 2.7, you will need to ensure that copies of
-  the package are installed with both Python instances.
+- bpo-28440: No longer add /Library/Python/site-packages, the Apple-supplied
+  system Python site-packages directory, to sys.path for macOS framework
+  builds. The coupling between the two Python instances often caused
+  confusion and, as of macOS 10.12, changes to the site-packages layout can
+  cause pip component installations to fail.  This change reverts the
+  effects introduced in 2.7.0 by Issue #4865.  If you are using a package
+  with both the Apple system Python 2.7 and a user-installed Python 2.7, you
+  will need to ensure that copies of the package are installed with both
+  Python instances.
 
 
-What's New in Python 2.7.12?
-============================
+What's New in Python 2.7.12 final?
+==================================
 
 *Release date: 2016-06-25*
 
 Build
 -----
 
-- Issue #27641: The configure script now inserts comments into the makefile
-  to prevent the pgen executable from being cross-compiled.
+- bpo-27641: The configure script now inserts comments into the makefile to
+  prevent the pgen executable from being cross-compiled.
 
-- Issue #26930: Update Windows builds to use OpenSSL 1.0.2h.
+- bpo-26930: Update Windows builds to use OpenSSL 1.0.2h.
 
 IDLE
 ----
 
-- Issue #27365: Fix about dialog.
+- bpo-27365: Fix about dialog.
 
 
 What's New in Python 2.7.12 release candidate 1?
@@ -666,314 +1084,316 @@ What's New in Python 2.7.12 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #20041: Fixed TypeError when frame.f_trace is set to None.
-  Patch by Xavier de Gaye.
+- bpo-20041: Fixed TypeError when frame.f_trace is set to None. Patch by
+  Xavier de Gaye.
 
-- Issue #25702: A --with-lto configure option has been added that will
-  enable link time optimizations at build time during a make profile-opt.
-  Some compilers and toolchains are known to not produce stable code when
-  using LTO, be sure to test things thoroughly before relying on it.
-  It can provide a few % speed up over profile-opt alone.
+- bpo-25702: A --with-lto configure option has been added that will enable
+  link time optimizations at build time during a make profile-opt. Some
+  compilers and toolchains are known to not produce stable code when using
+  LTO, be sure to test things thoroughly before relying on it. It can
+  provide a few % speed up over profile-opt alone.
 
-- Issue #26168: Fixed possible refleaks in failing Py_BuildValue() with the "N"
+- bpo-26168: Fixed possible refleaks in failing Py_BuildValue() with the "N"
   format unit.
 
-- Issue #27039: Fixed bytearray.remove() for values greater than 127.  Patch by
+- bpo-27039: Fixed bytearray.remove() for values greater than 127.  Patch by
   Joe Jevnik.
 
-- Issue #4806: Avoid masking the original TypeError exception when using star
+- bpo-4806: Avoid masking the original TypeError exception when using star
   (*) unpacking and the exception was raised from a generator.  Based on
   patch by Hagen Fürstenau.
 
-- Issue #26659: Make the builtin slice type support cycle collection.
+- bpo-26659: Make the builtin slice type support cycle collection.
 
-- Issue #26718: super.__init__ no longer leaks memory if called multiple times.
+- bpo-26718: super.__init__ no longer leaks memory if called multiple times.
   NOTE: A direct call of super.__init__ is not endorsed!
 
-- Issue #13410: Fixed a bug in PyUnicode_Format where it failed to properly
+- bpo-13410: Fixed a bug in PyUnicode_Format where it failed to properly
   ignore errors from a __int__() method.
 
-- Issue #26494: Fixed crash on iterating exhausting iterators.
-  Affected classes are generic sequence iterators, iterators of bytearray,
-  list, tuple, set, frozenset, dict, OrderedDict and corresponding views.
+- bpo-26494: Fixed crash on iterating exhausting iterators. Affected classes
+  are generic sequence iterators, iterators of bytearray, list, tuple, set,
+  frozenset, dict, OrderedDict and corresponding views.
 
-- Issue #26581: If coding cookie is specified multiple times on a line in
+- bpo-26581: If coding cookie is specified multiple times on a line in
   Python source code file, only the first one is taken to account.
 
-- Issue #22836: Ensure exception reports from PyErr_Display() and
+- bpo-22836: Ensure exception reports from PyErr_Display() and
   PyErr_WriteUnraisable() are sensible even when formatting them produces
   secondary errors.  This affects the reports produced by
   sys.__excepthook__() and when __del__() raises an exception.
 
-- Issue #22847: Improve method cache efficiency.
+- bpo-22847: Improve method cache efficiency.
 
-- Issue #25843: When compiling code, don't merge constants if they are equal
-  but have a different types. For example, ``f1, f2 = lambda: 1, lambda: 1.0``
-  is now correctly compiled to two different functions: ``f1()`` returns ``1``
-  (``int``) and ``f2()`` returns ``1.0`` (``int``), even if ``1`` and ``1.0``
-  are equal.
+- bpo-25843: When compiling code, don't merge constants if they are equal
+  but have a different types. For example, ``f1, f2 = lambda: 1, lambda:
+  1.0`` is now correctly compiled to two different functions: ``f1()``
+  returns ``1`` (``int``) and ``f2()`` returns ``1.0`` (``int``), even if
+  ``1`` and ``1.0`` are equal.
 
-- Issue #22995: [UPDATE] Remove the one of the pickleability tests in
+- bpo-22995: [UPDATE] Remove the one of the pickleability tests in
   _PyObject_GetState() due to regressions observed in Cython-based projects.
 
-- Issue #25961: Disallowed null characters in the type name.
+- bpo-25961: Disallowed null characters in the type name.
 
-- Issue #22995: Instances of extension types with a state that aren't
+- bpo-22995: Instances of extension types with a state that aren't
   subclasses of list or dict and haven't implemented any pickle-related
-  methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
-  or __getstate__), can no longer be pickled.  Including memoryview.
+  methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, or
+  __getstate__), can no longer be pickled.  Including memoryview.
 
-- Issue #20440: Massive replacing unsafe attribute setting code with special
+- bpo-20440: Massive replacing unsafe attribute setting code with special
   macro Py_SETREF.
 
-- Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
+- bpo-25421: __sizeof__ methods of builtin types now use dynamic basic size.
   This allows sys.getsize() to work correctly with their subclasses with
   __slots__ defined.
 
-- Issue #19543: Added Py3k warning for decoding unicode.
+- bpo-19543: Added Py3k warning for decoding unicode.
 
-- Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
+- bpo-24097: Fixed crash in object.__reduce__() if slot name is freed inside
   __getattr__.
 
-- Issue #24731: Fixed crash on converting objects with special methods
-  __str__, __trunc__, and __float__ returning instances of subclasses of
-  str, long, and float to subclasses of str, long, and float correspondingly.
+- bpo-24731: Fixed crash on converting objects with special methods __str__,
+  __trunc__, and __float__ returning instances of subclasses of str, long,
+  and float to subclasses of str, long, and float correspondingly.
 
-- Issue #26478: Fix semantic bugs when using binary operators with dictionary
+- bpo-26478: Fix semantic bugs when using binary operators with dictionary
   views and tuples.
 
-- Issue #26171: Fix possible integer overflow and heap corruption in
+- bpo-26171: Fix possible integer overflow and heap corruption in
   zipimporter.get_data().
 
 Library
 -------
 
-- Issue #26556: Update expat to 2.1.1, fixes CVE-2015-1283.
+- bpo-26556: Update expat to 2.1.1, fixes CVE-2015-1283.
 
-- Fix TLS stripping vulnerability in smptlib, CVE-2016-0772.  Reported by Team
-  Oststrom
+- Fix TLS stripping vulnerability in smptlib, CVE-2016-0772.  Reported by
+  Team Oststrom
 
-- Issue #7356: ctypes.util: Make parsing of ldconfig output independent of the
+- bpo-7356: ctypes.util: Make parsing of ldconfig output independent of the
   locale.
 
-- Issue #25738: Stop BaseHTTPServer.BaseHTTPRequestHandler.send_error() from
+- bpo-25738: Stop BaseHTTPServer.BaseHTTPRequestHandler.send_error() from
   sending a message body for 205 Reset Content.  Also, don't send the
   Content-Type header field in responses that don't have a body.  Based on
   patch by Susumu Koshiba.
 
-- Issue #21313: Fix the "platform" module to tolerate when sys.version
-  contains truncated build information.
+- bpo-21313: Fix the "platform" module to tolerate when sys.version contains
+  truncated build information.
 
-- Issue #27211: Fix possible memory corruption in io.IOBase.readline().
+- bpo-27211: Fix possible memory corruption in io.IOBase.readline().
 
-- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
+- bpo-27114: Fix SSLContext._load_windows_store_certs fails with
   PermissionError
 
-- Issue #14132: Fix urllib.request redirect handling when the target only has
-  query string.  Fix by Ján Janech.
+- bpo-14132: Fix urllib.request redirect handling when the target only has a
+  query string.  Fix by Ján Janech.
 
 - Removed the requirements for the ctypes and modulefinder modules to be
   compatible with earlier Python versions.
 
-- Issue #22274: In the subprocess module, allow stderr to be redirected to
+- bpo-22274: In the subprocess module, allow stderr to be redirected to
   stdout even when stdout is not redirected.  Patch by Akira Li.
 
-- Issue #12045: Avoid duplicate execution of command in ctypes.util._get_soname().
-  Patch by Sijin Joseph.
+- bpo-12045: Avoid duplicate execution of command in
+  ctypes.util._get_soname(). Patch by Sijin Joseph.
 
-- Issue #26960: Backported #16270 from Python 3 to Python 2, to prevent urllib
+- bpo-26960: Backported #16270 from Python 3 to Python 2, to prevent urllib
   from hanging when retrieving certain FTP files.
 
-- Issue #25745: Fixed leaking a userptr in curses panel destructor.
+- bpo-25745: Fixed leaking a userptr in curses panel destructor.
 
-- Issue #17765: weakref.ref() no longer silently ignores keyword arguments.
+- bpo-17765: weakref.ref() no longer silently ignores keyword arguments.
   Patch by Georg Brandl.
 
-- Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags
+- bpo-26873: xmlrpclib now raises ResponseError on unsupported type tags
   instead of silently return incorrect result.
 
-- Issue #24114: Fix an uninitialized variable in `ctypes.util`.
+- bpo-24114: Fix an uninitialized variable in `ctypes.util`.
 
-  The bug only occurs on SunOS when the ctypes implementation searches
-  for the `crle` program.  Patch by Xiang Zhang.  Tested on SunOS by
-  Kees Bos.
+  The bug only occurs on SunOS when the ctypes implementation searches for
+  the `crle` program.  Patch by Xiang Zhang.  Tested on SunOS by Kees Bos.
 
-- Issue #26864: In urllib, change the proxy bypass host checking against
-  no_proxy to be case-insensitive, and to not match unrelated host names that
-  happen to have a bypassed hostname as a suffix.  Patch by Xiang Zhang.
+- bpo-26864: In urllib, change the proxy bypass host checking against
+  no_proxy to be case-insensitive, and to not match unrelated host names
+  that happen to have a bypassed hostname as a suffix.  Patch by Xiang
+  Zhang.
 
-- Issue #26804: urllib will prefer lower_case proxy environment variables over
+- bpo-26804: urllib will prefer lower_case proxy environment variables over
   UPPER_CASE or Mixed_Case ones. Patch contributed by Hans-Peter Jansen.
 
-- Issue #26837: assertSequenceEqual() now correctly outputs non-stringified
-  differing items.  This affects assertListEqual() and assertTupleEqual().
+- bpo-26837: assertSequenceEqual() now correctly outputs non-stringified
+  differing items. This affects assertListEqual() and assertTupleEqual().
 
-- Issue #26822: itemgetter, attrgetter and methodcaller objects no longer
+- bpo-26822: itemgetter, attrgetter and methodcaller objects no longer
   silently ignore keyword arguments.
 
-- Issue #26657: Fix directory traversal vulnerability with SimpleHTTPServer
-  on Windows.  This fixes a regression that was introduced in 2.7.7.  Based
-  on patch by Philipp Hagemeister.
+- bpo-26657: Fix directory traversal vulnerability with SimpleHTTPServer on
+  Windows. This fixes a regression that was introduced in 2.7.7.  Based on
+  patch by Philipp Hagemeister.
 
-- Issue #19377: Add .svg to mimetypes.types_map.
+- bpo-19377: Add .svg to mimetypes.types_map.
 
-- Issue #13952: Add .csv to mimetypes.types_map.  Patch by Geoff Wilson.
+- bpo-13952: Add .csv to mimetypes.types_map.  Patch by Geoff Wilson.
 
-- Issue #16329: Add .webm to mimetypes.types_map.  Patch by Giampaolo Rodola'.
+- bpo-16329: Add .webm to mimetypes.types_map.  Patch by Giampaolo Rodola'.
 
-- Issue #23735: Handle terminal resizing with Readline 6.3+ by installing our
+- bpo-23735: Handle terminal resizing with Readline 6.3+ by installing our
   own SIGWINCH handler.  Patch by Eric Price.
 
-- Issue #26644: Raise ValueError rather than SystemError when a negative
-  length is passed to SSLSocket.recv() or read().
+- bpo-26644: Raise ValueError rather than SystemError when a negative length
+  is passed to SSLSocket.recv() or read().
 
-- Issue #23804: Fix SSL recv(0) and read(0) methods to return zero bytes
+- bpo-23804: Fix SSL recv(0) and read(0) methods to return zero bytes
   instead of up to 1024.
 
-- Issue #24266: Ctrl+C during Readline history search now cancels the search
+- bpo-24266: Ctrl+C during Readline history search now cancels the search
   mode when compiled with Readline 7.
 
-- Issue #23857: Implement PEP 493, adding a Python-2-only ssl module API and
-  environment variable to configure the default handling of SSL/TLS certificates
-  for HTTPS connections.
+- bpo-23857: Implement PEP 493, adding a Python-2-only ssl module API and
+  environment variable to configure the default handling of SSL/TLS
+  certificates for HTTPS connections.
 
-- Issue #26313: ssl.py _load_windows_store_certs fails if windows cert store
-  is empty. Patch by Baji.
+- bpo-26313: ssl.py _load_windows_store_certs fails if windows cert store is
+  empty. Patch by Baji.
 
-- Issue #26513: Fixes platform module detection of Windows Server
+- bpo-26513: Fixes platform module detection of Windows Server
 
-- Issue #23718: Fixed parsing time in week 0 before Jan 1.  Original patch by
+- bpo-23718: Fixed parsing time in week 0 before Jan 1.  Original patch by
   Tamás Bence Gedai.
 
-- Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
+- bpo-26177: Fixed the keys() method for Canvas and Scrollbar widgets.
 
-- Issue #15068: Got rid of excessive buffering in the fileinput module.
-  The bufsize parameter is no longer used.
+- bpo-15068: Got rid of excessive buffering in the fileinput module. The
+  bufsize parameter is no longer used.
 
-- Issue #2202: Fix UnboundLocalError in
-  AbstractDigestAuthHandler.get_algorithm_impls.  Initial patch by Mathieu Dupuy.
+- bpo-2202: Fix UnboundLocalError in
+  AbstractDigestAuthHandler.get_algorithm_impls. Initial patch by Mathieu
+  Dupuy.
 
-- Issue #26475: Fixed debugging output for regular expressions with the (?x)
+- bpo-26475: Fixed debugging output for regular expressions with the (?x)
   flag.
 
-- Issue #26385: Remove the file if the internal fdopen() call in
-  NamedTemporaryFile() fails.  Based on patch by Silent Ghost.
+- bpo-26385: Remove the file if the internal fdopen() call in
+  NamedTemporaryFile() fails. Based on patch by Silent Ghost.
 
-- Issue #26309: In the "SocketServer" module, shut down the request (closing
+- bpo-26309: In the "SocketServer" module, shut down the request (closing
   the connected socket) when verify_request() returns false.  Based on patch
   by Aviv Palivoda.
 
-- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates.
+- bpo-25939: On Windows open the cert store readonly in
+  ssl.enum_certificates.
 
-- Issue #24303: Fix random EEXIST upon multiprocessing semaphores creation with
+- bpo-24303: Fix random EEXIST upon multiprocessing semaphores creation with
   Linux PID namespaces enabled.
 
-- Issue #25698: Importing module if the stack is too deep no longer replaces
+- bpo-25698: Importing module if the stack is too deep no longer replaces
   imported module with the empty one.
 
-- Issue #12923: Reset FancyURLopener's redirect counter even if there is an
-  exception.  Based on patches by Brian Brazil and Daniel Rocco.
+- bpo-12923: Reset FancyURLopener's redirect counter even if there is an
+  exception. Based on patches by Brian Brazil and Daniel Rocco.
 
-- Issue #25945: Fixed a crash when unpickle the functools.partial object with
-  wrong state.  Fixed a leak in failed functools.partial constructor.
-  "args" and "keywords" attributes of functools.partial have now always types
-  tuple and dict correspondingly.
+- bpo-25945: Fixed a crash when unpickle the functools.partial object with
+  wrong state. Fixed a leak in failed functools.partial constructor. "args"
+  and "keywords" attributes of functools.partial have now always types tuple
+  and dict correspondingly.
 
-- Issue #19883: Fixed possible integer overflows in zipimport.
+- bpo-19883: Fixed possible integer overflows in zipimport.
 
-- Issue #26147: xmlrpclib now works with unicode not encodable with used
-  non-UTF-8 encoding.
+- bpo-26147: xmlrpclib now works with unicode not encodable with used non-
+  UTF-8 encoding.
 
-- Issue #16620: Fixed AttributeError in msilib.Directory.glob().
+- bpo-16620: Fixed AttributeError in msilib.Directory.glob().
 
-- Issue #21847: Fixed xmlrpclib on Unicode-disabled builds.
+- bpo-21847: Fixed xmlrpclib on Unicode-disabled builds.
 
-- Issue #6500: Fixed infinite recursion in urllib2.Request.__getattr__().
+- bpo-6500: Fixed infinite recursion in urllib2.Request.__getattr__().
 
-- Issue #26083: Workaround a subprocess bug that raises an incorrect
+- bpo-26083: Workaround a subprocess bug that raises an incorrect
   "ValueError: insecure string pickle" exception instead of the actual
-  exception on some platforms such as Mac OS X when an exception raised
-  in the forked child process prior to the exec() was large enough that
-  it overflowed the internal errpipe_read pipe buffer.
+  exception on some platforms such as Mac OS X when an exception raised in
+  the forked child process prior to the exec() was large enough that it
+  overflowed the internal errpipe_read pipe buffer.
 
-- Issue #24103: Fixed possible use after free in ElementTree.iterparse().
+- bpo-24103: Fixed possible use after free in ElementTree.iterparse().
 
-- Issue #20954: _args_from_interpreter_flags used by multiprocessing and some
+- bpo-20954: _args_from_interpreter_flags used by multiprocessing and some
   tests no longer behaves incorrectly in the presence of the PYTHONHASHSEED
   environment variable.
 
-- Issue #14285: When executing a package with the "python -m package" option,
+- bpo-14285: When executing a package with the "python -m package" option,
   and package initialization raises ImportError, a proper traceback is now
   reported.
 
-- Issue #6478: _strptime's regexp cache now is reset after changing timezone
+- bpo-6478: _strptime's regexp cache now is reset after changing timezone
   with time.tzset().
 
-- Issue #25718: Fixed copying object with state with boolean value is false.
+- bpo-25718: Fixed copying object with state with boolean value is false.
 
-- Issue #25742: :func:`locale.setlocale` now accepts a Unicode string for
-  its second parameter.
+- bpo-25742: :func:`locale.setlocale` now accepts a Unicode string for its
+  second parameter.
 
-- Issue #10131: Fixed deep copying of minidom documents.  Based on patch
-  by Marian Ganisin.
+- bpo-10131: Fixed deep copying of minidom documents.  Based on patch by
+  Marian Ganisin.
 
-- Issue #25725: Fixed a reference leak in cPickle.loads() when unpickling
+- bpo-25725: Fixed a reference leak in cPickle.loads() when unpickling
   invalid data including tuple instructions.
 
-- Issue #25663: In the Readline completer, avoid listing duplicate global
+- bpo-25663: In the Readline completer, avoid listing duplicate global
   names, and search the global namespace before searching builtins.
 
-- Issue #25688: Fixed file leak in ElementTree.iterparse() raising an error.
+- bpo-25688: Fixed file leak in ElementTree.iterparse() raising an error.
 
-- Issue #23914: Fixed SystemError raised by CPickle unpickler on broken data.
+- bpo-23914: Fixed SystemError raised by CPickle unpickler on broken data.
 
-- Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on
-  OS X versions 10.5 or higher.  Original patch by A. Jesse Jiryu Davis.
+- bpo-25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X
+  versions 10.5 or higher.  Original patch by A. Jesse Jiryu Davis.
 
-- Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on
+- bpo-26406: Avoid unnecessary serialization of getaddrinfo(3) calls on
   current versions of OpenBSD and NetBSD.  Patch by A. Jesse Jiryu Davis.
 
 IDLE
 ----
 
-- Issue #5124: Paste with text selected now replaces the selection on X11.
-  This matches how paste works on Windows, Mac, most modern Linux apps,
-  and ttk widgets.  Original patch by Serhiy Storchaka.
+- bpo-5124: Paste with text selected now replaces the selection on X11. This
+  matches how paste works on Windows, Mac, most modern Linux apps, and ttk
+  widgets. Original patch by Serhiy Storchaka.
 
-- Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory
-  is a private implementation of test.test_idle and tool for maintainers.
+- bpo-24759: Make clear in idlelib.idle_test.__init__ that the directory is
+  a private implementation of test.test_idle and tool for maintainers.
 
-- Issue #26673: When tk reports font size as 0, change to size 10.
-  Such fonts on Linux prevented the configuration dialog from opening.
+- bpo-26673: When tk reports font size as 0, change to size 10. Such fonts
+  on Linux prevented the configuration dialog from opening.
 
-- Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
+- bpo-27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
 
-- In the 'IDLE-console differences' section of the IDLE doc, clarify
-  how running with IDLE affects sys.modules and the standard streams.
+- In the 'IDLE-console differences' section of the IDLE doc, clarify how
+  running with IDLE affects sys.modules and the standard streams.
 
-- Issue #25507: fix incorrect change in IOBinding that prevented printing.
+- bpo-25507: fix incorrect change in IOBinding that prevented printing.
   Change also prevented saving shell window with non-ascii characters.
   Augment IOBinding htest to include all major IOBinding functions.
 
-- Issue #25905: Revert unwanted conversion of ' to ’ RIGHT SINGLE QUOTATION
-  MARK in README.txt and open this and NEWS.txt with 'ascii'.
-  Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'.
+- bpo-25905: Revert unwanted conversion of ' to ’ RIGHT SINGLE QUOTATION
+  MARK in README.txt and open this and NEWS.txt with 'ascii'. Re-encode
+  CREDITS.txt to utf-8 and open it with 'utf-8'.
 
-- Issue #26417: Prevent spurious errors and incorrect defaults when
-  installing IDLE 2.7 on OS X: default configuration settings are
-  no longer installed from OS X specific copies.
+- bpo-26417: Prevent spurious errors and incorrect defaults when installing
+  IDLE 2.7 on OS X: default configuration settings are no longer installed
+  from OS X specific copies.
 
 Documentation
 -------------
 
-- Issue #26736: Used HTTPS for external links in the documentation if possible.
+- bpo-26736: Used HTTPS for external links in the documentation if possible.
 
-- Issue #6953: Rework the Readline module documentation to group related
+- bpo-6953: Rework the Readline module documentation to group related
   functions together, and add more details such as what underlying Readline
   functions and variables are accessed.
 
-- Issue #26014: Guide users to the newer packaging documentation as was done
-  for Python 3.x.  In particular, the top-level 2.7 documentation page now
+- bpo-26014: Guide users to the newer packaging documentation as was done
+  for Python 3.x. In particular, the top-level 2.7 documentation page now
   links to the newer installer and distributions pages rather than the
   legacy install and Distutils pages; these are still linked to in the
   library/distutils doc page.
@@ -981,91 +1401,90 @@ Documentation
 Tests
 -----
 
-- Issue #21916: Added tests for the turtle module.  Patch by ingrid,
-  Gregory Loyse and Jelle Zijlstra.
+- bpo-21916: Added tests for the turtle module.  Patch by ingrid, Gregory
+  Loyse and Jelle Zijlstra.
 
-- Issue #25940: Changed test_ssl to use self-signed.pythontest.net.  This
+- bpo-25940: Changed test_ssl to use self-signed.pythontest.net.  This
   avoids relying on svn.python.org, which recently changed root certificate.
 
-- Issue #25616: Tests for OrderedDict are extracted from test_collections
-  into separate file test_ordered_dict.
+- bpo-25616: Tests for OrderedDict are extracted from test_collections into
+  separate file test_ordered_dict.
 
 Build
 -----
 
-- Issue #22359: Avoid incorrect recursive $(MAKE), and disable the rules for
+- bpo-22359: Avoid incorrect recursive $(MAKE), and disable the rules for
   running pgen when cross-compiling.  The pgen output is normally saved with
-  the source code anyway, and is still regenerated when doing a native build.
-  Patch by Jonas Wagner and Xavier de Gaye.
+  the source code anyway, and is still regenerated when doing a native
+  build. Patch by Jonas Wagner and Xavier de Gaye.
 
-- Issue #19450: Update Windows builds to use SQLite 3.8.11.0.
+- bpo-19450: Update Windows builds to use SQLite 3.8.11.0.
 
-- Issue #27229: Fix the cross-compiling pgen rule for in-tree builds.  Patch
-  by Xavier de Gaye.
+- bpo-27229: Fix the cross-compiling pgen rule for in-tree builds.  Patch by
+  Xavier de Gaye.
 
-- Issue #17603: Avoid error about nonexistant fileblocks.o file by using a
+- bpo-17603: Avoid error about nonexistant fileblocks.o file by using a
   lower-level check for st_blocks in struct stat.
 
-- Issue #26465: Update Windows builds to use OpenSSL 1.0.2g.
+- bpo-26465: Update Windows builds to use OpenSSL 1.0.2g.
 
-- Issue #24421: Compile Modules/_math.c once, before building extensions.
+- bpo-24421: Compile Modules/_math.c once, before building extensions.
   Previously it could fail to compile properly if the math and cmath builds
   were concurrent.
 
-- Issue #25824: Fixes sys.winver to not include any architecture suffix.
+- bpo-25824: Fixes sys.winver to not include any architecture suffix.
 
-- Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
+- bpo-25348: Added ``--pgo`` and ``--pgo-job`` arguments to
   ``PCbuild\build.bat`` for building with Profile-Guided Optimization.  The
   old ``PCbuild\build_pgo.bat`` script is now deprecated, and simply calls
   ``PCbuild\build.bat --pgo %*``.
 
-- Issue #25827: Add support for building with ICC to ``configure``, including
-  new ``--with-icc`` flag.
+- bpo-25827: Add support for building with ICC to ``configure``, including a
+  new ``--with-icc`` flag.
 
-- Issue #25696: Fix installation of Python on UNIX with make -j9.
+- bpo-25696: Fix installation of Python on UNIX with make -j9.
 
-- Issue #26930: Update OS X 10.5+ 32-bit-only installer to build
-  and link with OpenSSL 1.0.2h.
+- bpo-26930: Update OS X 10.5+ 32-bit-only installer to build and link with
+  OpenSSL 1.0.2h.
 
-- Issue #26268: Update Windows builds to use OpenSSL 1.0.2f.
+- bpo-26268: Update Windows builds to use OpenSSL 1.0.2f.
 
-- Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries.
+- bpo-25136: Support Apple Xcode 7's new textual SDK stub libraries.
 
 Tools/Demos
 -----------
 
-- Issue #26799: Fix python-gdb.py: don't get C types once when the Python code
-  is loaded, but get C types on demand. The C types can change if
-  python-gdb.py is loaded before the Python executable. Patch written by Thomas
+- bpo-26799: Fix python-gdb.py: don't get C types once when the Python code
+  is loaded, but get C types on demand. The C types can change if python-
+  gdb.py is loaded before the Python executable. Patch written by Thomas
   Ilsche.
 
 C API
 -----
 
-- bpo-30255: PySlice_GetIndicesEx now clips the step to
-  [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] instead of
-  [-PY_SSIZE_T_MAX-1, PY_SSIZE_T_MAX].  This makes it safe to do "step = -step"
-  when reversing a slice.
+- bpo-30255: PySlice_GetIndicesEx now clips the step to [-PY_SSIZE_T_MAX,
+  PY_SSIZE_T_MAX] instead of [-PY_SSIZE_T_MAX-1, PY_SSIZE_T_MAX].  This
+  makes it safe to do "step = -step" when reversing a slice.
 
-- Issue #26476: Fixed compilation error when use PyErr_BadInternalCall() in C++.
-  Patch by Jeroen Demeyer.
+- bpo-26476: Fixed compilation error when use PyErr_BadInternalCall() in
+  C++. Patch by Jeroen Demeyer.
 
-Misc
-----
+Windows
+-------
 
-- Issue #17500, and https://github.com/python/pythondotorg/issues/945: Remove
-  unused and outdated icons.
+- bpo-17500: Remove unused and outdated icons. (See also:
+  https://github.com/python/pythondotorg/issues/945)
 
 
-What's New in Python 2.7.11?
-============================
+What's New in Python 2.7.11 final?
+==================================
 
 *Release date: 2015-12-05*
 
 Library
 -------
 
-- Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
+- bpo-25624: ZipFile now always writes a ZIP_STORED header for directory
   entries.  Patch by Dingyuan Wang.
 
 
@@ -1077,355 +1496,357 @@ What's New in Python 2.7.11 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #25678: Avoid buffer overreads when int(), long(), float(), and
+- bpo-25678: Avoid buffer overreads when int(), long(), float(), and
   compile() are passed buffer objects.  These objects are not necessarily
   terminated by a null byte, but the functions assumed they were.
 
-- Issue #25388: Fixed tokenizer hang when processing undecodable source code
+- bpo-25388: Fixed tokenizer hang when processing undecodable source code
   with a null byte.
 
-- Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
+- bpo-22995: Default implementation of __reduce__ and __reduce_ex__ now
   rejects builtin types with not defined __new__.
 
-- Issue #7267: format(int, 'c') now raises OverflowError when the argument is
+- bpo-7267: format(int, 'c') now raises OverflowError when the argument is
   not in range(0, 256).
 
-- Issue #24806: Prevent builtin types that are not allowed to be subclassed from
-  being subclassed through multiple inheritance.
+- bpo-24806: Prevent builtin types that are not allowed to be subclassed
+  from being subclassed through multiple inheritance.
 
-- Issue #24848: Fixed a number of bugs in UTF-7 decoding of misformed data.
+- bpo-24848: Fixed a number of bugs in UTF-7 decoding of misformed data.
 
-- Issue #25003: os.urandom() doesn't use getentropy() on Solaris because
-  getentropy() is blocking, whereas os.urandom() should not block. getentropy()
-  is supported since Solaris 11.3.
+- bpo-25003: os.urandom() doesn't use getentropy() on Solaris because
+  getentropy() is blocking, whereas os.urandom() should not block.
+  getentropy() is supported since Solaris 11.3.
 
-- Issue #21167: NAN operations are now handled correctly when python is
+- bpo-21167: NAN operations are now handled correctly when python is
   compiled with ICC even if -fp-model strict is not specified.
 
-- Issue #24467: Fixed possible buffer over-read in bytearray. The bytearray
-  object now always allocates place for trailing null byte and it's buffer now
-  is always null-terminated.
+- bpo-24467: Fixed possible buffer over-read in bytearray. The bytearray
+  object now always allocates place for trailing null byte and it's buffer
+  now is always null-terminated.
 
-- Issue #19543: encode() and decode() methods and constructors of str,
-  unicode and bytearray classes now emit deprecation warning for known
-  non-text encodings when Python is ran with the -3 option.
+- bpo-19543: encode() and decode() methods and constructors of str, unicode
+  and bytearray classes now emit deprecation warning for known non-text
+  encodings when Python is ran with the -3 option.
 
-- Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),
+- bpo-24115: Update uses of PyObject_IsTrue(), PyObject_Not(),
   PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains()
   to check for and handle errors correctly.
 
-- Issue #4753: On compilers where it is supported, use "computed gotos" for
+- bpo-4753: On compilers where it is supported, use "computed gotos" for
   bytecode dispatch in the interpreter. This improves interpretation
   performance.
 
-- Issue #22939: Fixed integer overflow in iterator object.  Original patch by
+- bpo-22939: Fixed integer overflow in iterator object.  Original patch by
   Clement Rouault.
 
-- Issue #24102: Fixed exception type checking in standard error handlers.
+- bpo-24102: Fixed exception type checking in standard error handlers.
 
 Library
 -------
 
-- Issue #10128: backport issue #10845's mitigation of incompatibilities between
+- bpo-10128: backport issue #10845's mitigation of incompatibilities between
   the multiprocessing module and directory and zipfile execution.
-  Multiprocessing on Windows will now automatically skip rerunning __main__ in
-  spawned processes, rather than failing with AssertionError.
+  Multiprocessing on Windows will now automatically skip rerunning __main__
+  in spawned processes, rather than failing with AssertionError.
 
-- Issue #25578: Fix (another) memory leak in SSLSocket.getpeercer().
+- bpo-25578: Fix (another) memory leak in SSLSocket.getpeercer().
 
-- Issue #25590: In the Readline completer, only call getattr() once per
+- bpo-25590: In the Readline completer, only call getattr() once per
   attribute.
 
-- Issue #25530: Disable the vulnerable SSLv3 protocol by default when creating
+- bpo-25530: Disable the vulnerable SSLv3 protocol by default when creating
   ssl.SSLContext.
 
-- Issue #25569: Fix memory leak in SSLSocket.getpeercert().
+- bpo-25569: Fix memory leak in SSLSocket.getpeercert().
 
-- Issue #7759: Fixed the mhlib module on filesystems that doesn't support
-  link counting for directories.
+- bpo-7759: Fixed the mhlib module on filesystems that doesn't support link
+  counting for directories.
 
-- Issue #892902: Fixed pickling recursive objects.
+- bpo-892902: Fixed pickling recursive objects.
 
-- Issue #18010: Fix the pydoc GUI's search function to handle exceptions
-  from importing packages.
+- bpo-18010: Fix the pydoc GUI's search function to handle exceptions from
+  importing packages.
 
-- Issue #25515: Always use os.urandom as a source of randomness in uuid.uuid4.
+- bpo-25515: Always use os.urandom as a source of randomness in uuid.uuid4.
 
-- Issue #21827: Fixed textwrap.dedent() for the case when largest common
-  whitespace is a substring of smallest leading whitespace.
-  Based on patch by Robert Li.
+- bpo-21827: Fixed textwrap.dedent() for the case when largest common
+  whitespace is a substring of smallest leading whitespace. Based on patch
+  by Robert Li.
 
-- Issue #21709: Fix the logging module to not depend upon __file__ being set
+- bpo-21709: Fix the logging module to not depend upon __file__ being set
   properly to get the filename of its caller from the stack.  This allows it
   to work if run in a frozen or embedded environment where the module's
   .__file__ attribute does not match its code object's .co_filename.
 
-- Issue #25319: When threading.Event is reinitialized, the underlying condition
+- bpo-25319: When threading.Event is reinitialized, the underlying condition
   should use a regular lock rather than a recursive lock.
 
-- Issue #25232: Fix CGIRequestHandler to split the query from the URL at the
+- bpo-25232: Fix CGIRequestHandler to split the query from the URL at the
   first question mark (?) rather than the last. Patch from Xiang Zhang.
 
-- Issue #24657: Prevent CGIRequestHandler from collapsing slashes in the
-  query part of the URL as if it were a path. Patch from Xiang Zhang.
+- bpo-24657: Prevent CGIRequestHandler from collapsing slashes in the query
+  part of the URL as if it were a path. Patch from Xiang Zhang.
 
-- Issue #22958: Constructor and update method of weakref.WeakValueDictionary
+- bpo-22958: Constructor and update method of weakref.WeakValueDictionary
   now accept the self keyword argument.
 
-- Issue #22609: Constructor and the update method of collections.UserDict now
+- bpo-22609: Constructor and the update method of collections.UserDict now
   accept the self keyword argument.
 
-- Issue #25203: Failed readline.set_completer_delims() no longer left the
+- bpo-25203: Failed readline.set_completer_delims() no longer left the
   module in inconsistent state.
 
-- Issue #19143: platform module now reads Windows version from kernel32.dll to
+- bpo-19143: platform module now reads Windows version from kernel32.dll to
   avoid compatibility shims.
 
-- Issue #25135: Make deque_clear() safer by emptying the deque before clearing.
+- bpo-25135: Make deque_clear() safer by emptying the deque before clearing.
   This helps avoid possible reentrancy issues.
 
-- Issue #24684: socket.socket.getaddrinfo() now calls
+- bpo-24684: socket.socket.getaddrinfo() now calls
   PyUnicode_AsEncodedString() instead of calling the encode() method of the
   host, to handle correctly custom unicode string with an encode() method
   which doesn't return a byte string. The encoder of the IDNA codec is now
   called directly instead of calling the encode() method of the string.
 
-- Issue #24982: shutil.make_archive() with the "zip" format now adds entries
+- bpo-24982: shutil.make_archive() with the "zip" format now adds entries
   for directories (including empty directories) in ZIP file.
 
-- Issue #17849: Raise a sensible exception if an invalid response is
-  received for a HTTP tunnel request, as seen with some servers that
-  do not support tunnelling.  Initial patch from Cory Benfield.
+- bpo-17849: Raise a sensible exception if an invalid response is received
+  for a HTTP tunnel request, as seen with some servers that do not support
+  tunnelling. Initial patch from Cory Benfield.
 
-- Issue #16180: Exit pdb if file has syntax error, instead of trapping user
-  in an infinite loop.  Patch by Xavier de Gaye.
+- bpo-16180: Exit pdb if file has syntax error, instead of trapping user in
+  an infinite loop.  Patch by Xavier de Gaye.
 
-- Issue #22812: Fix unittest discovery examples.
-  Patch from Pam McA'Nulty.
+- bpo-22812: Fix unittest discovery examples. Patch from Pam McA'Nulty.
 
-- Issue #24634: Importing uuid should not try to load libc on Windows
+- bpo-24634: Importing uuid should not try to load libc on Windows
 
-- Issue #23652: Make it possible to compile the select module against the
-  libc headers from the Linux Standard Base, which do not include some
-  EPOLL macros.  Initial patch by Matt Frank.
+- bpo-23652: Make it possible to compile the select module against the libc
+  headers from the Linux Standard Base, which do not include some EPOLL
+  macros.  Initial patch by Matt Frank.
 
-- Issue #15138: Speed up base64.urlsafe_b64{en,de}code considerably.
+- bpo-15138: Speed up base64.urlsafe_b64{en,de}code considerably.
 
-- Issue #23319: Fix ctypes.BigEndianStructure, swap correctly bytes. Patch
+- bpo-23319: Fix ctypes.BigEndianStructure, swap correctly bytes. Patch
   written by Matthieu Gautier.
 
-- Issue #23254: Document how to close the TCPServer listening socket.
-  Patch from Martin Panter.
+- bpo-23254: Document how to close the TCPServer listening socket. Patch
+  from Martin Panter.
 
-- Issue #17527: Add PATCH to wsgiref.validator. Patch from Luca Sbardella.
+- bpo-17527: Add PATCH to wsgiref.validator. Patch from Luca Sbardella.
 
-- Issue #24613: Calling array.fromstring() with self is no longer allowed
-  to prevent the use-after-free error.  Patch by John Leitch.
+- bpo-24613: Calling array.fromstring() with self is no longer allowed to
+  prevent the use-after-free error.  Patch by John Leitch.
 
-- Issue #24708: Fix possible integer overflow in strop.replace().
+- bpo-24708: Fix possible integer overflow in strop.replace().
 
-- Issue #24620: Random.setstate() now validates the value of state last element.
+- bpo-24620: Random.setstate() now validates the value of state last
+  element.
 
-- Issue #13938: 2to3 converts StringTypes to a tuple. Patch from Mark Hammond.
+- bpo-13938: 2to3 converts StringTypes to a tuple. Patch from Mark Hammond.
 
-- Issue #24611: Fixed compiling the posix module on non-Windows platforms
+- bpo-24611: Fixed compiling the posix module on non-Windows platforms
   without mknod() or makedev() (e.g. on Unixware).
 
-- Issue #18684: Fixed reading out of the buffer in the re module.
+- bpo-18684: Fixed reading out of the buffer in the re module.
 
-- Issue #24259: tarfile now raises a ReadError if an archive is truncated
+- bpo-24259: tarfile now raises a ReadError if an archive is truncated
   inside a data segment.
 
-- Issue #24514: tarfile now tolerates number fields consisting of only
+- bpo-24514: tarfile now tolerates number fields consisting of only
   whitespace.
 
-- Issue #20387: Restore semantic round-trip correctness in tokenize/untokenize
-  for tab-indented blocks.
+- bpo-20387: Restore semantic round-trip correctness in tokenize/untokenize
+  for tab- indented blocks.
 
-- Issue #24456: Fixed possible buffer over-read in adpcm2lin() and lin2adpcm()
-  functions of the audioop module.  Fixed SystemError when the state is not a
-  tuple.  Fixed possible memory leak.
+- bpo-24456: Fixed possible buffer over-read in adpcm2lin() and lin2adpcm()
+  functions of the audioop module.  Fixed SystemError when the state is not
+  tuple.  Fixed possible memory leak.
 
-- Issue #24481: Fix possible memory corruption with large profiler info strings
+- bpo-24481: Fix possible memory corruption with large profiler info strings
   in hotshot.
 
-- Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
+- bpo-24489: ensure a previously set C errno doesn't disturb cmath.polar().
 
-- Issue #19543: io.TextIOWrapper (and hence io.open()) now uses the internal
+- bpo-19543: io.TextIOWrapper (and hence io.open()) now uses the internal
   codec marking system added to emit deprecation warning for known non-text
-  encodings at stream construction time when Python is ran with the -3 option.
+  encodings at stream construction time when Python is ran with the -3
+  option.
 
-- Issue #24264: Fixed buffer overflow in the imageop module.
+- bpo-24264: Fixed buffer overflow in the imageop module.
 
-- Issue #5633: Fixed timeit when the statement is a string and the setup is not.
+- bpo-5633: Fixed timeit when the statement is a string and the setup is
+  not.
 
-- Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
+- bpo-24326: Fixed audioop.ratecv() with non-default weightB argument.
   Original patch by David Moore.
 
-- Issue #22095: Fixed HTTPConnection.set_tunnel with default port.  The port
+- bpo-22095: Fixed HTTPConnection.set_tunnel with default port.  The port
   value in the host header was set to "None".  Patch by Demian Brecht.
 
-- Issue #24257: Fixed segmentation fault in sqlite3.Row constructor with faked
+- bpo-24257: Fixed segmentation fault in sqlite3.Row constructor with faked
   cursor type.
 
-- Issue #24286: Dict view were not registered with the MappingView abstract
-  base classes.  This caused key and item views in OrderedDict to not be equal
-  to their regular dict counterparts.
+- bpo-24286: Dict view were not registered with the MappingView abstract
+  base classes. This caused key and item views in OrderedDict to not be
+  equal to their regular dict counterparts.
 
-- Issue #22107: tempfile.gettempdir() and tempfile.mkdtemp() now try again
-  when a directory with the chosen name already exists on Windows as well as
-  on Unix.  tempfile.mkstemp() now fails early if parent directory is not
-  valid (not exists or is a file) on Windows.
+- bpo-22107: tempfile.gettempdir() and tempfile.mkdtemp() now try again when
+  a directory with the chosen name already exists on Windows as well as on
+  Unix. tempfile.mkstemp() now fails early if parent directory is not valid
+  (not exists or is a file) on Windows.
 
-- Issue #6598: Increased time precision and random number range in
+- bpo-6598: Increased time precision and random number range in
   email.utils.make_msgid() to strengthen the uniqueness of the message ID.
 
-- Issue #24091: Fixed various crashes in corner cases in cElementTree.
+- bpo-24091: Fixed various crashes in corner cases in cElementTree.
 
-- Issue #15267: HTTPConnection.request() now is compatible with old-style
+- bpo-15267: HTTPConnection.request() now is compatible with old-style
   classes (such as TemporaryFile).  Original patch by Atsuo Ishimoto.
 
-- Issue #20014: array.array() now accepts unicode typecodes.  Based on patch by
+- bpo-20014: array.array() now accepts unicode typecodes.  Based on patch by
   Vajrasky Kok.
 
-- Issue #23637: Showing a warning no longer fails with UnicodeError.
-  Formatting unicode warning in the file with the path containing non-ascii
-  characters no longer fails with UnicodeError.
+- bpo-23637: Showing a warning no longer fails with UnicodeError. Formatting
+  unicode warning in the file with the path containing non-ascii characters
+  no longer fails with UnicodeError.
 
-- Issue #24134: Reverted issue #24134 changes.
+- bpo-24134: Reverted issue #24134 changes.
 
 IDLE
 ----
 
-- Issue #15348: Stop the debugger engine (normally in a user process)
-  before closing the debugger window (running in the IDLE process).
-  This prevents the RuntimeErrors that were being caught and ignored.
+- bpo-15348: Stop the debugger engine (normally in a user process) before
+  closing the debugger window (running in the IDLE process). This prevents
+  the RuntimeErrors that were being caught and ignored.
 
-- Issue #24455: Prevent IDLE from hanging when a) closing the shell while the
+- bpo-24455: Prevent IDLE from hanging when a) closing the shell while the
   debugger is active (15347); b) closing the debugger with the [X] button
-  (15348); and c) activating the debugger when already active (24455).
-  The patch by Mark Roseman does this by making two changes.
-  1. Suspend and resume the gui.interaction method with the tcl vwait
-  mechanism intended for this purpose (instead of root.mainloop & .quit).
-  2. In gui.run, allow any existing interaction to terminate first.
+  (15348); and c) activating the debugger when already active (24455). The
+  patch by Mark Roseman does this by making two changes. 1. Suspend and
+  resume the gui.interaction method with the tcl vwait mechanism intended
+  for this purpose (instead of root.mainloop & .quit). 2. In gui.run, allow
+  any existing interaction to terminate first.
 
 - Change 'The program' to 'Your program' in an IDLE 'kill program?' message
   to make it clearer that the program referred to is the currently running
   user program, not IDLE itself.
 
-- Issue #24750: Improve the appearance of the IDLE editor window status bar.
+- bpo-24750: Improve the appearance of the IDLE editor window status bar.
   Patch by Mark Roseman.
 
-- Issue #25313: Change the handling of new built-in text color themes to better
+- bpo-25313: Change the handling of new built-in text color themes to better
   address the compatibility problem introduced by the addition of IDLE Dark.
   Consistently use the revised idleConf.CurrentTheme everywhere in idlelib.
 
-- Issue #24782: Extension configuration is now a tab in the IDLE Preferences
+- bpo-24782: Extension configuration is now a tab in the IDLE Preferences
   dialog rather than a separate dialog.   The former tabs are now a sorted
   list.  Patch by Mark Roseman.
 
-- Issue #22726: Re-activate the config dialog help button with some content
+- bpo-22726: Re-activate the config dialog help button with some content
   about the other buttons and the new IDLE Dark theme.
 
-- Issue #24820: IDLE now has an 'IDLE Dark' built-in text color theme.
-  It is more or less IDLE Classic inverted, with a cobalt blue background.
-  Strings, comments, keywords, ... are still green, red, orange, ... .
-  To use it with IDLEs released before November 2015, hit the
-  'Save as New Custom Theme' button and enter a new name,
-  such as 'Custom Dark'.  The custom theme will work with any IDLE
-  release, and can be modified.
+- bpo-24820: IDLE now has an 'IDLE Dark' built-in text color theme. It is
+  more or less IDLE Classic inverted, with a cobalt blue background.
+  Strings, comments, keywords, ... are still green, red, orange, ... . To
+  use it with IDLEs released before November 2015, hit the 'Save as New
+  Custom Theme' button and enter a new name, such as 'Custom Dark'.  The
+  custom theme will work with any IDLE release, and can be modified.
 
-- Issue #25224: README.txt is now an idlelib index for IDLE developers and
-  curious users.  The previous user content is now in the IDLE doc chapter.
+- bpo-25224: README.txt is now an idlelib index for IDLE developers and
+  curious users. The previous user content is now in the IDLE doc chapter.
   'IDLE' now means 'Integrated Development and Learning Environment'.
 
-- Issue #24820: Users can now set breakpoint colors in
-  Settings -> Custom Highlighting.  Original patch by Mark Roseman.
+- bpo-24820: Users can now set breakpoint colors in Settings -> Custom
+  Highlighting. Original patch by Mark Roseman.
 
-- Issue #24972: Inactive selection background now matches active selection
+- bpo-24972: Inactive selection background now matches active selection
   background, as configured by users, on all systems.  Found items are now
   always highlighted on Windows.  Initial patch by Mark Roseman.
 
-- Issue #24570: Idle: make calltip and completion boxes appear on Macs
-  affected by a tk regression.  Initial patch by Mark Roseman.
+- bpo-24570: Idle: make calltip and completion boxes appear on Macs affected
+  by a tk regression.  Initial patch by Mark Roseman.
 
-- Issue #24988: Idle ScrolledList context menus (used in debugger)
-  now work on Mac Aqua.  Patch by Mark Roseman.
+- bpo-24988: Idle ScrolledList context menus (used in debugger) now work on
+  Mac Aqua. Patch by Mark Roseman.
 
-- Issue #24801: Make right-click for context menu work on Mac Aqua.
-  Patch by Mark Roseman.
+- bpo-24801: Make right-click for context menu work on Mac Aqua. Patch by
+  Mark Roseman.
 
-- Issue #25173: Associate tkinter messageboxes with a specific widget.
-  For Mac OSX, make them a 'sheet'.  Patch by Mark Roseman.
+- bpo-25173: Associate tkinter messageboxes with a specific widget. For Mac
+  OSX, make them a 'sheet'.  Patch by Mark Roseman.
 
-- Issue #25198: Enhance the initial html viewer now used for Idle Help.
-  * Properly indent fixed-pitch text (patch by Mark Roseman).
-  * Give code snippet a very Sphinx-like light blueish-gray background.
-  * Re-use initial width and height set by users for shell and editor.
-  * When the Table of Contents (TOC) menu is used, put the section header
-  at the top of the screen.
+- bpo-25198: Enhance the initial html viewer now used for Idle Help. *
+  Properly indent fixed-pitch text (patch by Mark Roseman). * Give code
+  snippet a very Sphinx- like light blueish-gray background. * Re-use
+  initial width and height set by users for shell and editor. * When the
+  Table of Contents (TOC) menu is used, put the section header at the top of
+  the screen.
 
-- Issue #25225: Condense and rewrite Idle doc section on text colors.
+- bpo-25225: Condense and rewrite Idle doc section on text colors.
 
-- Issue #21995: Explain some differences between IDLE and console Python.
+- bpo-21995: Explain some differences between IDLE and console Python.
 
-- Issue #22820: Explain need for *print* when running file from Idle editor.
+- bpo-22820: Explain need for *print* when running file from Idle editor.
 
-- Issue #25224: Doc: augment Idle feature list and no-subprocess section.
+- bpo-25224: Doc: augment Idle feature list and no-subprocess section.
 
-- Issue #25219: Update doc for Idle command line options.
-  Some were missing and notes were not correct.
+- bpo-25219: Update doc for Idle command line options. Some were missing and
+  notes were not correct.
 
-- Issue #24861: Most of idlelib is private and subject to change.
-  Use idleib.idle.* to start Idle. See idlelib.__init__.__doc__.
+- bpo-24861: Most of idlelib is private and subject to change. Use
+  idleib.idle.* to start Idle. See idlelib.__init__.__doc__.
 
-- Issue #25199: Idle: add synchronization comments for future maintainers.
+- bpo-25199: Idle: add synchronization comments for future maintainers.
 
-- Issue #16893: Replace help.txt with help.html for Idle doc display.
-  The new idlelib/help.html is rstripped Doc/build/html/library/idle.html.
-  It looks better than help.txt and will better document Idle as released.
-  The tkinter html viewer that works for this file was written by Mark Roseman.
-  The now unused EditorWindow.HelpDialog class and helt.txt file are deprecated.
+- bpo-16893: Replace help.txt with help.html for Idle doc display. The new
+  idlelib/help.html is rstripped Doc/build/html/library/idle.html. It looks
+  better than help.txt and will better document Idle as released. The
+  tkinter html viewer that works for this file was written by Mark Roseman.
+  The now unused EditorWindow.HelpDialog class and helt.txt file are
+  deprecated.
 
-- Issue #24199: Deprecate unused idlelib.idlever with possible removal in 3.6.
+- bpo-24199: Deprecate unused idlelib.idlever with possible removal in 3.6.
 
-- Issue #24790: Remove extraneous code (which also create 2 & 3 conflicts).
+- bpo-24790: Remove extraneous code (which also create 2 & 3 conflicts).
 
-- Issue #23672: Allow Idle to edit and run files with astral chars in name.
+- bpo-23672: Allow Idle to edit and run files with astral chars in name.
   Patch by Mohd Sanad Zaki Rizvi.
 
-- Issue #24745: Idle editor default font. Switch from Courier to
-  platform-sensitive TkFixedFont.  This should not affect current customized
-  font selections.  If there is a problem, edit $HOME/.idlerc/config-main.cfg
-  and remove 'fontxxx' entries from [Editor Window].  Patch by Mark Roseman.
+- bpo-24745: Idle editor default font. Switch from Courier to platform-
+  sensitive TkFixedFont.  This should not affect current customized font
+  selections.  If there is a problem, edit $HOME/.idlerc/config-main.cfg and
+  remove 'fontxxx' entries from [Editor Window].  Patch by Mark Roseman.
 
-- Issue #21192: Idle editor. When a file is run, put its name in the restart bar.
-  Do not print false prompts. Original patch by Adnan Umer.
+- bpo-21192: Idle editor. When a file is run, put its name in the restart
+  bar. Do not print false prompts. Original patch by Adnan Umer.
 
-- Issue #13884: Idle menus. Remove tearoff lines. Patch by Roger Serwy.
+- bpo-13884: Idle menus. Remove tearoff lines. Patch by Roger Serwy.
 
-- Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for
+- bpo-15809: IDLE shell now uses locale encoding instead of Latin1 for
   decoding unicode literals.
 
 Documentation
 -------------
 
-- Issue #24952: Clarify the default size argument of stack_size() in
-  the "threading" and "thread" modules. Patch from Mattip.
+- bpo-24952: Clarify the default size argument of stack_size() in the
+  "threading" and "thread" modules. Patch from Mattip.
 
-- Issue #20769: Improve reload() docs. Patch by Dorian Pula.
+- bpo-20769: Improve reload() docs. Patch by Dorian Pula.
 
-- Issue #23589: Remove duplicate sentence from the FAQ.  Patch by Yongzhi Pan.
+- bpo-23589: Remove duplicate sentence from the FAQ.  Patch by Yongzhi Pan.
 
-- Issue #22155: Add File Handlers subsection with createfilehandler to Tkinter
+- bpo-22155: Add File Handlers subsection with createfilehandler to Tkinter
   doc.  Remove obsolete example from FAQ.  Patch by Martin Panter.
 
 Tests
 -----
 
-- Issue #24751: When running regrtest with the ``-w`` command line option,
-  a test run is no longer marked as a failure if all tests succeed when
-  re-run.
+- bpo-24751: When running regrtest with the ``-w`` command line option, a
+  test run is no longer marked as a failure if all tests succeed when re-
+  run.
 
 - PCbuild\rt.bat now accepts an unlimited number of arguments to pass along
   to regrtest.py.  Previously there was a limit of 9.
@@ -1433,35 +1854,35 @@ Tests
 Build
 -----
 
-- Issue #24915: When doing a PGO build, the test suite is now used instead of
-  pybench; Clang support was also added as part off this work. Initial patch by
-  Alecsandru Patrascu of Intel.
+- bpo-24915: When doing a PGO build, the test suite is now used instead of
+  pybench; Clang support was also added as part off this work. Initial patch
+  by Alecsandru Patrascu of Intel.
 
-- Issue #24986: It is now possible to build Python on Windows without errors
+- bpo-24986: It is now possible to build Python on Windows without errors
   when external libraries are not available.
 
-- Issue #24508: Backported the MSBuild project files from Python 3.5.  The
-  backported files replace the old project files in PCbuild; the old files moved
-  to PC/VS9.0 and remain supported.
+- bpo-24508: Backported the MSBuild project files from Python 3.5.  The
+  backported files replace the old project files in PCbuild; the old files
+  moved to PC/VS9.0 and remain supported.
 
-- Issue #24603: Update Windows builds and OS X 10.5 installer to use OpenSSL
+- bpo-24603: Update Windows builds and OS X 10.5 installer to use OpenSSL
   1.0.2d.
 
 Windows
 -------
 
-- Issue #25022: Removed very outdated PC/example_nt/ directory.
+- bpo-25022: Removed very outdated PC/example_nt/ directory.
 
 
-What's New in Python 2.7.10?
-============================
+What's New in Python 2.7.10 final?
+==================================
 
 *Release date: 2015-05-23*
 
 Library
 -------
 
-- Issue #22931: Allow '[' and ']' in cookie values.
+- bpo-22931: Allow '[' and ']' in cookie values.
 
 
 What's New in Python 2.7.10 release candidate 1?
@@ -1472,323 +1893,324 @@ What's New in Python 2.7.10 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #23971: Fix underestimated presizing in dict.fromkeys().
+- bpo-23971: Fix underestimated presizing in dict.fromkeys().
 
-- Issue #23757: PySequence_Tuple() incorrectly called the concrete list API
+- bpo-23757: PySequence_Tuple() incorrectly called the concrete list API
   when the data was a list subclass.
 
-- Issue #23629: Fix the default __sizeof__ implementation for variable-sized
+- bpo-23629: Fix the default __sizeof__ implementation for variable-sized
   objects.
 
-- Issue #23055: Fixed a buffer overflow in PyUnicode_FromFormatV.  Analysis
-  and fix by Guido Vranken.
+- bpo-23055: Fixed a buffer overflow in PyUnicode_FromFormatV.  Analysis and
+  fix by Guido Vranken.
 
-- Issue #23048: Fix jumping out of an infinite while loop in the pdb.
+- bpo-23048: Fix jumping out of an infinite while loop in the pdb.
 
 Library
 -------
 
 - The keywords attribute of functools.partial is now always a dictionary.
 
-- Issue #20274: When calling a _sqlite.Connection, it now complains if passed
+- bpo-20274: When calling a _sqlite.Connection, it now complains if passed
   any keyword arguments.  Previously it silently ignored them.
 
-- Issue #20274: Remove ignored and erroneous "kwargs" parameters from three
+- bpo-20274: Remove ignored and erroneous "kwargs" parameters from three
   METH_VARARGS methods on _sqlite.Connection.
 
-- Issue #24134: assertRaises() and assertRaisesRegexp() checks are not longer
+- bpo-24134: assertRaises() and assertRaisesRegexp() checks are not longer
   successful if the callable is None.
 
-- Issue #23008: Fixed resolving attributes with boolean value is False in pydoc.
+- bpo-23008: Fixed resolving attributes with boolean value is False in
+  pydoc.
 
-- Issues #24099, #24100, and #24101: Fix use-after-free bug in heapq's siftup
-  and siftdown functions.
+- bpo-24099: Fix use-after-free bug in heapq's siftup and siftdown
+  functions. (See also: bpo-24100, bpo-24101)
 
-- Backport collections.deque fixes from Python 3.5.  Prevents reentrant badness
-  during deletion by deferring the decref until the container has been restored
-  to a consistent state.
+- Backport collections.deque fixes from Python 3.5.  Prevents reentrant
+  badness during deletion by deferring the decref until the container has
+  been restored to a consistent state.
 
-- Issue #23842: os.major(), os.minor() and os.makedev() now support ints again.
+- bpo-23842: os.major(), os.minor() and os.makedev() now support ints again.
 
-- Issue #23811: Add missing newline to the PyCompileError error message.
-  Patch by Alex Shkop.
+- bpo-23811: Add missing newline to the PyCompileError error message. Patch
+  by Alex Shkop.
 
-- Issue #17898: Fix exception in gettext.py when parsing certain plural forms.
+- bpo-17898: Fix exception in gettext.py when parsing certain plural forms.
 
-- Issue #23865: close() methods in multiple modules now are idempotent and more
+- bpo-23865: close() methods in multiple modules now are idempotent and more
   robust at shutdown. If they need to release multiple resources, all are
   released even if errors occur.
 
-- Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP
+- bpo-23881: urllib.ftpwrapper constructor now closes the socket if the FTP
   connection failed.
 
-- Issue #15133: _tkinter.tkapp.getboolean() now supports long and Tcl_Obj and
-  always returns bool.  tkinter.BooleanVar now validates input values (accepted
-  bool, int, long, str, unicode, and Tcl_Obj).  tkinter.BooleanVar.get() now
-  always returns bool.
+- bpo-15133: _tkinter.tkapp.getboolean() now supports long and Tcl_Obj and
+  always returns bool.  tkinter.BooleanVar now validates input values
+  (accepted bool, int, long, str, unicode, and Tcl_Obj).
+  tkinter.BooleanVar.get() now always returns bool.
 
-- Issue #23338: Fixed formatting ctypes error messages on Cygwin.
-  Patch by Makoto Kato.
+- bpo-23338: Fixed formatting ctypes error messages on Cygwin. Patch by
+  Makoto Kato.
 
-- Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and
+- bpo-16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and
   arbitrary precision integers added in Tcl 8.5.
 
-- Issue #23834: Fix socket.sendto(), use the C long type to store the result of
+- bpo-23834: Fix socket.sendto(), use the C long type to store the result of
   sendto() instead of the C int type.
 
-- Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
+- bpo-21526: Tkinter now supports new boolean type in Tcl 8.5.
 
-- Issue #23838: linecache now clears the cache and returns an empty result on
+- bpo-23838: linecache now clears the cache and returns an empty result on
   MemoryError.
 
-- Issue #23742: ntpath.expandvars() no longer loses unbalanced single quotes.
+- bpo-23742: ntpath.expandvars() no longer loses unbalanced single quotes.
 
-- Issue #21802: The reader in BufferedRWPair now is closed even when closing
+- bpo-21802: The reader in BufferedRWPair now is closed even when closing
   writer failed in BufferedRWPair.close().
 
-- Issue #23671: string.Template now allows specifying the "self" parameter as
-  keyword argument.  string.Formatter now allows specifying the "self" and
+- bpo-23671: string.Template now allows specifying the "self" parameter as a
+  keyword argument.  string.Formatter now allows specifying the "self" and
   the "format_string" parameters as keyword arguments.
 
-- Issue #21560: An attempt to write a data of wrong type no longer cause
+- bpo-21560: An attempt to write a data of wrong type no longer cause
   GzipFile corruption.  Original patch by Wolfgang Maier.
 
-- Issue #23647: Increase impalib's MAXLINE to accommodate modern mailbox sizes.
+- bpo-23647: Increase impalib's MAXLINE to accommodate modern mailbox sizes.
 
-- Issue #23539: If body is None, http.client.HTTPConnection.request now sets
-  Content-Length to 0 for PUT, POST, and PATCH headers to avoid 411 errors from
-  some web servers.
+- bpo-23539: If body is None, http.client.HTTPConnection.request now sets
+  Content-Length to 0 for PUT, POST, and PATCH headers to avoid 411 errors
+  from some web servers.
 
-- Issue #23136: _strptime now uniformly handles all days in week 0, including
+- bpo-23136: _strptime now uniformly handles all days in week 0, including
   Dec 30 of previous year.  Based on patch by Jim Carroll.
 
-- Issue #23138: Fixed parsing cookies with absent keys or values in cookiejar.
+- bpo-23138: Fixed parsing cookies with absent keys or values in cookiejar.
   Patch by Demian Brecht.
 
-- Issue #23051: multiprocessing.Pool methods imap() and imap_unordered() now
+- bpo-23051: multiprocessing.Pool methods imap() and imap_unordered() now
   handle exceptions raised by an iterator.  Patch by Alon Diamant and Davin
   Potts.
 
-- Issue #22928: Disabled HTTP header injections in httplib.
-  Original patch by Demian Brecht.
+- bpo-22928: Disabled HTTP header injections in httplib. Original patch by
+  Demian Brecht.
 
-- Issue #23615: Module tarfile is now can be reloaded with imp.reload().
+- bpo-23615: Module tarfile is now can be reloaded with imp.reload().
 
-- Issue #22853: Fixed a deadlock when use multiprocessing.Queue at import time.
+- bpo-22853: Fixed a deadlock when use multiprocessing.Queue at import time.
   Patch by Florian Finkernagel and Davin Potts.
 
-- Issue #23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST
+- bpo-23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST
   flag on certificate stores when it is available.
 
-- Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the
+- bpo-23576: Avoid stalling in SSL reads when EOF has been reached in the
   SSL layer but the underlying connection hasn't been closed.
 
-- Issue #23504: Added an __all__ to the types module.
+- bpo-23504: Added an __all__ to the types module.
 
-- Issue #23458: On POSIX, the file descriptor kept open by os.urandom() is now
+- bpo-23458: On POSIX, the file descriptor kept open by os.urandom() is now
   set to non inheritable
 
-- Issue #22113: struct.pack_into() now supports new buffer protocol (in
+- bpo-22113: struct.pack_into() now supports new buffer protocol (in
   particular accepts writable memoryview).
 
-- Issues #814253, #9179: Warnings now are raised when group references and
-  conditional group references are used in lookbehind assertions in regular
-  expressions.
+- bpo-814253: Warnings now are raised when group references and conditional
+  group references are used in lookbehind assertions in regular expressions.
+  (See also: bpo-9179)
 
-- Issue #23215: Multibyte codecs with custom error handlers that ignores errors
-  consumed too much memory and raised SystemError or MemoryError.
-  Original patch by Aleksi Torhamo.
+- bpo-23215: Multibyte codecs with custom error handlers that ignores errors
+  consumed too much memory and raised SystemError or MemoryError. Original
+  patch by Aleksi Torhamo.
 
-- Issue #5700: io.FileIO() called flush() after closing the file.
-  flush() was not called in close() if closefd=False.
+- bpo-5700: io.FileIO() called flush() after closing the file. flush() was
+  not called in close() if closefd=False.
 
-- Issue #21548: Fix pydoc.synopsis() and pydoc.apropos() on modules with empty
-  docstrings.  Initial patch by Yuyang Guo.
+- bpo-21548: Fix pydoc.synopsis() and pydoc.apropos() on modules with empty
+  docstrings. Initial patch by Yuyang Guo.
 
-- Issue #22885: Fixed arbitrary code execution vulnerability in the dumbdbm
-  module.  Original patch by Claudiu Popa.
+- bpo-22885: Fixed arbitrary code execution vulnerability in the dumbdbm
+  module. Original patch by Claudiu Popa.
 
-- Issue #23481: Remove RC4 from the SSL module's default cipher list.
+- bpo-23481: Remove RC4 from the SSL module's default cipher list.
 
-- Issue #21849: Fixed xmlrpclib serialization of non-ASCII unicode strings in
+- bpo-21849: Fixed xmlrpclib serialization of non-ASCII unicode strings in
   the multiprocessing module.
 
-- Issue #21840: Fixed expanding unicode variables of form $var in
-  posixpath.expandvars().  Fixed all os.path implementations on
-  unicode-disabled builds.
+- bpo-21840: Fixed expanding unicode variables of form $var in
+  posixpath.expandvars(). Fixed all os.path implementations on unicode-
+  disabled builds.
 
-- Issue #23367: Fix possible overflows in the unicodedata module.
+- bpo-23367: Fix possible overflows in the unicodedata module.
 
-- Issue #23363: Fix possible overflow in itertools.permutations.
+- bpo-23363: Fix possible overflow in itertools.permutations.
 
-- Issue #23364: Fix possible overflow in itertools.product.
+- bpo-23364: Fix possible overflow in itertools.product.
 
-- Issue #23365: Fixed possible integer overflow in
+- bpo-23365: Fixed possible integer overflow in
   itertools.combinations_with_replacement.
 
-- Issue #23366: Fixed possible integer overflow in itertools.combinations.
+- bpo-23366: Fixed possible integer overflow in itertools.combinations.
 
-- Issue #23191: fnmatch functions that use caching are now threadsafe.
+- bpo-23191: fnmatch functions that use caching are now threadsafe.
 
-- Issue #18518: timeit now rejects statements which can't be compiled outside
-  function or a loop (e.g. "return" or "break").
+- bpo-18518: timeit now rejects statements which can't be compiled outside a
+  function or a loop (e.g. "return" or "break").
 
-- Issue #19996: Make :mod:`httplib` ignore headers with no name rather than
+- bpo-19996: Make :mod:`httplib` ignore headers with no name rather than
   assuming the body has started.
 
-- Issue #20188: Support Application-Layer Protocol Negotiation (ALPN) in the ssl
-  module.
+- bpo-20188: Support Application-Layer Protocol Negotiation (ALPN) in the
+  ssl module.
 
-- Issue #23248: Update ssl error codes from latest OpenSSL git master.
+- bpo-23248: Update ssl error codes from latest OpenSSL git master.
 
-- Issue #23098: 64-bit dev_t is now supported in the os module.
+- bpo-23098: 64-bit dev_t is now supported in the os module.
 
-- Issue #23063: In the disutils' check command, fix parsing of reST with code or
-  code-block directives.
+- bpo-23063: In the disutils' check command, fix parsing of reST with code
+  or code-block directives.
 
-- Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The
-  availability of the function is checked during the compilation. Patch written
-  by Bernard Spil.
+- bpo-21356: Make ssl.RAND_egd() optional to support LibreSSL. The
+  availability of the function is checked during the compilation. Patch
+  written by Bernard Spil.
 
 - Backport the context argument to ftplib.FTP_TLS.
 
-- Issue #23111: Maximize compatibility in protocol versions of ftplib.FTP_TLS.
+- bpo-23111: Maximize compatibility in protocol versions of ftplib.FTP_TLS.
 
-- Issue #23112: Fix SimpleHTTPServer to correctly carry the query string and
+- bpo-23112: Fix SimpleHTTPServer to correctly carry the query string and
   fragment when it redirects to add a trailing slash.
 
-- Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),
+- bpo-22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),
   instead of reading /dev/urandom, to get pseudo-random bytes.
 
-- Issue #23093: In the io, module allow more operations to work on detached
+- bpo-23093: In the io, module allow more operations to work on detached
   streams.
 
-- Issue #23071: Added missing names to codecs.__all__.  Patch by Martin Panter.
+- bpo-23071: Added missing names to codecs.__all__.  Patch by Martin Panter.
 
-- Issue #23016: A warning no longer produces an AttributeError when sys.stderr
+- bpo-23016: A warning no longer produces an AttributeError when sys.stderr
   is None.
 
-- Issue #21032: Fixed socket leak if HTTPConnection.getresponse() fails.
+- bpo-21032: Fixed socket leak if HTTPConnection.getresponse() fails.
   Original patch by Martin Panter.
 
-- Issue #22609: Constructors and update methods of mapping classes in the
+- bpo-22609: Constructors and update methods of mapping classes in the
   collections module now accept the self keyword argument.
 
 Documentation
 -------------
 
-- Issue #23006: Improve the documentation and indexing of dict.__missing__.
-  Add an entry in the language datamodel special methods section.
-  Revise and index its discussion in the stdtypes mapping/dict section.
-  Backport the code example from 3.4.
+- bpo-23006: Improve the documentation and indexing of dict.__missing__. Add
+  an entry in the language datamodel special methods section. Revise and
+  index its discussion in the stdtypes mapping/dict section. Backport the
+  code example from 3.4.
 
-- Issue #21514: The documentation of the json module now refers to new JSON RFC
+- bpo-21514: The documentation of the json module now refers to new JSON RFC
   7159 instead of obsoleted RFC 4627.
 
 Tools/Demos
 -----------
 
-- Issue #23330: h2py now supports arbitrary filenames in #include.
+- bpo-23330: h2py now supports arbitrary filenames in #include.
 
-- Issue #6639: Module-level turtle functions no longer raise TclError after
+- bpo-6639: Module-level turtle functions no longer raise TclError after
   closing the window.
 
-- Issue #22314: pydoc now works when the LINES environment variable is set.
+- bpo-22314: pydoc now works when the LINES environment variable is set.
 
-- Issue #18905: "pydoc -p 0" now outputs actually used port.  Based on patch by
+- bpo-18905: "pydoc -p 0" now outputs actually used port.  Based on patch by
   Wieland Hoffmann.
 
-- Issue #23345: Prevent test_ssl failures with large OpenSSL patch level
-  values (like 0.9.8zc).
+- bpo-23345: Prevent test_ssl failures with large OpenSSL patch level values
+  (like 0.9.8zc).
 
 Tests
 -----
 
-- Issue #23799: Added test.test_support.start_threads() for running and
+- bpo-23799: Added test.test_support.start_threads() for running and
   cleaning up multiple threads.
 
-- Issue #22390: test.regrtest now emits a warning if temporary files or
+- bpo-22390: test.regrtest now emits a warning if temporary files or
   directories are left after running a test.
 
-- Issue #23583: Added tests for standard IO streams in IDLE.
+- bpo-23583: Added tests for standard IO streams in IDLE.
 
-- Issue #23392: Added tests for marshal C API that works with FILE*.
+- bpo-23392: Added tests for marshal C API that works with FILE*.
 
-- Issue #18982: Add tests for CLI of the calendar module.
+- bpo-18982: Add tests for CLI of the calendar module.
 
-- Issue #19949: The test_xpickle test now tests compatibility with installed
+- bpo-19949: The test_xpickle test now tests compatibility with installed
   Python 2.7 and reports skipped tests.  Based on patch by Zachary Ware.
 
-- Issue #11578: Backported test for the timeit module.
+- bpo-11578: Backported test for the timeit module.
 
-- Issue #22943: bsddb tests are locale independend now.
+- bpo-22943: bsddb tests are locale independend now.
 
 IDLE
 ----
 
-- Issue #23583: Fixed writing unicode to standard output stream in IDLE.
+- bpo-23583: Fixed writing unicode to standard output stream in IDLE.
 
-- Issue #20577: Configuration of the max line length for the FormatParagraph
-  extension has been moved from the General tab of the Idle preferences dialog
-  to the FormatParagraph tab of the Config Extensions dialog.
-  Patch by Tal Einat.
+- bpo-20577: Configuration of the max line length for the FormatParagraph
+  extension has been moved from the General tab of the Idle preferences
+  dialog to the FormatParagraph tab of the Config Extensions dialog. Patch
+  by Tal Einat.
 
-- Issue #16893: Update Idle doc chapter to match current Idle and add new
+- bpo-16893: Update Idle doc chapter to match current Idle and add new
   information.
 
-- Issue #23180: Rename IDLE "Windows" menu item to "Window".
-  Patch by Al Sweigart.
+- bpo-23180: Rename IDLE "Windows" menu item to "Window". Patch by Al
+  Sweigart.
 
 Build
 -----
 
-- Issue #15506: Use standard PKG_PROG_PKG_CONFIG autoconf macro in the configure
-  script.
+- bpo-15506: Use standard PKG_PROG_PKG_CONFIG autoconf macro in the
+  configure script.
 
-- Issue #23032: Fix installer build failures on OS X 10.4 Tiger
-  by disabling assembly code in the OpenSSL build.
+- bpo-23032: Fix installer build failures on OS X 10.4 Tiger by disabling
+  assembly code in the OpenSSL build.
 
-- Issue #23686: Update OS X 10.5 installer and Windows builds to use
-  OpenSSL 1.0.2a.
+- bpo-23686: Update OS X 10.5 installer and Windows builds to use OpenSSL
+  1.0.2a.
 
 C API
 -----
 
-- Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
+- bpo-23998: PyImport_ReInitLock() now checks for lock allocation error
 
-- Issue #22079: PyType_Ready() now checks that statically allocated type has
-  no dynamically allocated bases.
+- bpo-22079: PyType_Ready() now checks that statically allocated type has no
+  dynamically allocated bases.
 
 
-What's New in Python 2.7.9?
-===========================
+What's New in Python 2.7.9 final?
+=================================
 
 *Release date: 2014-12-10*
 
 Library
 -------
 
-- Issue #22959: Remove the *check_hostname* parameter of
+- bpo-22959: Remove the *check_hostname* parameter of
   httplib.HTTPSConnection. The *context* parameter should be used instead.
 
-- Issue #16043: Add a default limit for the amount of data xmlrpclib.gzip_decode
-  will return. This resolves CVE-2013-1753.
+- bpo-16043: Add a default limit for the amount of data
+  xmlrpclib.gzip_decode will return. This resolves CVE-2013-1753.
 
-- Issue #16042: CVE-2013-1752: smtplib: Limit amount of data read by limiting
+- bpo-16042: CVE-2013-1752: smtplib: Limit amount of data read by limiting
   the call to readline().  Original patch by Christian Heimes.
 
-- Issue #16041: In poplib, limit maximum line length read from the server to
+- bpo-16041: In poplib, limit maximum line length read from the server to
   prevent CVE-2013-1752.
 
-- Issue #22960: Add a context argument to xmlrpclib.ServerProxy.
+- bpo-22960: Add a context argument to xmlrpclib.ServerProxy.
 
 Build
 -----
 
-- Issue #22935: Allow the ssl module to be compiled if openssl doesn't support
+- bpo-22935: Allow the ssl module to be compiled if openssl doesn't support
   SSL 3.
 
-- Issue #17128: Use private version of OpenSSL for 2.7.9 OS X 10.5+ installer.
+- bpo-17128: Use private version of OpenSSL for 2.7.9 OS X 10.5+ installer.
 
 
 What's New in Python 2.7.9 release candidate 1?
@@ -1799,538 +2221,546 @@ What's New in Python 2.7.9 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #21963: backout issue #1856 patch (avoid crashes and lockups when
+- bpo-21963: backout issue #1856 patch (avoid crashes and lockups when
   daemon threads run while the interpreter is shutting down; instead, these
   threads are now killed when they try to take the GIL), as it seems to
   break some existing code.
 
-- Issue #22604: Fix assertion error in debug mode when dividing a complex
+- bpo-22604: Fix assertion error in debug mode when dividing a complex
   number by (nan+0j).
 
-- Issue #22470: Fixed integer overflow issues in "backslashreplace" and
+- bpo-22470: Fixed integer overflow issues in "backslashreplace" and
   "xmlcharrefreplace" error handlers.
 
-- Issue #22526: Fix iterating through files with lines longer than 2^31 bytes.
+- bpo-22526: Fix iterating through files with lines longer than 2^31 bytes.
 
-- Issue #22519: Fix overflow checking in PyString_Repr.
+- bpo-22519: Fix overflow checking in PyString_Repr.
 
-- Issue #22518: Fix integer overflow issues in latin-1 encoding.
+- bpo-22518: Fix integer overflow issues in latin-1 encoding.
 
-- Issue #22379: Fix empty exception message in a TypeError raised in
+- bpo-22379: Fix empty exception message in a TypeError raised in
   ``str.join``.
 
-- Issue #22221: Now the source encoding declaration on the second line isn't
+- bpo-22221: Now the source encoding declaration on the second line isn't
   effective if the first line contains anything except a comment.
 
-- Issue #22023: Fix ``%S``, ``%R`` and ``%V`` formats of
+- bpo-22023: Fix ``%S``, ``%R`` and ``%V`` formats of
   :c:func:`PyUnicode_FromFormat`.
 
-- Issue #21591: Correctly handle qualified exec statements in tuple form by
+- bpo-21591: Correctly handle qualified exec statements in tuple form by
   moving compatibility layer from run-time to AST transformation.
 
 Library
 -------
 
-- Issue #22417: Verify certificates by default in httplib (PEP 476).
+- bpo-22417: Verify certificates by default in httplib (PEP 476).
 
-- Issue #22927: Allow urllib.urlopen to take a *context* parameter to control
+- bpo-22927: Allow urllib.urlopen to take a *context* parameter to control
   SSL settings for HTTPS connections.
 
-- Issue #22921: Allow SSLContext to take the *hostname* parameter even if
+- bpo-22921: Allow SSLContext to take the *hostname* parameter even if
   OpenSSL doesn't support SNI.
 
-- Issue #9003 and #22366: httplib.HTTPSConnection, urllib2.HTTPSHandler and
-  urllib2.urlopen now take optional arguments to allow for server certificate
-  checking, as recommended in public uses of HTTPS. This backport is part of PEP
-  467.
+- bpo-9003: httplib.HTTPSConnection, urllib2.HTTPSHandler and
+  urllib2.urlopen now take optional arguments to allow for server
+  certificate checking, as recommended in public uses of HTTPS. This
+  backport is part of PEP 467. (See also: bpo-22366)
 
-- Issue #12728: Different Unicode characters having the same uppercase but
-  different lowercase are now matched in case-insensitive regular expressions.
+- bpo-12728: Different Unicode characters having the same uppercase but
+  different lowercase are now matched in case-insensitive regular
+  expressions.
 
-- Issue #22821: Fixed fcntl() with integer argument on 64-bit big-endian
+- bpo-22821: Fixed fcntl() with integer argument on 64-bit big-endian
   platforms.
 
-- Issue #17293: uuid.getnode() now determines MAC address on AIX using netstat.
+- bpo-17293: uuid.getnode() now determines MAC address on AIX using netstat.
   Based on patch by Aivars Kalvāns.
 
-- Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
+- bpo-22769: Fixed ttk.Treeview.tag_has() when called without arguments.
 
-- Issue #22787: Allow the keyfile argument of SSLContext.load_cert_chain to be
+- bpo-22787: Allow the keyfile argument of SSLContext.load_cert_chain to be
   None.
 
-- Issue #22775: Fixed unpickling of Cookie.SimpleCookie with protocol 2.
-  Patch by Tim Graham.
+- bpo-22775: Fixed unpickling of Cookie.SimpleCookie with protocol 2. Patch
+  by Tim Graham.
 
-- Issue #22776: Brought excluded code into the scope of a try block in
+- bpo-22776: Brought excluded code into the scope of a try block in
   SysLogHandler.emit().
 
-- Issue #17381: Fixed ranges handling in case-insensitive regular expressions.
+- bpo-17381: Fixed ranges handling in case-insensitive regular expressions.
 
-- Issue #19329: Optimized compiling charsets in regular expressions.
+- bpo-19329: Optimized compiling charsets in regular expressions.
 
-- Issue #22410: Module level functions in the re module now cache compiled
+- bpo-22410: Module level functions in the re module now cache compiled
   locale-dependent regular expressions taking into account the locale.
 
-- Issue #8876: distutils now falls back to copying files when hard linking
-  doesn't work.  This allows use with special filesystems such as VirtualBox
+- bpo-8876: distutils now falls back to copying files when hard linking
+  doesn't work. This allows use with special filesystems such as VirtualBox
   shared folders.
 
-- Issue #9351: Defaults set with set_defaults on an argparse subparser
-  are no longer ignored when also set on the parent parser.
+- bpo-9351: Defaults set with set_defaults on an argparse subparser are no
+  longer ignored when also set on the parent parser.
 
-- Issue #20421: Add a .version() method to SSL sockets exposing the actual
+- bpo-20421: Add a .version() method to SSL sockets exposing the actual
   protocol version in use.
 
-- Issue #22435: Fix a file descriptor leak when SocketServer bind fails.
+- bpo-22435: Fix a file descriptor leak when SocketServer bind fails.
 
-- Issue #13664: GzipFile now supports non-ascii Unicode filenames.
+- bpo-13664: GzipFile now supports non-ascii Unicode filenames.
 
-- Issue #13096: Fixed segfault in CTypes POINTER handling of large
-  values.
+- bpo-13096: Fixed segfault in CTypes POINTER handling of large values.
 
-- Issue #11694: Raise ConversionError in xdrlib as documented.  Patch
-  by Filip Gruszczyński and Claudiu Popa.
+- bpo-11694: Raise ConversionError in xdrlib as documented.  Patch by Filip
+  Gruszczyński and Claudiu Popa.
 
-- Issue #1686: Fix string.Template when overriding the pattern attribute.
+- bpo-1686: Fix string.Template when overriding the pattern attribute.
 
-- Issue #11866: Eliminated race condition in the computation of names
-  for new threads.
+- bpo-11866: Eliminated race condition in the computation of names for new
+  threads.
 
-- Issue #22219: The zipfile module CLI now adds entries for directories
+- bpo-22219: The zipfile module CLI now adds entries for directories
   (including empty directories) in ZIP file.
 
-- Issue #22449: In the ssl.SSLContext.load_default_certs, consult the
+- bpo-22449: In the ssl.SSLContext.load_default_certs, consult the
   environmental variables SSL_CERT_DIR and SSL_CERT_FILE on Windows.
 
-- Issue #8473: doctest.testfile now uses universal newline mode to read
-  the test file.
+- bpo-8473: doctest.testfile now uses universal newline mode to read the
+  test file.
 
-- Issue #20076: Added non derived UTF-8 aliases to locale aliases table.
+- bpo-20076: Added non derived UTF-8 aliases to locale aliases table.
 
-- Issue #20079: Added locales supported in glibc 2.18 to locale alias table.
+- bpo-20079: Added locales supported in glibc 2.18 to locale alias table.
 
-- Issue #22530: Allow the ``group()`` method of regular expression match objects
-  to take a ``long`` as an index.
+- bpo-22530: Allow the ``group()`` method of regular expression match
+  objects to take a ``long`` as an index.
 
-- Issue #22517: When an io.BufferedRWPair object is deallocated, clear its
+- bpo-22517: When an io.BufferedRWPair object is deallocated, clear its
   weakrefs.
 
-- Issue #10510: distutils register and upload methods now use HTML standards
+- bpo-10510: distutils register and upload methods now use HTML standards
   compliant CRLF line endings.
 
-- Issue #9850: Fixed macpath.join() for empty first component.  Patch by
-  Oleg Oshmyan.
+- bpo-9850: Fixed macpath.join() for empty first component.  Patch by Oleg
+  Oshmyan.
 
-- Issue #20912: Now directories added to ZIP file have correct Unix and MS-DOS
+- bpo-20912: Now directories added to ZIP file have correct Unix and MS-DOS
   directory attributes.
 
-- Issue #21866: ZipFile.close() no longer writes ZIP64 central directory
+- bpo-21866: ZipFile.close() no longer writes ZIP64 central directory
   records if allowZip64 is false.
 
-- Issue #22415: Fixed debugging output of the GROUPREF_EXISTS opcode in the re
+- bpo-22415: Fixed debugging output of the GROUPREF_EXISTS opcode in the re
   module.
 
-- Issue #22423: Unhandled exception in thread no longer causes unhandled
+- bpo-22423: Unhandled exception in thread no longer causes unhandled
   AttributeError when sys.stderr is None.
 
-- Issue #22419: Limit the length of incoming HTTP request in wsgiref server to
-  65536 bytes and send a 414 error code for higher lengths. Patch contributed
-  by Devin Cook.
+- bpo-22419: Limit the length of incoming HTTP request in wsgiref server to
+  65536 bytes and send a 414 error code for higher lengths. Patch
+  contributed by Devin Cook.
 
 - Lax cookie parsing in http.cookies could be a security issue when combined
   with non-standard cookie handling in some Web browsers.  Reported by
   Sergey Bobrov.
 
-- Issue #21147: sqlite3 now raises an exception if the request contains a null
+- bpo-21147: sqlite3 now raises an exception if the request contains a null
   character instead of truncating it.  Based on patch by Victor Stinner.
 
-- Issue #21951: Fixed a crash in Tkinter on AIX when called Tcl command with
+- bpo-21951: Fixed a crash in Tkinter on AIX when called Tcl command with
   empty string or tuple argument.
 
-- Issue #21951: Tkinter now most likely raises MemoryError instead of crash
-  if the memory allocation fails.
+- bpo-21951: Tkinter now most likely raises MemoryError instead of crash if
+  the memory allocation fails.
 
-- Issue #22226: First letter no longer is stripped from the "status" key in
-  the result of Treeview.heading().
+- bpo-22226: First letter no longer is stripped from the "status" key in the
+  result of Treeview.heading().
 
-- Issue #22051: turtledemo no longer reloads examples to re-run them.
-  Initialization of variables and gui setup should be done in main(),
-  which is called each time a demo is run, but not on import.
+- bpo-22051: turtledemo no longer reloads examples to re-run them.
+  Initialization of variables and gui setup should be done in main(), which
+  is called each time a demo is run, but not on import.
 
-- Issue #21597: The separator between the turtledemo text pane and the drawing
-  canvas can now be grabbed and dragged with a mouse.  The code text pane can
-  be widened to easily view or copy the full width of the text.  The canvas
-  can be widened on small screens.  Original patches by Jan Kanis and Lita Cho.
+- bpo-21597: The separator between the turtledemo text pane and the drawing
+  canvas can now be grabbed and dragged with a mouse.  The code text pane
+  can be widened to easily view or copy the full width of the text.  The
+  canvas can be widened on small screens.  Original patches by Jan Kanis and
+  Lita Cho.
 
-- Issue #18132: Turtledemo buttons no longer disappear when the window is
+- bpo-18132: Turtledemo buttons no longer disappear when the window is
   shrunk.  Original patches by Jan Kanis and Lita Cho.
 
-- Issue #22312: Fix ntpath.splitdrive IndexError.
+- bpo-22312: Fix ntpath.splitdrive IndexError.
 
-- Issue #22216: smtplib now resets its state more completely after a quit.  The
+- bpo-22216: smtplib now resets its state more completely after a quit.  The
   most obvious consequence of the previous behavior was a STARTTLS failure
   during a connect/starttls/quit/connect/starttls sequence.
 
-- Issue #21305: os.urandom now caches a fd to /dev/urandom. This is a PEP 466
+- bpo-21305: os.urandom now caches a fd to /dev/urandom. This is a PEP 466
   backport from Python 3.
 
-- Issue #21307: As part of PEP 466, backport hashlib.algorithms_guaranteed and
+- bpo-21307: As part of PEP 466, backport hashlib.algorithms_guaranteed and
   hashlib.algorithms_available.
 
-- Issue #22259: Fix segfault when attempting to fopen a file descriptor
+- bpo-22259: Fix segfault when attempting to fopen a file descriptor
   corresponding to a directory.
 
-- Issue #22236: Fixed Tkinter images copying operations in NoDefaultRoot mode.
+- bpo-22236: Fixed Tkinter images copying operations in NoDefaultRoot mode.
 
-- Issue #22191: Fixed warnings.__all__.
+- bpo-22191: Fixed warnings.__all__.
 
-- Issue #21308: Backport numerous features from Python's ssl module. This is
+- bpo-21308: Backport numerous features from Python's ssl module. This is
   part of PEP 466.
 
-- Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows.
+- bpo-15696: Add a __sizeof__ implementation for mmap objects on Windows.
 
-- Issue #8797: Raise HTTPError on failed Basic Authentication immediately.
+- bpo-8797: Raise HTTPError on failed Basic Authentication immediately.
   Initial patch by Sam Bull.
 
-- Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter.
+- bpo-22068: Avoided reference loops with Variables and Fonts in Tkinter.
 
-- Issue #21448: Changed FeedParser feed() to avoid O(N**2) behavior when
-  parsing long line.  Original patch by Raymond Hettinger.
+- bpo-21448: Changed FeedParser feed() to avoid O(N**2) behavior when
+  parsing long line. Original patch by Raymond Hettinger.
 
-- Issue #17923: glob() patterns ending with a slash no longer match non-dirs on
+- bpo-17923: glob() patterns ending with a slash no longer match non-dirs on
   AIX.  Based on patch by Delhallt.
 
-- Issue #21975: Fixed crash when using uninitialized sqlite3.Row (in particular
-  when unpickling pickled sqlite3.Row).  sqlite3.Row is now initialized in the
-  __new__() method.
+- bpo-21975: Fixed crash when using uninitialized sqlite3.Row (in particular
+  when unpickling pickled sqlite3.Row).  sqlite3.Row is now initialized in
+  the __new__() method.
 
-- Issue #16037: HTTPMessage.readheaders() raises an HTTPException when more
+- bpo-16037: HTTPMessage.readheaders() raises an HTTPException when more
   than 100 headers are read. Patch by Jyrki Pulliainen and Daniel Eriksson.
 
-- Issue #21580: Now Tkinter correctly handles binary "data" and "maskdata"
+- bpo-21580: Now Tkinter correctly handles binary "data" and "maskdata"
   configure options of tkinter.PhotoImage.
 
-- Issue #19612: subprocess.communicate() now also ignores EINVAL when using at
+- bpo-19612: subprocess.communicate() now also ignores EINVAL when using at
   least two pipes.
 
 - Fix repr(_socket.socket) on Windows 64-bit: don't fail with OverflowError
   on closed socket.
 
-- Issue #16133: The asynchat.async_chat.handle_read() method now ignores
+- bpo-16133: The asynchat.async_chat.handle_read() method now ignores
   socket.error() exceptions with blocking I/O errors: EAGAIN, EALREADY,
   EINPROGRESS, or EWOULDBLOCK.
 
-- Issue #21990: Clean-up unnecessary and slow inner class definition in
+- bpo-21990: Clean-up unnecessary and slow inner class definition in
   saxutils (Contributed by Alex Gaynor).
 
-- Issue #1730136: Fix the comparison between a tkFont.Font and an object of
+- bpo-1730136: Fix the comparison between a tkFont.Font and an object of
   another kind.
 
-- Issue #19884: readline: Disable the meta modifier key if stdout is not
-  terminal to not write the ANSI sequence "\033[1034h" into stdout. This
+- bpo-19884: readline: Disable the meta modifier key if stdout is not a
+  terminal to not write the ANSI sequence "\033[1034h" into stdout. This
   sequence is used on some terminal (ex: TERM=xterm-256color") to enable
   support of 8 bit characters.
 
-- Issue #22017: Correct reference counting error in the initialization of the
+- bpo-22017: Correct reference counting error in the initialization of the
   _warnings module.
 
-- Issue #21868: Prevent turtle crash when undo buffer set to a value less
-  than one.
+- bpo-21868: Prevent turtle crash when undo buffer set to a value less than
+  one.
 
-- Issue #21151: Fixed a segfault in the _winreg module when ``None`` is passed
+- bpo-21151: Fixed a segfault in the _winreg module when ``None`` is passed
   as a ``REG_BINARY`` value to SetValueEx.  Patch by John Ehresman.
 
-- Issue #21090: io.FileIO.readall() does not ignore I/O errors anymore. Before,
+- bpo-21090: io.FileIO.readall() does not ignore I/O errors anymore. Before,
   it ignored I/O errors if at least the first C call read() succeed.
 
-- Issue #19870: BaseCookie now parses 'secure' and 'httponly' flags.
-  Backport of issue #16611.
+- bpo-19870: BaseCookie now parses 'secure' and 'httponly' flags. Backport
+  of issue #16611.
 
-- Issue #21923: Prevent AttributeError in distutils.sysconfig.customize_compiler
-  due to possible uninitialized _config_vars.
+- bpo-21923: Prevent AttributeError in
+  distutils.sysconfig.customize_compiler due to possible uninitialized
+  _config_vars.
 
-- Issue #21323: Fix CGIHTTPServer to again handle scripts in CGI subdirectories,
-  broken by the fix for security issue #19435.  Patch by Zach Byrne.
+- bpo-21323: Fix CGIHTTPServer to again handle scripts in CGI
+  subdirectories, broken by the fix for security issue #19435.  Patch by
+  Zach Byrne.
 
-- Issue #22199: Make get_makefile_filename() available in Lib/sysconfig.py
-  for 2.7 to match other versions of sysconfig.
+- bpo-22199: Make get_makefile_filename() available in Lib/sysconfig.py for
+  2.7 to match other versions of sysconfig.
 
 IDLE
 ----
 
-- Issue #3068: Add Idle extension configuration dialog to Options menu.
-  Changes are written to HOME/.idlerc/config-extensions.cfg.
-  Original patch by Tal Einat.
+- bpo-3068: Add Idle extension configuration dialog to Options menu. Changes
+  are written to HOME/.idlerc/config-extensions.cfg. Original patch by Tal
+  Einat.
 
-- Issue #16233: A module browser (File : Class Browser, Alt+C) requires an
+- bpo-16233: A module browser (File : Class Browser, Alt+C) requires an
   editor window with a filename.  When Class Browser is requested otherwise,
   from a shell, output window, or 'Untitled' editor, Idle no longer displays
-  an error box.  It now pops up an Open Module box (Alt+M). If a valid name
+  an error box. It now pops up an Open Module box (Alt+M). If a valid name
   is entered and a module is opened, a corresponding browser is also opened.
 
-- Issue #4832: Save As to type Python files automatically adds .py to the
-  name you enter (even if your system does not display it).  Some systems
+- bpo-4832: Save As to type Python files automatically adds .py to the name
+  you enter (even if your system does not display it).  Some systems
   automatically add .txt when type is Text files.
 
-- Issue #21986: Code objects are not normally pickled by the pickle module.
-  To match this, they are no longer pickled when running under Idle.
+- bpo-21986: Code objects are not normally pickled by the pickle module. To
+  match this, they are no longer pickled when running under Idle.
 
-- Issue #22221: IDLE now ignores the source encoding declaration on the second
+- bpo-22221: IDLE now ignores the source encoding declaration on the second
   line if the first line contains anything except a comment.
 
-- Issue #17390: Adjust Editor window title; remove 'Python',
-  move version to end.
+- bpo-17390: Adjust Editor window title; remove 'Python', move version to
+  end.
 
-- Issue #14105: Idle debugger breakpoints no longer disappear
-  when inserting or deleting lines.
+- bpo-14105: Idle debugger breakpoints no longer disappear when inserting or
+  deleting lines.
 
-Extension Modules
------------------
+Library
+-------
 
-- Issue #22381: Update zlib to 1.2.8.
+- bpo-22381: Update zlib to 1.2.8.
 
-- Issue #22176: Update the ctypes module's libffi to v3.1.  This release
-  adds support for the Linux AArch64 and POWERPC ELF ABIv2 little endian
+- bpo-22176: Update the ctypes module's libffi to v3.1.  This release adds
+  support for the Linux AArch64 and POWERPC ELF ABIv2 little endian
   architectures.
 
 Tools/Demos
 -----------
 
-- Issue #10712: 2to3 has a new "asserts" fixer that replaces deprecated names
+- bpo-10712: 2to3 has a new "asserts" fixer that replaces deprecated names
   of unittest methods (e.g. failUnlessEqual -> assertEqual).
 
-- Issue #22221: 2to3 and the findnocoding.py script now ignore the source
-  encoding declaration on the second line if the first line contains anything
-  except a comment.
+- bpo-22221: 2to3 and the findnocoding.py script now ignore the source
+  encoding declaration on the second line if the first line contains
+  anything except a comment.
 
-- Issue #22201: Command-line interface of the zipfile module now correctly
+- bpo-22201: Command-line interface of the zipfile module now correctly
   extracts ZIP files with directory entries.  Patch by Ryan Wilson.
 
 Tests
 -----
 
-- Issue #22236: Tkinter tests now don't reuse default root window.  New root
+- bpo-22236: Tkinter tests now don't reuse default root window.  New root
   window is created for every test class.
 
-- Issue #18004: test_overflow in test_list by mistake consumed 40 GiB of memory
+- bpo-18004: test_overflow in test_list by mistake consumed 40 GiB of memory
   on 64-bit systems.
 
-- Issue #21976: Fix test_ssl to accept LibreSSL version strings.  Thanks
-  to William Orr.
+- bpo-21976: Fix test_ssl to accept LibreSSL version strings.  Thanks to
+  William Orr.
 
-- Issue #22770: Prevent some Tk segfaults on OS X when running gui tests.
+- bpo-22770: Prevent some Tk segfaults on OS X when running gui tests.
 
 Build
 -----
 
-- Issue #20221: Removed conflicting (or circular) hypot definition when
+- bpo-20221: Removed conflicting (or circular) hypot definition when
   compiled with VS 2010 or above.  Initial patch by Tabrez Mohammed.
 
-- Issue #16537: Check whether self.extensions is empty in setup.py. Patch by
+- bpo-16537: Check whether self.extensions is empty in setup.py. Patch by
   Jonathan Hosmer.
 
-- The documentation Makefile no longer automatically downloads Sphinx. Users are
-  now required to have Sphinx already installed to build the documentation.
+- The documentation Makefile no longer automatically downloads Sphinx. Users
+  are now required to have Sphinx already installed to build the
+  documentation.
 
-- Issue #21958: Define HAVE_ROUND when building with Visual Studio 2013 and
+- bpo-21958: Define HAVE_ROUND when building with Visual Studio 2013 and
   above.  Patch by Zachary Turner.
 
-- Issue #15759: "make suspicious", "make linkcheck" and "make doctest" in Doc/
+- bpo-15759: "make suspicious", "make linkcheck" and "make doctest" in Doc/
   now display special message when and only when there are failures.
 
-- Issue #21166: Prevent possible segfaults and other random failures of
-  python --generate-posix-vars in pybuilddir.txt build target.
+- bpo-21166: Prevent possible segfaults and other random failures of python
+  --generate- posix-vars in pybuilddir.txt build target.
 
-- Issue #18096: Fix library order returned by python-config.
+- bpo-18096: Fix library order returned by python-config.
 
-- Issue #17219: Add library build dir for Python extension cross-builds.
+- bpo-17219: Add library build dir for Python extension cross-builds.
 
-- Issue #22877: PEP 477 - OS X installer now installs pip.
+- bpo-22877: PEP 477 - OS X installer now installs pip.
 
-- Issue #22878: PEP 477 - "make install" and "make altinstall" can now install
+- bpo-22878: PEP 477 - "make install" and "make altinstall" can now install
   or upgrade pip, using the bundled pip provided by the backported ensurepip
   module.  A configure option, --with-ensurepip[=upgrade|install|no], is
-  available to set the option for subsequent installs; the default for Python 2
-  in "no" (do not install or upgrade pip).  The option can also be set with
-  "make [alt]install ENSUREPIP=[upgrade|install|no]".
+  available to set the option for subsequent installs; the default for
+  Python 2 in "no" (do not install or upgrade pip).  The option can also be
+  set with "make [alt]install ENSUREPIP=[upgrade|install|no]".
 
 Windows
 -------
 
-- Issue #17896: The Windows build scripts now expect external library sources
+- bpo-17896: The Windows build scripts now expect external library sources
   to be in ``PCbuild\..\externals`` rather than ``PCbuild\..\..``.
 
-- Issue #17717: The Windows build scripts now use a copy of NASM pulled from
+- bpo-17717: The Windows build scripts now use a copy of NASM pulled from
   svn.python.org to build OpenSSL.
 
-- Issue #22644: The bundled version of OpenSSL has been updated to 1.0.1j.
+- bpo-22644: The bundled version of OpenSSL has been updated to 1.0.1j.
 
 
-What's New in Python 2.7.8?
-===========================
+What's New in Python 2.7.8 final?
+=================================
 
 *Release date: 2014-06-29*
 
 Core and Builtins
 -----------------
 
-- Issue #4346: In PyObject_CallMethod and PyObject_CallMethodObjArgs, don't
+- bpo-4346: In PyObject_CallMethod and PyObject_CallMethodObjArgs, don't
   overwrite the error set in PyObject_GetAttr.
 
-- Issue #21831: Avoid integer overflow when large sizes and offsets are given to
-  the buffer type. CVE-2014-7185.
+- bpo-21831: Avoid integer overflow when large sizes and offsets are given
+  to the buffer type. CVE-2014-7185.
 
-- Issue #19656: Running Python with the -3 option now also warns about
-  non-ascii bytes literals.
+- bpo-19656: Running Python with the -3 option now also warns about non-
+  ascii bytes literals.
 
-- Issue #21642: If the conditional if-else expression, allow an integer written
-  with no space between itself and the ``else`` keyword (e.g. ``True if 42else
-  False``) to be valid syntax.
+- bpo-21642: If the conditional if-else expression, allow an integer written
+  with no space between itself and the ``else`` keyword (e.g. ``True if
+  42else False``) to be valid syntax.
 
-- Issue #21523: Fix over-pessimistic computation of the stack effect of
-  some opcodes in the compiler.  This also fixes a quadratic compilation
-  time issue noticeable when compiling code with a large number of "and"
-  and "or" operators.
+- bpo-21523: Fix over-pessimistic computation of the stack effect of some
+  opcodes in the compiler.  This also fixes a quadratic compilation time
+  issue noticeable when compiling code with a large number of "and" and "or"
+  operators.
 
 Library
 -------
 
-- Issue #21652: Prevent mimetypes.type_map from containing unicode keys on
+- bpo-21652: Prevent mimetypes.type_map from containing unicode keys on
   Windows.
 
-- Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
+- bpo-21729: Used the "with" statement in the dbm.dumb module to ensure
   files closing.
 
-- Issue #21672: Fix the behavior of ntpath.join on UNC-style paths.
+- bpo-21672: Fix the behavior of ntpath.join on UNC-style paths.
 
-- Issue #19145: The times argument for itertools.repeat now handles
-  negative values the same way for keyword arguments as it does for
-  positional arguments.
+- bpo-19145: The times argument for itertools.repeat now handles negative
+  values the same way for keyword arguments as it does for positional
+  arguments.
 
-- Issue #21832: Require named tuple inputs to be exact strings.
+- bpo-21832: Require named tuple inputs to be exact strings.
 
-- Issue #8343: Named group error messages in the re module did not show
-  the name of the erroneous group.
+- bpo-8343: Named group error messages in the re module did not show the
+  name of the erroneous group.
 
-- Issue #21491: SocketServer: Fix a race condition in child processes reaping.
+- bpo-21491: SocketServer: Fix a race condition in child processes reaping.
 
-- Issue #21635: The difflib SequenceMatcher.get_matching_blocks() method
-  cache didn't match the actual result.  The former was a list of tuples
-  and the latter was a list of named tuples.
+- bpo-21635: The difflib SequenceMatcher.get_matching_blocks() method cache
+  didn't match the actual result.  The former was a list of tuples and the
+  latter was a list of named tuples.
 
-- Issue #21722: The distutils "upload" command now exits with a non-zero
-  return code when uploading fails.  Patch by Martin Dengler.
+- bpo-21722: The distutils "upload" command now exits with a non-zero return
+  code when uploading fails.  Patch by Martin Dengler.
 
-- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
+- bpo-21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
   before checking for a CGI script at that path.
 
-- Issue #21310: Fixed possible resource leak in failed open().
+- bpo-21310: Fixed possible resource leak in failed open().
 
-- Issue #21304: Backport the key derivation function hashlib.pbkdf2_hmac from
+- bpo-21304: Backport the key derivation function hashlib.pbkdf2_hmac from
   Python 3 per PEP 466.
 
-- Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a
+- bpo-11709: Fix the pydoc.help function to not fail when sys.stdin is not a
   valid file.
 
-- Issue #13223: Fix pydoc.writedoc so that the HTML documentation for methods
+- bpo-13223: Fix pydoc.writedoc so that the HTML documentation for methods
   that use 'self' in the example code is generated correctly.
 
-- Issue #21552: Fixed possible integer overflow of too long string lengths in
+- bpo-21552: Fixed possible integer overflow of too long string lengths in
   the tkinter module on 64-bit platforms.
 
-- Issue #14315: The zipfile module now ignores extra fields in the central
-  directory that are too short to be parsed instead of letting a struct.unpack
-  error bubble up as this "bad data" appears in many real world zip files in
-  the wild and is ignored by other zip tools.
+- bpo-14315: The zipfile module now ignores extra fields in the central
+  directory that are too short to be parsed instead of letting a
+  struct.unpack error bubble up as this "bad data" appears in many real
+  world zip files in the wild and is ignored by other zip tools.
 
-- Issue #21402: Tkinter.ttk now works when default root window is not set.
+- bpo-21402: Tkinter.ttk now works when default root window is not set.
 
-- Issue #10203: sqlite3.Row now truly supports sequence protocol.  In particulr
-  it supports reverse() and negative indices.  Original patch by Claudiu Popa.
+- bpo-10203: sqlite3.Row now truly supports sequence protocol.  In particulr
+  it supports reverse() and negative indices.  Original patch by Claudiu
+  Popa.
 
-- Issue #8743: Fix interoperability between set objects and the
+- bpo-8743: Fix interoperability between set objects and the
   collections.Set() abstract base class.
 
-- Issue #21481: Argparse equality and inequality tests now return
+- bpo-21481: Argparse equality and inequality tests now return
   NotImplemented when comparing to an unknown type.
 
 IDLE
 ----
 
-- Issue #21940: Add unittest for WidgetRedirector. Initial patch by Saimadhav
+- bpo-21940: Add unittest for WidgetRedirector. Initial patch by Saimadhav
   Heblikar.
 
-- Issue #18592: Add unittest for SearchDialogBase. Patch by Phil Webster.
+- bpo-18592: Add unittest for SearchDialogBase. Patch by Phil Webster.
 
-- Issue #21694: Add unittest for ParenMatch. Patch by Saimadhav Heblikar.
+- bpo-21694: Add unittest for ParenMatch. Patch by Saimadhav Heblikar.
 
-- Issue #21686: add unittest for HyperParser. Original patch by Saimadhav
+- bpo-21686: add unittest for HyperParser. Original patch by Saimadhav
   Heblikar.
 
-- Issue #12387: Add missing upper(lower)case versions of default Windows key
-  bindings for Idle so Caps Lock does not disable them. Patch by Roger Serwy.
+- bpo-12387: Add missing upper(lower)case versions of default Windows key
+  bindings for Idle so Caps Lock does not disable them. Patch by Roger
+  Serwy.
 
-- Issue #21695: Closing a Find-in-files output window while the search is
-  still in progress no longer closes Idle.
+- bpo-21695: Closing a Find-in-files output window while the search is still
+  in progress no longer closes Idle.
 
-- Issue #18910: Add unittest for textView. Patch by Phil Webster.
+- bpo-18910: Add unittest for textView. Patch by Phil Webster.
 
-- Issue #18292: Add unittest for AutoExpand. Patch by Saihadhav Heblikar.
+- bpo-18292: Add unittest for AutoExpand. Patch by Saihadhav Heblikar.
 
-- Issue #18409: Add unittest for AutoComplete. Patch by Phil Webster.
+- bpo-18409: Add unittest for AutoComplete. Patch by Phil Webster.
 
 Tests
 -----
 
-- Issue #20155: Changed HTTP method names in failing tests in test_httpservers
-  so that packet filtering software (specifically Windows Base Filtering Engine)
-  does not interfere with the transaction semantics expected by the tests.
+- bpo-20155: Changed HTTP method names in failing tests in test_httpservers
+  so that packet filtering software (specifically Windows Base Filtering
+  Engine) does not interfere with the transaction semantics expected by the
+  tests.
 
-- Issue #19493: Refactored the ctypes test package to skip tests explicitly
+- bpo-19493: Refactored the ctypes test package to skip tests explicitly
   rather than silently.
 
-- Issue #18492: All resources are now allowed when tests are not run by
+- bpo-18492: All resources are now allowed when tests are not run by
   regrtest.py.
 
-- Issue #21605: Added tests for Tkinter images.
+- bpo-21605: Added tests for Tkinter images.
 
-- Issue #21493: Added test for ntpath.expanduser().  Original patch by
-  Claudiu Popa.
+- bpo-21493: Added test for ntpath.expanduser().  Original patch by Claudiu
+  Popa.
 
-- Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok.
+- bpo-19925: Added tests for the spwd module. Original patch by Vajrasky
+  Kok.
 
-- Issue #13355: random.triangular() no longer fails with a ZeroDivisionError
+- bpo-13355: random.triangular() no longer fails with a ZeroDivisionError
   when low equals high.
 
-- Issue #21522: Added Tkinter tests for Listbox.itemconfigure(),
+- bpo-21522: Added Tkinter tests for Listbox.itemconfigure(),
   PanedWindow.paneconfigure(), and Menu.entryconfigure().
 
-- Issue #20635: Added tests for Tk geometry managers.
+- bpo-20635: Added tests for Tk geometry managers.
 
 Build
 -----
 
-- Issue #21811: Anticipated fixes to support OS X versions > 10.9.
+- bpo-21811: Anticipated fixes to support OS X versions > 10.9.
 
 Windows
 -------
 
-- Issue #21671, CVE-2014-0224: The bundled version of OpenSSL has been
-  updated to 1.0.1h.
+- bpo-21671: The bundled version of OpenSSL has been updated to 1.0.1h. (See
+  also: CVE-2014-0224)
 
 
-What's New in Python 2.7.7
-==========================
+What's New in Python 2.7.7 final?
+=================================
 
 *Release date: 2014-05-31*
 
 Build
 -----
 
-- Issue #21462: Build the Windows installers with OpenSSL 1.0.1g.
+- bpo-21462: Build the Windows installers with OpenSSL 1.0.1g.
 
-- Issue #19866: Include some test data in the Windows installers, so tests don't
-  fail.
+- bpo-19866: Include some test data in the Windows installers, so tests
+  don't fail.
 
 
 What's New in Python 2.7.7 release candidate 1?
@@ -2341,312 +2771,315 @@ What's New in Python 2.7.7 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #21350: Fix file.writelines() to accept arbitrary buffer objects,
-  as advertised.  Patch by Brian Kearns.
+- bpo-21350: Fix file.writelines() to accept arbitrary buffer objects, as
+  advertised. Patch by Brian Kearns.
 
-- Issue #20437: Fixed 43 potential bugs when deleting object references.
+- bpo-20437: Fixed 43 potential bugs when deleting object references.
 
-- Issue #21134: Fix segfault when str is called on an uninitialized
+- bpo-21134: Fix segfault when str is called on an uninitialized
   UnicodeEncodeError, UnicodeDecodeError, or UnicodeTranslateError object.
 
-- Issue #20494: Ensure that free()d memory arenas are really released on POSIX
+- bpo-20494: Ensure that free()d memory arenas are really released on POSIX
   systems supporting anonymous memory mappings.  Patch by Charles-François
   Natali.
 
-- Issue #17825: Cursor "^" is correctly positioned for SyntaxError and
+- bpo-17825: Cursor "^" is correctly positioned for SyntaxError and
   IndentationError.
 
 - Raise a better error when non-unicode codecs are used for a file's coding
   cookie.
 
-- Issue #17976: Fixed potential problem with file.write() not detecting IO error
-  by inspecting the return value of fwrite().  Based on patches by Jaakko Moisio
-  and Victor Stinner.
+- bpo-17976: Fixed potential problem with file.write() not detecting IO
+  error by inspecting the return value of fwrite().  Based on patches by
+  Jaakko Moisio and Victor Stinner.
 
-- Issue #14432: Generator now clears the borrowed reference to the thread
+- bpo-14432: Generator now clears the borrowed reference to the thread
   state. Fix a crash when a generator is created in a C thread that is
-  destroyed while the generator is still used. The issue was that a generator
-  contains a frame, and the frame kept a reference to the Python state of the
-  destroyed C thread. The crash occurs when a trace function is setup.
+  destroyed while the generator is still used. The issue was that a
+  generator contains a frame, and the frame kept a reference to the Python
+  state of the destroyed C thread. The crash occurs when a trace function is
+  setup.
 
-- Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
+- bpo-19932: Fix typo in import.h, missing whitespaces in function
+  prototypes.
 
-- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2
+- bpo-19638: Fix possible crash / undefined behaviour from huge (more than 2
   billion characters) input strings in _Py_dg_strtod.
 
-- Issue #12546: Allow \x00 to be used as a fill character when using str, int,
+- bpo-12546: Allow \x00 to be used as a fill character when using str, int,
   float, and complex __format__ methods.
 
 Library
 -------
 
-- Issue #10744: Fix PEP 3118 format strings on ctypes objects with a nontrivial
+- bpo-10744: Fix PEP 3118 format strings on ctypes objects with a nontrivial
   shape.
 
-- Issue #7776: Backport Fix ``Host:'' header and reconnection when using
+- bpo-7776: Backport Fix ``Host:'' header and reconnection when using
   http.client.HTTPConnection.set_tunnel() from Python 3.  Patch by Nikolaus
   Rath.
 
-- Issue #21306: Backport hmac.compare_digest from Python 3. This is part of PEP
+- bpo-21306: Backport hmac.compare_digest from Python 3. This is part of PEP
   466.
 
-- Issue #21470: Do a better job seeding the random number generator by
-  using enough bytes to span the full state space of the Mersenne Twister.
+- bpo-21470: Do a better job seeding the random number generator by using
+  enough bytes to span the full state space of the Mersenne Twister.
 
-- Issue #21469: Reduced the risk of false positives in robotparser by
-  checking to make sure that robots.txt has been read or does not exist
-  prior to returning True in can_fetch().
+- bpo-21469: Reduced the risk of false positives in robotparser by checking
+  to make sure that robots.txt has been read or does not exist prior to
+  returning True in can_fetch().
 
-- Issue #21321: itertools.islice() now releases the reference to the source
+- bpo-21321: itertools.islice() now releases the reference to the source
   iterator when the slice is exhausted.  Patch by Anton Afanasyev.
 
-- Issue #9291: Do not attempt to re-encode mimetype data read from registry in
+- bpo-9291: Do not attempt to re-encode mimetype data read from registry in
   ANSI mode. Initial patches by Dmitry Jemerov & Vladimir Iofik.
 
-- Issue #21349: Passing a memoryview to _winreg.SetValueEx now correctly raises
-  a TypeError where it previously crashed the interpreter. Patch by Brian Kearns
+- bpo-21349: Passing a memoryview to _winreg.SetValueEx now correctly raises
+  a TypeError where it previously crashed the interpreter. Patch by Brian
+  Kearns
 
-- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in
-  JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido
-  Vranken.
+- bpo-21529: Fix arbitrary memory access in JSONDecoder.raw_decode with a
+  negative second parameter. Bug reported by Guido Vranken. (See also:
+  CVE-2014-4616)
 
-- Issue #21172: isinstance check relaxed from dict to collections.Mapping.
+- bpo-21172: isinstance check relaxed from dict to collections.Mapping.
 
-- Issue #21191: In os.fdopen, never close the file descriptor when an exception
+- bpo-21191: In os.fdopen, never close the file descriptor when an exception
   happens.
 
-- Issue #21149: Improved thread-safety in logging cleanup during interpreter
+- bpo-21149: Improved thread-safety in logging cleanup during interpreter
   shutdown. Thanks to Devin Jeanpierre for the patch.
 
 - Fix possible overflow bug in strop.expandtabs. You shouldn't be using this
   module!
 
-- Issue #20145: `assertRaisesRegex` now raises a TypeError if the second
+- bpo-20145: `assertRaisesRegex` now raises a TypeError if the second
   argument is not a string or compiled regex.
 
-- Issue #21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),
+- bpo-21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),
   close the file descriptor if os.fdopen() fails
 
-- Issue #20283: RE pattern methods now accept the string keyword parameters
-  as documented.  The pattern and source keyword parameters are left as
+- bpo-20283: RE pattern methods now accept the string keyword parameters as
+  documented. The pattern and source keyword parameters are left as
   deprecated aliases.
 
-- Issue #11599: When an external command (e.g. compiler) fails, distutils now
-  prints out the whole command line (instead of just the command name) if the
-  environment variable DISTUTILS_DEBUG is set.
+- bpo-11599: When an external command (e.g. compiler) fails, distutils now
+  prints out the whole command line (instead of just the command name) if
+  the environment variable DISTUTILS_DEBUG is set.
 
-- Issue #4931: distutils should not produce unhelpful "error: None" messages
-  anymore.  distutils.util.grok_environment_error is kept but doc-deprecated.
+- bpo-4931: distutils should not produce unhelpful "error: None" messages
+  anymore. distutils.util.grok_environment_error is kept but doc-deprecated.
 
 - Improve the random module's default seeding to use 256 bits of entropy
   from os.urandom().  This was already done for Python 3, mildly improving
   security with a bigger seed space.
 
-- Issue #15618: Make turtle.py compatible with 'from __future__ import
-  unicode_literals'.  Initial patch by Juancarlo Añez.
+- bpo-15618: Make turtle.py compatible with 'from __future__ import
+  unicode_literals'. Initial patch by Juancarlo Añez.
 
-- Issue #20501: fileinput module no longer reads whole file into memory when using
-  fileinput.hook_encoded.
+- bpo-20501: fileinput module no longer reads whole file into memory when
+  using fileinput.hook_encoded.
 
-- Issue #6815: os.path.expandvars() now supports non-ASCII Unicode environment
+- bpo-6815: os.path.expandvars() now supports non-ASCII Unicode environment
   variables names and values.
 
-- Issue #20635: Fixed grid_columnconfigure() and grid_rowconfigure() methods of
+- bpo-20635: Fixed grid_columnconfigure() and grid_rowconfigure() methods of
   Tkinter widgets to work in wantobjects=True mode.
 
-- Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
-  Based on patch by Stephen Tu.
+- bpo-17671: Fixed a crash when use non-initialized io.BufferedRWPair. Based
+  on patch by Stephen Tu.
 
-- Issue #8478: Untokenizer.compat processes first token from iterator input.
+- bpo-8478: Untokenizer.compat processes first token from iterator input.
   Patch based on lines from Georg Brandl, Eric Snow, and Gareth Rees.
 
-- Issue #20594: Avoid name clash with the libc function posix_close.
+- bpo-20594: Avoid name clash with the libc function posix_close.
 
-- Issue #19856: shutil.move() failed to move a directory to other directory
-  on Windows if source name ends with os.altsep.
+- bpo-19856: shutil.move() failed to move a directory to other directory on
+  Windows if source name ends with os.altsep.
 
-- Issue #14983: email.generator now always adds a line end after each MIME
+- bpo-14983: email.generator now always adds a line end after each MIME
   boundary marker, instead of doing so only when there is an epilogue.  This
   fixes an RFC compliance bug and solves an issue with signed MIME parts.
 
-- Issue #20013: Some imap servers disconnect if the current mailbox is
-  deleted, and imaplib did not handle that case gracefully.  Now it
-  handles the 'bye' correctly.
+- bpo-20013: Some imap servers disconnect if the current mailbox is deleted,
+  and imaplib did not handle that case gracefully.  Now it handles the 'bye'
+  correctly.
 
-- Issue #20426: When passing the re.DEBUG flag, re.compile() displays the
-  debug output every time it is called, regardless of the compilation cache.
+- bpo-20426: When passing the re.DEBUG flag, re.compile() displays the debug
+  output every time it is called, regardless of the compilation cache.
 
-- Issue #20368: The null character now correctly passed from Tcl to Python (in
-  unicode strings only).  Improved error handling in variables-related commands.
+- bpo-20368: The null character now correctly passed from Tcl to Python (in
+  unicode strings only).  Improved error handling in variables-related
+  commands.
 
-- Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline
+- bpo-20435: Fix _pyio.StringIO.getvalue() to take into account newline
   translation settings.
 
-- Issue #20288: fix handling of invalid numeric charrefs in HTMLParser.
+- bpo-20288: fix handling of invalid numeric charrefs in HTMLParser.
 
-- Issue #19456: ntpath.join() now joins relative paths correctly when a drive
+- bpo-19456: ntpath.join() now joins relative paths correctly when a drive
   is present.
 
-- Issue #8260: The read(), readline() and readlines() methods of
+- bpo-8260: The read(), readline() and readlines() methods of
   codecs.StreamReader returned incomplete data when were called after
-  readline() or read(size).  Based on patch by Amaury Forgeot d'Arc.
+  readline() or read(size). Based on patch by Amaury Forgeot d'Arc.
 
-- Issue #20374: Fix build with GNU readline >= 6.3.
+- bpo-20374: Fix build with GNU readline >= 6.3.
 
-- Issue #14548: Make multiprocessing finalizers check pid before
-  running to cope with possibility of gc running just after fork.
-  (Backport from 3.x.)
+- bpo-14548: Make multiprocessing finalizers check pid before running to
+  cope with possibility of gc running just after fork. (Backport from 3.x.)
 
-- Issue #20262: Warnings are raised now when duplicate names are added in the
+- bpo-20262: Warnings are raised now when duplicate names are added in the
   ZIP file or too long ZIP file comment is truncated.
 
-- Issue #20270: urllib and urlparse now support empty ports.
+- bpo-20270: urllib and urlparse now support empty ports.
 
-- Issue #20243: TarFile no longer raise ReadError when opened in write mode.
+- bpo-20243: TarFile no longer raise ReadError when opened in write mode.
 
-- Issue #20245: The open functions in the tarfile module now correctly handle
+- bpo-20245: The open functions in the tarfile module now correctly handle
   empty mode.
 
-- Issue #20086: Restored the use of locale-independent mapping instead of
+- bpo-20086: Restored the use of locale-independent mapping instead of
   locale-dependent str.lower() in locale.normalize().
 
-- Issue #20246: Fix buffer overflow in socket.recvfrom_into.
+- bpo-20246: Fix buffer overflow in socket.recvfrom_into.
 
-- Issue #19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in
+- bpo-19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in
   modules and documentation.
 
-- Issue #13107: argparse and optparse no longer raises an exception when output
-  a help on environment with too small COLUMNS.  Based on patch by
-  Elazar Gershuni.
+- bpo-13107: argparse and optparse no longer raises an exception when output
+  a help on environment with too small COLUMNS.  Based on patch by Elazar
+  Gershuni.
 
-- Issue #20207: Always disable SSLv2 except when PROTOCOL_SSLv2 is explicitly
+- bpo-20207: Always disable SSLv2 except when PROTOCOL_SSLv2 is explicitly
   asked for.
 
-- Issue #20072: Fixed multiple errors in tkinter with wantobjects is False.
+- bpo-20072: Fixed multiple errors in tkinter with wantobjects is False.
 
-- Issue #1065986: pydoc can now handle unicode strings.
+- bpo-1065986: pydoc can now handle unicode strings.
 
-- Issue #16039: CVE-2013-1752: Change use of readline in imaplib module to
+- bpo-16039: CVE-2013-1752: Change use of readline in imaplib module to
   limit line length.  Patch by Emil Lind.
 
-- Issue #19422: Explicitly disallow non-SOCK_STREAM sockets in the ssl
-  module, rather than silently let them emit clear text data.
+- bpo-19422: Explicitly disallow non-SOCK_STREAM sockets in the ssl module,
+  rather than silently let them emit clear text data.
 
-- Issue #20027: Fixed locale aliases for devanagari locales.
+- bpo-20027: Fixed locale aliases for devanagari locales.
 
-- Issue #20067: Tkinter variables now work when wantobjects is false.
+- bpo-20067: Tkinter variables now work when wantobjects is false.
 
-- Issue #19020: Tkinter now uses splitlist() instead of split() in configure
+- bpo-19020: Tkinter now uses splitlist() instead of split() in configure
   methods.
 
-- Issue #12226: HTTPS is now used by default when connecting to PyPI.
+- bpo-12226: HTTPS is now used by default when connecting to PyPI.
 
-- Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of
+- bpo-20048: Fixed ZipExtFile.peek() when it is called on the boundary of
   the uncompress buffer and read() goes through more than one readbuffer.
 
-- Issue #20034: Updated alias mapping to most recent locale.alias file
-  from X.org distribution using makelocalealias.py.
+- bpo-20034: Updated alias mapping to most recent locale.alias file from
+  X.org distribution using makelocalealias.py.
 
-- Issue #5815: Fixed support for locales with modifiers.  Fixed support for
+- bpo-5815: Fixed support for locales with modifiers.  Fixed support for
   locale encodings with hyphens.
 
-- Issue #20026: Fix the sqlite module to handle correctly invalid isolation
+- bpo-20026: Fix the sqlite module to handle correctly invalid isolation
   level (wrong type).
 
-- Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
+- bpo-18829: csv.Dialect() now checks type for delimiter, escapechar and
   quotechar fields.  Original patch by Vajrasky Kok.
 
-- Issue #19855: uuid.getnode() on Unix now looks on the PATH for the
+- bpo-19855: uuid.getnode() on Unix now looks on the PATH for the
   executables used to find the mac address, with /sbin and /usr/sbin as
   fallbacks.
 
-- Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
+- bpo-20007: HTTPResponse.read(0) no more prematurely closes connection.
   Original patch by Simon Sapin.
 
-- Issue #19912: Fixed numerous bugs in ntpath.splitunc().
+- bpo-19912: Fixed numerous bugs in ntpath.splitunc().
 
-- Issue #19623: Fixed writing to unseekable files in the aifc module.
-  Fixed writing 'ulaw' (lower case) compressed AIFC files.
+- bpo-19623: Fixed writing to unseekable files in the aifc module. Fixed
+  writing 'ulaw' (lower case) compressed AIFC files.
 
-- Issue #17919: select.poll.register() again works with poll.POLLNVAL on AIX.
+- bpo-17919: select.poll.register() again works with poll.POLLNVAL on AIX.
   Fixed integer overflow in the eventmask parameter.
 
-- Issue #17200: telnetlib's read_until and expect timeout was broken by the
-  fix to Issue #14635 in Python 2.7.4 to be interpreted as milliseconds
-  instead of seconds when the platform supports select.poll (ie: everywhere).
-  It is now treated as seconds once again.
+- bpo-17200: telnetlib's read_until and expect timeout was broken by the fix
+  to Issue #14635 in Python 2.7.4 to be interpreted as milliseconds instead
+  of seconds when the platform supports select.poll (ie: everywhere). It is
+  now treated as seconds once again.
 
-- Issue #19099: The struct module now supports Unicode format strings.
+- bpo-19099: The struct module now supports Unicode format strings.
 
-- Issue #19878: Fix segfault in bz2 module after calling __init__ twice with
+- bpo-19878: Fix segfault in bz2 module after calling __init__ twice with
   non-existent filename. Initial patch by Vajrasky Kok.
 
-- Issue #16373: Prevent infinite recursion for ABC Set class comparisons.
+- bpo-16373: Prevent infinite recursion for ABC Set class comparisons.
 
-- Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows a match when
-  no exception detail exists (no colon following the exception's name, or
-  colon does follow but no text follows the colon).
+- bpo-19138: doctest's IGNORE_EXCEPTION_DETAIL now allows a match when no
+  exception detail exists (no colon following the exception's name, or a
+  colon does follow but no text follows the colon).
 
-- Issue #16231: Fixed pickle.Pickler to only fallback to its default pickling
+- bpo-16231: Fixed pickle.Pickler to only fallback to its default pickling
   behaviour when Pickler.persistent_id returns None, but not for any other
-  false values.  This allows false values other than None to be used as
+  false values. This allows false values other than None to be used as
   persistent IDs.  This behaviour is consistent with cPickle.
 
-- Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
-  virtual interface.  Original patch by Kent Frazier.
+- bpo-11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
+  virtual interface. Original patch by Kent Frazier.
 
-- Issue #11489: JSON decoder now accepts lone surrogates.
+- bpo-11489: JSON decoder now accepts lone surrogates.
 
 - Fix test.test_support.bind_port() to not cause an error when Python was
-  compiled on a system with SO_REUSEPORT defined in the headers but run on
-  system with an OS kernel that does not support that new socket option.
+  compiled on a system with SO_REUSEPORT defined in the headers but run on a
+  system with an OS kernel that does not support that new socket option.
 
-- Issue #19633: Fixed writing not compressed 16- and 32-bit wave files on
-  big-endian platforms.
+- bpo-19633: Fixed writing not compressed 16- and 32-bit wave files on big-
+  endian platforms.
 
-- Issue #19449: in csv's writerow, handle non-string keys when generating the
+- bpo-19449: in csv's writerow, handle non-string keys when generating the
   error message that certain keys are not in the 'fieldnames' list.
 
-- Issue #12853: Fix NameError in distutils.command.upload.
+- bpo-12853: Fix NameError in distutils.command.upload.
 
-- Issue #19523: Closed FileHandler leak which occurred when delay was set.
+- bpo-19523: Closed FileHandler leak which occurred when delay was set.
 
-- Issue #1575020: Fixed support of 24-bit wave files on big-endian platforms.
+- bpo-1575020: Fixed support of 24-bit wave files on big-endian platforms.
 
-- Issue #19480: HTMLParser now accepts all valid start-tag names as defined
-  by the HTML5 standard.
+- bpo-19480: HTMLParser now accepts all valid start-tag names as defined by
+  the HTML5 standard.
 
-- Issue #17827: Add the missing documentation for ``codecs.encode`` and
+- bpo-17827: Add the missing documentation for ``codecs.encode`` and
   ``codecs.decode``.
 
-- Issue #6157: Fixed Tkinter.Text.debug().  Original patch by Guilherme Polo.
+- bpo-6157: Fixed Tkinter.Text.debug().  Original patch by Guilherme Polo.
 
-- Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of
+- bpo-6160: The bbox() method of tkinter.Spinbox now returns a tuple of
   integers instead of a string.  Based on patch by Guilherme Polo.
 
-- Issue #19286: Directories in ``package_data`` are no longer added to
-  the filelist, preventing failure outlined in the ticket.
+- bpo-19286: Directories in ``package_data`` are no longer added to the
+  filelist, preventing failure outlined in the ticket.
 
-- Issue #6676: Ensure a meaningful exception is raised when attempting
-  to parse more than one XML document per pyexpat xmlparser instance.
-  (Original patches by Hirokazu Yamamoto and Amaury Forgeot d'Arc, with
-  suggested wording by David Gutteridge)
+- bpo-6676: Ensure a meaningful exception is raised when attempting to parse
+  more than one XML document per pyexpat xmlparser instance. (Original
+  patches by Hirokazu Yamamoto and Amaury Forgeot d'Arc, with suggested
+  wording by David Gutteridge)
 
-- Issue #21311: Avoid exception in _osx_support with non-standard compiler
-  configurations.  Patch by John Szakmeister.
+- bpo-21311: Avoid exception in _osx_support with non-standard compiler
+  configurations. Patch by John Szakmeister.
 
 Tools/Demos
 -----------
 
-- Issue #3561: The Windows installer now has an option, off by default, for
-  placing the Python installation into the system "Path" environment variable.
-  This was backported from Python 3.3.
+- bpo-3561: The Windows installer now has an option, off by default, for
+  placing the Python installation into the system "Path" environment
+  variable. This was backported from Python 3.3.
 
 - Add support for ``yield from`` to 2to3.
 
 - Add support for the PEP 465 matrix multiplication operator to 2to3.
 
-- Issue #19936: Added executable bits or shebang lines to Python scripts which
+- bpo-19936: Added executable bits or shebang lines to Python scripts which
   requires them.  Disable executable bits and shebang lines in test and
   benchmark files in order to prevent using a random system python, and in
   source files of modules which don't provide command line interface.
@@ -2654,166 +3087,169 @@ Tools/Demos
 IDLE
 ----
 
-- Issue #18104: Add idlelib/idle_test/htest.py with a few sample tests to begin
-  consolidating and improving human-validated tests of Idle. Change other files
-  as needed to work with htest.  Running the module as __main__ runs all tests.
+- bpo-18104: Add idlelib/idle_test/htest.py with a few sample tests to begin
+  consolidating and improving human-validated tests of Idle. Change other
+  files as needed to work with htest.  Running the module as __main__ runs
+  all tests.
 
-- Issue #21139: Change default paragraph width to 72, the PEP 8 recommendation.
+- bpo-21139: Change default paragraph width to 72, the PEP 8 recommendation.
 
-- Issue #21284: Paragraph reformat test passes after user changes reformat width.
+- bpo-21284: Paragraph reformat test passes after user changes reformat
+  width.
 
-- Issue #20406: Use Python application icons for Idle window title bars.
-  Patch mostly by Serhiy Storchaka.
+- bpo-20406: Use Python application icons for Idle window title bars. Patch
+  mostly by Serhiy Storchaka.
 
-- Issue #21029: Occurrences of "print" are now consistently colored as
-  being a keyword (the colorizer doesn't know if print functions are
-  enabled in the source).
+- bpo-21029: Occurrences of "print" are now consistently colored as being a
+  keyword (the colorizer doesn't know if print functions are enabled in the
+  source).
 
-- Issue #17721: Remove non-functional configuration dialog help button until we
+- bpo-17721: Remove non-functional configuration dialog help button until we
   make it actually gives some help when clicked. Patch by Guilherme Simões.
 
-- Issue #17390: Add Python version to Idle editor window title bar.
-  Original patches by Edmond Burnett and Kent Johnson.
+- bpo-17390: Add Python version to Idle editor window title bar. Original
+  patches by Edmond Burnett and Kent Johnson.
 
-- Issue #20058: sys.stdin.readline() in IDLE now always returns only one line.
+- bpo-20058: sys.stdin.readline() in IDLE now always returns only one line.
 
-- Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE
+- bpo-19481: print() of unicode, str or bytearray subclass instance in IDLE
   no more hangs.
 
-- Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
+- bpo-18270: Prevent possible IDLE AttributeError on OS X when no initial
   shell window is present.
 
-- Issue #17654: Ensure IDLE menus are customized properly on OS X for
-  non-framework builds and for all variants of Tk.
+- bpo-17654: Ensure IDLE menus are customized properly on OS X for non-
+  framework builds and for all variants of Tk.
 
 Tests
 -----
 
-- Issue #17752: Fix distutils tests when run from the installed location.
+- bpo-17752: Fix distutils tests when run from the installed location.
 
-- Issue #18604: Consolidated checks for GUI availability.  All platforms now
-  at least check whether Tk can be instantiated when the GUI resource is
+- bpo-18604: Consolidated checks for GUI availability.  All platforms now at
+  least check whether Tk can be instantiated when the GUI resource is
   requested.
 
-- Issue #20946: Correct alignment assumptions of some ctypes tests.
+- bpo-20946: Correct alignment assumptions of some ctypes tests.
 
-- Issue #20743: Fix a reference leak in test_tcl.
+- bpo-20743: Fix a reference leak in test_tcl.
 
-- Issue #20510: Rewrote test_exit in test_sys to match existing comments,
-  use modern unittest features, and use helpers from test.script_helper
-  instead of using subprocess directly.  Initial patch by Gareth Rees.
+- bpo-20510: Rewrote test_exit in test_sys to match existing comments, use
+  modern unittest features, and use helpers from test.script_helper instead
+  of using subprocess directly.  Initial patch by Gareth Rees.
 
-- Issue #20532: Tests which use _testcapi now are marked as CPython only.
+- bpo-20532: Tests which use _testcapi now are marked as CPython only.
 
-- Issue #19920: Added tests for TarFile.list().  Based on patch by Vajrasky Kok.
+- bpo-19920: Added tests for TarFile.list().  Based on patch by Vajrasky
+  Kok.
 
-- Issue #19990: Added tests for the imghdr module.  Based on patch by
-  Claudiu Popa.
+- bpo-19990: Added tests for the imghdr module.  Based on patch by Claudiu
+  Popa.
 
-- Issue #19804: The test_find_mac test in test_uuid is now skipped if the
+- bpo-19804: The test_find_mac test in test_uuid is now skipped if the
   ifconfig executable is not available.
 
-- Issue #19886: Use better estimated memory requirements for bigmem tests.
+- bpo-19886: Use better estimated memory requirements for bigmem tests.
 
 - Backported tests for Tkinter variables.
 
-- Issue #19320: test_tcl no longer fails when wantobjects is false.
+- bpo-19320: test_tcl no longer fails when wantobjects is false.
 
-- Issue #19683: Removed empty tests from test_minidom.  Initial patch by
+- bpo-19683: Removed empty tests from test_minidom.  Initial patch by
   Ajitesh Gupta.
 
-- Issue #19928: Implemented a test for repr() of cell objects.
+- bpo-19928: Implemented a test for repr() of cell objects.
 
-- Issue #19595, #19987: Re-enabled a long-disabled test in test_winsound.
+- bpo-19595: Re-enabled a long-disabled test in test_winsound. (See also:
+  bpo-19987)
 
-- Issue #19588: Fixed tests in test_random that were silently skipped most
-  of the time.  Patch by Julian Gindi.
+- bpo-19588: Fixed tests in test_random that were silently skipped most of
+  the time. Patch by Julian Gindi.
 
-- Issue #17883: Tweak test_tcl testLoadWithUNC to skip the test in the
-  event of a permission error on Windows and to properly report other
-  skip conditions.
+- bpo-17883: Tweak test_tcl testLoadWithUNC to skip the test in the event of
+  a permission error on Windows and to properly report other skip
+  conditions.
 
-- Issue #17883: Backported _is_gui_available() in test.test_support to
-  avoid hanging Windows buildbots on test_ttk_guionly.
+- bpo-17883: Backported _is_gui_available() in test.test_support to avoid
+  hanging Windows buildbots on test_ttk_guionly.
 
-- Issue #18702, #19572: All skipped tests now reported as skipped.
+- bpo-18702: All skipped tests now reported as skipped. (See also:
+  bpo-19572)
 
-- Issue #19085: Added basic tests for all tkinter widget options.
+- bpo-19085: Added basic tests for all tkinter widget options.
 
-- Issue #20605: Make test_socket getaddrinfo OS X segfault test more robust.
+- bpo-20605: Make test_socket getaddrinfo OS X segfault test more robust.
 
-- Issue #20939: Avoid various network test failures due to new
-  redirect of http://www.python.org/ to https://www.python.org:
-  use http://www.example.com instead.
+- bpo-20939: Avoid various network test failures due to new redirect of
+  http://www.python.org/ to https://www.python.org: use
+  http://www.example.com instead.
 
-- Issue #21093: Prevent failures of ctypes test_macholib on OS X if a
-  copy of libz exists in $HOME/lib or /usr/local/lib.
+- bpo-21093: Prevent failures of ctypes test_macholib on OS X if a copy of
+  libz exists in $HOME/lib or /usr/local/lib.
 
 Build
 -----
 
-- Issue #21285: Refactor and fix curses configure check to always search
-  in a ncursesw directory.
+- bpo-21285: Refactor and fix curses configure check to always search in a
+  ncursesw directory.
 
 Documentation
 -------------
 
-- Issue #20255: Update the about and bugs pages.
+- bpo-20255: Update the about and bugs pages.
 
-- Issue #18840: Introduce the json module in the tutorial, and de-emphasize
-  the pickle module.
+- bpo-18840: Introduce the json module in the tutorial, and de-emphasize the
+  pickle module.
 
-- Issue #19795: Improved markup of True/False constants.
+- bpo-19795: Improved markup of True/False constants.
 
 Windows
 -------
 
-- Issue #21303, #20565: Updated the version of Tcl/Tk included in the
-  installer from 8.5.2 to 8.5.15.
+- bpo-21303: Updated the version of Tcl/Tk included in the installer from
+  8.5.2 to 8.5.15. (See also: bpo-20565)
 
-Mac OS X
---------
+macOS
+-----
 
-- As of 2.7.8, the 32-bit-only installer will support OS X 10.5
-  and later systems as is currently done for Python 3.x installers.
-  For 2.7.7 only, we will provide three installers:
-  the legacy deprecated 10.3+ 32-bit-only format;
-  the newer 10.5+ 32-bit-only format;
-  and the unchanged 10.6+ 64-/32-bit format.
-  Although binary installers will no longer be available from
-  python.org as of 2.7.8, it will still be possible to build from
-  source on 10.3.9 and 10.4 systems if necessary.
-  See Mac/BuildScript/README.txt for more information.
+- As of 2.7.8, the 32-bit-only installer will support OS X 10.5 and later
+  systems as is currently done for Python 3.x installers. For 2.7.7 only, we
+  will provide three installers: the legacy deprecated 10.3+ 32-bit-only
+  format; the newer 10.5+ 32-bit-only format; and the unchanged 10.6+
+  64-/32-bit format. Although binary installers will no longer be available
+  from python.org as of 2.7.8, it will still be possible to build from
+  source on 10.3.9 and 10.4 systems if necessary. See
+  Mac/BuildScript/README.txt for more information.
 
 
-Whats' New in Python 2.7.6?
-===========================
+What's New in Python 2.7.6 final?
+=================================
 
 *Release date: 2013-11-10*
 
 Library
 -------
 
-- Issue #19435: Fix directory traversal attack on CGIHttpRequestHandler.
+- bpo-19435: Fix directory traversal attack on CGIHttpRequestHandler.
 
 IDLE
 ----
 
-- Issue #19426: Fixed the opening of Python source file with specified encoding.
+- bpo-19426: Fixed the opening of Python source file with specified
+  encoding.
 
 Tests
 -----
 
-- Issue #19457: Fixed xmlcharrefreplace tests on wide build when tests are
+- bpo-19457: Fixed xmlcharrefreplace tests on wide build when tests are
   loaded from .py[co] files.
 
 Build
 -----
 
-- Issue #15663: Revert OS X installer built-in Tcl/Tk support for 2.7.6.
-  Some third-party projects, such as Matplotlib and PIL/Pillow,
-  depended on being able to build with Tcl and Tk frameworks in
-  /Library/Frameworks.
+- bpo-15663: Revert OS X installer built-in Tcl/Tk support for 2.7.6. Some
+  third-party projects, such as Matplotlib and PIL/Pillow, depended on being
+  able to build with Tcl and Tk frameworks in /Library/Frameworks.
 
 
 What's New in Python 2.7.6 release candidate 1?
@@ -2824,1359 +3260,1361 @@ What's New in Python 2.7.6 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the
+- bpo-18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the
   Python executable and not removed by the linker's optimizer.
 
-- Issue #19279: UTF-7 decoder no more produces illegal unicode strings.
+- bpo-19279: UTF-7 decoder no more produces illegal unicode strings.
 
-- Issue #18739: Fix an inconsistency between math.log(n) and math.log(long(n));
+- bpo-18739: Fix an inconsistency between math.log(n) and math.log(long(n));
   the results could be off from one another by a ulp or two.
 
-- Issue #13461: Fix a crash in the "replace" error handler on 64-bit platforms.
+- bpo-13461: Fix a crash in the "replace" error handler on 64-bit platforms.
   Patch by Yogesh Chaudhari.
 
-- Issue #15866: The xmlcharrefreplace error handler no more produces two XML
+- bpo-15866: The xmlcharrefreplace error handler no more produces two XML
   entities for a non-BMP character on narrow build.
 
-- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
+- bpo-18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
   OverflowError when an argument of %c format is out of range.
 
-- Issue #18137: Detect integer overflow on precision in float.__format__()
-  and complex.__format__().
+- bpo-18137: Detect integer overflow on precision in float.__format__() and
+  complex.__format__().
 
-- Issue #18038: SyntaxError raised during compilation sources with illegal
+- bpo-18038: SyntaxError raised during compilation sources with illegal
   encoding now always contains an encoding name.
 
-- Issue #18019: Fix crash in the repr of dictionaries containing their own
+- bpo-18019: Fix crash in the repr of dictionaries containing their own
   views.
 
-- Issue #18427: str.replace could crash the interpreter with huge strings.
+- bpo-18427: str.replace could crash the interpreter with huge strings.
 
 Library
 -------
 
-- Issue #19393: Fix symtable.symtable function to not be confused when there are
-  functions or classes named "top".
+- bpo-19393: Fix symtable.symtable function to not be confused when there
+  are functions or classes named "top".
 
-- Issue #19327: Fixed the working of regular expressions with too big charset.
+- bpo-19327: Fixed the working of regular expressions with too big charset.
 
-- Issue #19350: Increasing the test coverage of macurl2path. Patch by Colin
+- bpo-19350: Increasing the test coverage of macurl2path. Patch by Colin
   Williams.
 
-- Issue #19352: Fix unittest discovery when a module can be reached
-  through several paths (e.g. under Debian/Ubuntu with virtualenv).
+- bpo-19352: Fix unittest discovery when a module can be reached through
+  several paths (e.g. under Debian/Ubuntu with virtualenv).
 
-- Issue #15207: Fix mimetypes to read from correct part of Windows registry
+- bpo-15207: Fix mimetypes to read from correct part of Windows registry
   Original patch by Dave Chambers
 
-- Issue #8964: fix platform._sys_version to handle IronPython 2.6+.
-  Patch by Martin Matusiak.
+- bpo-8964: fix platform._sys_version to handle IronPython 2.6+. Patch by
+  Martin Matusiak.
 
-- Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by
-  limiting the call to readline().  Original patch by Michał
-  Jastrzębski and Giampaolo Rodola.
+- bpo-16038: CVE-2013-1752: ftplib: Limit amount of data read by limiting
+  the call to readline().  Original patch by Michał Jastrzębski and
+  Giampaolo Rodola.
 
-- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
+- bpo-19276: Fixed the wave module on 64-bit big-endian platforms.
 
-- Issue #18458: Prevent crashes with newer versions of libedit.  Its readline
+- bpo-18458: Prevent crashes with newer versions of libedit.  Its readline
   emulation has changed from 0-based indexing to 1-based like gnu readline.
   Original patch by Ronald Oussoren.
 
-- Issue #18919: If the close() method of a writer in the sunau or wave module
+- bpo-18919: If the close() method of a writer in the sunau or wave module
   failed, second invocation of close() and destructor no more raise an
-  exception.  Second invocation of close() on sunau writer now has no effects.
-  The aifc module now accepts lower case of names of the 'ulaw' and 'alaw'
-  codecs.
+  exception.  Second invocation of close() on sunau writer now has no
+  effects. The aifc module now accepts lower case of names of the 'ulaw' and
+  'alaw' codecs.
 
-- Issue #19131: The aifc module now correctly reads and writes sampwidth of
+- bpo-19131: The aifc module now correctly reads and writes sampwidth of
   compressed streams.
 
-- Issue #19158: A rare race in BoundedSemaphore could allow .release() too
+- bpo-19158: A rare race in BoundedSemaphore could allow .release() too
   often.
 
-- Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
+- bpo-18037: 2to3 now escapes '\u' and '\U' in native strings.
 
-- Issue #19137: The pprint module now correctly formats empty set and frozenset
+- bpo-19137: The pprint module now correctly formats empty set and frozenset
   and instances of set and frozenset subclasses.
 
-- Issue #16040: CVE-2013-1752: nntplib: Limit maximum line lengths to 2048 to
+- bpo-16040: CVE-2013-1752: nntplib: Limit maximum line lengths to 2048 to
   prevent readline() calls from consuming too much memory.  Patch by Jyrki
   Pulliainen.
 
-- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
-  when necessary.  Patch by Oscar Benjamin.
+- bpo-12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
+  when necessary. Patch by Oscar Benjamin.
 
 - Properly initialize all fields of a SSL object after allocation.
 
-- Issue #4366: Fix building extensions on all platforms when --enable-shared
-  is used.
+- bpo-4366: Fix building extensions on all platforms when --enable-shared is
+  used.
 
-- Issue #18950: Fix miscellaneous bugs in the sunau module.
+- bpo-18950: Fix miscellaneous bugs in the sunau module.
   Au_read.readframes() now updates current file position and reads correct
   number of frames from multichannel stream.  Au_write.writeframesraw() now
-  correctly updates current file position.  Au_read and Au_write now correctly
-  work with file object if start file position is not a zero.
+  correctly updates current file position.  Au_read and Au_write now
+  correctly work with file object if start file position is not a zero.
 
-- Issue #18050: Fixed an incompatibility of the re module with Python 2.7.3
-  and older binaries.
+- bpo-18050: Fixed an incompatibility of the re module with Python 2.7.3 and
+  older binaries.
 
-- Issue #19037: The mailbox module now makes all changes to maildir files
-  before moving them into place, to avoid race conditions with other programs
-  that may be accessing the maildir directory.
+- bpo-19037: The mailbox module now makes all changes to maildir files
+  before moving them into place, to avoid race conditions with other
+  programs that may be accessing the maildir directory.
 
-- Issue #14984: On POSIX systems, when netrc is called without a filename
+- bpo-14984: On POSIX systems, when netrc is called without a filename
   argument (and therefore is reading the user's $HOME/.netrc file), it now
-  enforces the same security rules as typical ftp clients: the .netrc file must
-  be owned by the user that owns the process and must not be readable by any
-  other user.
+  enforces the same security rules as typical ftp clients: the .netrc file
+  must be owned by the user that owns the process and must not be readable
+  by any other user.
 
-- Issue #17324: Fix http.server's request handling case on trailing '/'. Patch
+- bpo-17324: Fix http.server's request handling case on trailing '/'. Patch
   contributed by Vajrasky Kok.
 
-- Issue #19018: The heapq.merge() function no longer suppresses IndexError
-  in the underlying iterables.
+- bpo-19018: The heapq.merge() function no longer suppresses IndexError in
+  the underlying iterables.
 
-- Issue #18784: The uuid module no more attempts to load libc via ctypes.CDLL,
-  if all necessary functions are already found in libuuid.
-  Patch by Evgeny Sologubov.
+- bpo-18784: The uuid module no more attempts to load libc via ctypes.CDLL,
+  if all necessary functions are already found in libuuid. Patch by Evgeny
+  Sologubov.
 
-- Issue #14971: unittest test discovery no longer gets confused when a function
+- bpo-14971: unittest test discovery no longer gets confused when a function
   has a different __name__ than its name in the TestCase class dictionary.
 
-- Issue #18672: Fixed format specifiers for Py_ssize_t in debugging output in
+- bpo-18672: Fixed format specifiers for Py_ssize_t in debugging output in
   the _sre module.
 
-- Issue #18830: inspect.getclasstree() no more produces duplicated entries even
+- bpo-18830: inspect.getclasstree() no more produces duplicated entries even
   when input list contains duplicates.
 
-- Issue #18909: Fix _tkinter.tkapp.interpaddr() on Windows 64-bit, don't cast
+- bpo-18909: Fix _tkinter.tkapp.interpaddr() on Windows 64-bit, don't cast
   64-bit pointer to long (32 bits).
 
-- Issue #18876: The FileIO.mode attribute now better reflects the actual mode
+- bpo-18876: The FileIO.mode attribute now better reflects the actual mode
   under which the file was opened.  Patch by Erik Bray.
 
-- Issue #18851: Avoid a double close of subprocess pipes when the child
-  process fails starting.
+- bpo-18851: Avoid a double close of subprocess pipes when the child process
+  fails starting.
 
-- Issue #18418: After fork(), reinit all threads states, not only active ones.
+- bpo-18418: After fork(), reinit all threads states, not only active ones.
   Patch by A. Jesse Jiryu Davis.
 
-- Issue #11973: Fix a problem in kevent. The flags and fflags fields are now
+- bpo-11973: Fix a problem in kevent. The flags and fflags fields are now
   properly handled as unsigned.
 
-- Issue #16809: Fixed some tkinter incompatibilities with Tcl/Tk 8.6.
+- bpo-16809: Fixed some tkinter incompatibilities with Tcl/Tk 8.6.
 
-- Issue #16809: Tkinter's splitlist() and split() methods now accept Tcl_Obj
+- bpo-16809: Tkinter's splitlist() and split() methods now accept Tcl_Obj
   argument.
 
-- Issue #17119: Fixed integer overflows when processing large Unicode strings
+- bpo-17119: Fixed integer overflows when processing large Unicode strings
   and tuples in the tkinter module.
 
-- Issue #15233: Python now guarantees that callables registered with the atexit
+- bpo-15233: Python now guarantees that callables registered with the atexit
   module will be called in a deterministic order.
 
-- Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
-  pthread_atfork() parent handler is used to seed the PRNG with pid, time
+- bpo-18747: Re-seed OpenSSL's pseudo-random number generator after fork. A
+  pthread_atfork() parent handler is used to seed the PRNG with pid, time
   and some stack data.
 
-- Issue #8865: Concurrent invocation of select.poll.poll() now raises a
+- bpo-8865: Concurrent invocation of select.poll.poll() now raises a
   RuntimeError exception.  Patch by Christian Schubert.
 
-- Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit
+- bpo-13461: Fix a crash in the TextIOWrapper.tell method on 64-bit
   platforms.  Patch by Yogesh Chaudhari.
 
-- Issue #18777: The ssl module now uses the new CRYPTO_THREADID API of
-  OpenSSL 1.0.0+ instead of the deprecated CRYPTO id callback function.
+- bpo-18777: The ssl module now uses the new CRYPTO_THREADID API of OpenSSL
+  1.0.0+ instead of the deprecated CRYPTO id callback function.
 
-- Issue #18768: Correct doc string of RAND_edg(). Patch by Vajrasky Kok.
+- bpo-18768: Correct doc string of RAND_edg(). Patch by Vajrasky Kok.
 
-- Issue #18178: Fix ctypes on BSD. dlmalloc.c was compiled twice which broke
+- bpo-18178: Fix ctypes on BSD. dlmalloc.c was compiled twice which broke
   malloc weak symbols.
 
-- Issue #18709: Fix CVE-2013-4238. The SSL module now handles NULL bytes
-  inside subjectAltName correctly. Formerly the module has used OpenSSL's
+- bpo-18709: Fix CVE-2013-4238. The SSL module now handles NULL bytes inside
+  subjectAltName correctly. Formerly the module has used OpenSSL's
   GENERAL_NAME_print() function to get the string representation of ASN.1
   strings for ``rfc822Name`` (email), ``dNSName`` (DNS) and
   ``uniformResourceIdentifier`` (URI).
 
-- Issue #18756: Improve error reporting in os.urandom() when the failure
-  is due to something else than /dev/urandom not existing (for example,
-  exhausting the file descriptor limit).
+- bpo-18756: Improve error reporting in os.urandom() when the failure is due
+  to something else than /dev/urandom not existing (for example, exhausting
+  the file descriptor limit).
 
 - Fix tkinter regression introduced by the security fix in issue #16248.
 
-- Issue #18676: Change 'positive' to 'non-negative' in queue.py put and get
+- bpo-18676: Change 'positive' to 'non-negative' in queue.py put and get
   docstrings and ValueError messages. Patch by Zhongyue Luo
 
-- Issue #17998: Fix an internal error in regular expression engine.
+- bpo-17998: Fix an internal error in regular expression engine.
 
-- Issue #17557: Fix os.getgroups() to work with the modified behavior of
+- bpo-17557: Fix os.getgroups() to work with the modified behavior of
   getgroups(2) on OS X 10.8.  Original patch by Mateusz Lenik.
 
-- Issue #18455: multiprocessing should not retry connect() with same socket.
+- bpo-18455: multiprocessing should not retry connect() with same socket.
 
-- Issue #18513: Fix behaviour of cmath.rect w.r.t. signed zeros on OS X 10.8 +
+- bpo-18513: Fix behaviour of cmath.rect w.r.t. signed zeros on OS X 10.8 +
   gcc.
 
-- Issue #18101: Tcl.split() now process Unicode strings nested in a tuple as it
+- bpo-18101: Tcl.split() now process Unicode strings nested in a tuple as it
   do with byte strings.
 
-- Issue #18347: ElementTree's html serializer now preserves the case of
-  closing tags.
+- bpo-18347: ElementTree's html serializer now preserves the case of closing
+  tags.
 
-- Issue #17261: Ensure multiprocessing's proxies use proper address.
+- bpo-17261: Ensure multiprocessing's proxies use proper address.
 
-- Issue #17097: Make multiprocessing ignore EINTR.
+- bpo-17097: Make multiprocessing ignore EINTR.
 
-- Issue #18155: The csv module now correctly handles csv files that use
-  delimiter character that has a special meaning in regexes, instead of
+- bpo-18155: The csv module now correctly handles csv files that use a
+  delimiter character that has a special meaning in regexes, instead of
   throwing an exception.
 
-- Issue #18135: ssl.SSLSocket.write() now raises an OverflowError if the input
+- bpo-18135: ssl.SSLSocket.write() now raises an OverflowError if the input
   string in longer than 2 gigabytes. The ssl module does not support partial
   write.
 
-- Issue #18167: cgi.FieldStorage no longer fails to handle multipart/form-data
+- bpo-18167: cgi.FieldStorage no longer fails to handle multipart/form-data
   when \r\n appears at end of 65535 bytes without other newlines.
 
-- Issue #17403: urllib.parse.robotparser normalizes the urls before adding to
-  ruleline. This helps in handling certain types invalid urls in a conservative
-  manner. Patch contributed by Mher Movsisyan.
+- bpo-17403: urllib.parse.robotparser normalizes the urls before adding to
+  ruleline. This helps in handling certain types invalid urls in a
+  conservative manner. Patch contributed by Mher Movsisyan.
 
 - Implement inequality on weakref.WeakSet.
 
-- Issue #17981: Closed socket on error in SysLogHandler.
+- bpo-17981: Closed socket on error in SysLogHandler.
 
-- Issue #18015: Fix unpickling of 2.7.3 and 2.7.4 namedtuples.
+- bpo-18015: Fix unpickling of 2.7.3 and 2.7.4 namedtuples.
 
-- Issue #17754: Make ctypes.util.find_library() independent of the locale.
+- bpo-17754: Make ctypes.util.find_library() independent of the locale.
 
 - Fix typos in the multiprocessing module.
 
-- Issue #17269: Workaround for socket.getaddrinfo crash on MacOS X
-  with port None or "0" and flags AI_NUMERICSERV.
+- bpo-17269: Workaround for socket.getaddrinfo crash on MacOS X with port
+  None or "0" and flags AI_NUMERICSERV.
 
-- Issue #18080: When building a C extension module on OS X, if the compiler
-  is overridden with the CC environment variable, use the new compiler as
-  the default for linking if LDSHARED is not also overridden.  This restores
+- bpo-18080: When building a C extension module on OS X, if the compiler is
+  overridden with the CC environment variable, use the new compiler as the
+  default for linking if LDSHARED is not also overridden.  This restores
   Distutils behavior introduced in 2.7.3 and inadvertently dropped in 2.7.4.
 
-- Issue #18071: C extension module builds on OS X could fail with TypeError
-  if the Xcode command line tools were not installed.
+- bpo-18071: C extension module builds on OS X could fail with TypeError if
+  the Xcode command line tools were not installed.
 
-- Issue #18113: Fixed a refcount leak in the curses.panel module's
-  set_userptr() method.  Reported by Atsuo Ishimoto.
+- bpo-18113: Fixed a refcount leak in the curses.panel module's
+  set_userptr() method. Reported by Atsuo Ishimoto.
 
-- Issue #18849: Fixed a Windows-specific tempfile bug where collision with an
+- bpo-18849: Fixed a Windows-specific tempfile bug where collision with an
   existing directory caused mkstemp and related APIs to fail instead of
   retrying. Report and fix by Vlad Shcherbina.
 
-- Issue #19400: Prevent extension module build failures with Xcode 5 on OS X
-  10.8+ when using a universal Python that included a PPC architecture,
-  such as with a python.org 32-bit-only binary installer.
+- bpo-19400: Prevent extension module build failures with Xcode 5 on OS X
+  10.8+ when using a universal Python that included a PPC architecture, such
+  as with a python.org 32-bit-only binary installer.
 
 Tools/Demos
 -----------
 
-- Issue #18873: 2to3 and the findnocoding.py script now detect Python source
+- bpo-18873: 2to3 and the findnocoding.py script now detect Python source
   code encoding only in comment lines.
 
-- Issue #18817: Fix a resource warning in Lib/aifc.py demo.
+- bpo-18817: Fix a resource warning in Lib/aifc.py demo.
 
-- Issue #18439: Make patchcheck work on Windows for ACKS, NEWS.
+- bpo-18439: Make patchcheck work on Windows for ACKS, NEWS.
 
-- Issue #18448: Fix a typo in Demo/newmetaclasses/Eiffel.py.
+- bpo-18448: Fix a typo in Demo/newmetaclasses/Eiffel.py.
 
-- Issue #12990: The "Python Launcher" on OSX could not launch python scripts
+- bpo-12990: The "Python Launcher" on OSX could not launch python scripts
   that have paths that include wide characters.
 
 Build
 -----
 
-- Issue #16067: Add description into MSI file to replace installer's temporary name.
+- bpo-16067: Add description into MSI file to replace installer's temporary
+  name.
 
-- Issue #18256: Compilation fix for recent AIX releases.  Patch by
-  David Edelsohn.
+- bpo-18256: Compilation fix for recent AIX releases.  Patch by David
+  Edelsohn.
 
-- Issue #18098: The deprecated OS X Build Applet.app fails to build on
-  OS X 10.8 systems because the Apple-deprecated QuickDraw headers have
-  been removed from Xcode 4.  Skip building it in this case.
+- bpo-18098: The deprecated OS X Build Applet.app fails to build on OS X
+  10.8 systems because the Apple-deprecated QuickDraw headers have been
+  removed from Xcode 4.  Skip building it in this case.
 
-- Issue #1584: Provide options to override default search paths for
-  Tcl and Tk when building _tkinter.
+- bpo-1584: Provide options to override default search paths for Tcl and Tk
+  when building _tkinter.
 
-- Issue #15663: Tcl/Tk 8.5.15 is now included with the OS X 10.6+
-  64-bit/32-bit installer for 10.6+.  It is no longer necessary
-  to install a third-party version of Tcl/Tk 8.5 to work around the
-  problems in the Apple-supplied Tcl/Tk 8.5 shipped in OS X 10.6
-  and later releases.
+- bpo-15663: Tcl/Tk 8.5.15 is now included with the OS X 10.6+ 64-bit/32-bit
+  installer for 10.6+.  It is no longer necessary to install a third-party
+  version of Tcl/Tk 8.5 to work around the problems in the Apple-supplied
+  Tcl/Tk 8.5 shipped in OS X 10.6 and later releases.
 
-- Issue #19019: Change the OS X installer build script to use CFLAGS instead
-  of OPT for special build options.  By setting OPT, some compiler-specific
+- bpo-19019: Change the OS X installer build script to use CFLAGS instead of
+  OPT for special build options.  By setting OPT, some compiler-specific
   options like -fwrapv were overridden and thus not used, which could result
   in broken interpreters when building with clang.
 
 IDLE
 ----
 
-- Issue #18873: IDLE now detects Python source code encoding only in comment
+- bpo-18873: IDLE now detects Python source code encoding only in comment
   lines.
 
-- Issue #18988: The "Tab" key now works when a word is already autocompleted.
+- bpo-18988: The "Tab" key now works when a word is already autocompleted.
 
-- Issue #18489: Add tests for SearchEngine. Original patch by Phil Webster.
+- bpo-18489: Add tests for SearchEngine. Original patch by Phil Webster.
 
-- Issue #18429: Format / Format Paragraph, now works when comment blocks
-  are selected. As with text blocks, this works best when the selection
-  only includes complete lines.
+- bpo-18429: Format / Format Paragraph, now works when comment blocks are
+  selected. As with text blocks, this works best when the selection only
+  includes complete lines.
 
-- Issue #18226: Add docstrings and unittests for FormatParagraph.py.
-  Original patches by Todd Rovito and Phil Webster.
+- bpo-18226: Add docstrings and unittests for FormatParagraph.py. Original
+  patches by Todd Rovito and Phil Webster.
 
-- Issue #18279: Format - Strip trailing whitespace no longer marks a file as
+- bpo-18279: Format - Strip trailing whitespace no longer marks a file as
   changed when it has not been changed. This fix followed the addition of a
   test file originally written by Phil Webster (the issue's main goal).
 
-- Issue #18539: Calltips now work for float default arguments.
+- bpo-18539: Calltips now work for float default arguments.
 
-- Issue #7136: In the Idle File menu, "New Window" is renamed "New File".
-  Patch by Tal Einat, Roget Serwy, and Todd Rovito.
+- bpo-7136: In the Idle File menu, "New Window" is renamed "New File". Patch
+  by Tal Einat, Roget Serwy, and Todd Rovito.
 
-- Issue #8515: Set __file__ when run file in IDLE.
-  Initial patch by Bruce Frederiksen.
+- bpo-8515: Set __file__ when run file in IDLE. Initial patch by Bruce
+  Frederiksen.
 
-- Issue #5492: Avoid traceback when exiting IDLE caused by a race condition.
+- bpo-5492: Avoid traceback when exiting IDLE caused by a race condition.
 
-- Issue #17511: Keep IDLE find dialog open after clicking "Find Next".
-  Original patch by Sarah K.
+- bpo-17511: Keep IDLE find dialog open after clicking "Find Next". Original
+  patch by Sarah K.
 
-- Issue #15392: Create a unittest framework for IDLE.
-  Preliminary patch by Rajagopalasarma Jayakrishnan
-  See Lib/idlelib/idle_test/README.txt for how to run Idle tests.
+- bpo-15392: Create a unittest framework for IDLE. Preliminary patch by
+  Rajagopalasarma Jayakrishnan See Lib/idlelib/idle_test/README.txt for how
+  to run Idle tests.
 
-- Issue #14146: Highlight source line while debugging on Windows.
+- bpo-14146: Highlight source line while debugging on Windows.
 
-- Issue #17532: Always include Options menu for IDLE on OS X.
-  Patch by Guilherme Simões.
+- bpo-17532: Always include Options menu for IDLE on OS X. Patch by
+  Guilherme Simões.
 
 Tests
 -----
 
-- Issue #18919: Added tests for the sunau module.  Unified and extended tests
+- bpo-18919: Added tests for the sunau module.  Unified and extended tests
   for audio modules: aifc, sunau and wave.
 
-- Issue #18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as
+- bpo-18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as
   possible, since "localhost" goes through a DNS lookup under recent Windows
   versions.
 
-- Issue #18357: add tests for dictview set difference.
-  Patch by Fraser Tweedale.
+- bpo-18357: add tests for dictview set difference. Patch by Fraser
+  Tweedale.
 
-- Issue #11185: Fix test_wait4 under AIX.  Patch by Sébastien Sablé.
+- bpo-11185: Fix test_wait4 under AIX.  Patch by Sébastien Sablé.
 
-- Issue #18094: test_uuid no more reports skipped tests as passed.
+- bpo-18094: test_uuid no more reports skipped tests as passed.
 
-- Issue #11995: test_pydoc doesn't import all sys.path modules anymore.
+- bpo-11995: test_pydoc doesn't import all sys.path modules anymore.
 
 Documentation
 -------------
 
-- Issue #18758: Fixed and improved cross-references.
+- bpo-18758: Fixed and improved cross-references.
 
-- Issue #18718: datetime documentation contradictory on leap second support.
+- bpo-18718: datetime documentation contradictory on leap second support.
 
-- Issue #17701: Improving strftime documentation.
+- bpo-17701: Improving strftime documentation.
 
-- Issue #17844: Refactor a documentation of Python specific encodings.
-  Add links to encoders and decoders for binary-to-binary codecs.
+- bpo-17844: Refactor a documentation of Python specific encodings. Add
+  links to encoders and decoders for binary-to-binary codecs.
 
 
-What's New in Python 2.7.5?
-===========================
+What's New in Python 2.7.5 final?
+=================================
 
 *Release date: 2013-05-12*
 
 Core and Builtins
 -----------------
 
-- Issue #15535: Fixed regression in the pickling of named tuples by
-  removing the __dict__ property introduced in 2.7.4.
+- bpo-15535: Fixed regression in the pickling of named tuples by removing
+  the __dict__ property introduced in 2.7.4.
 
-- Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
-  such as was shipped with Centos 5 and Mac OS X 10.4.
+- bpo-17857: Prevent build failures with pre-3.5.0 versions of sqlite3, such
+  as was shipped with Centos 5 and Mac OS X 10.4.
 
-- Issue #17703: Fix a regression where an illegal use of Py_DECREF() after
+- bpo-17703: Fix a regression where an illegal use of Py_DECREF() after
   interpreter finalization can cause a crash.
 
-- Issue #16447: Fixed potential segmentation fault when setting __name__ on a
+- bpo-16447: Fixed potential segmentation fault when setting __name__ on a
   class.
 
-- Issue #17610: Don't rely on non-standard behavior of the C qsort() function.
+- bpo-17610: Don't rely on non-standard behavior of the C qsort() function.
 
 Library
 -------
 
-- Issue #17979: Fixed the re module in build with --disable-unicode.
+- bpo-17979: Fixed the re module in build with --disable-unicode.
 
-- Issue #17606: Fixed support of encoded byte strings in the XMLGenerator
- .characters() and ignorableWhitespace() methods.  Original patch by Sebastian
-  Ortiz Vasquez.
+- bpo-17606: Fixed support of encoded byte strings in the XMLGenerator
+  .characters() and ignorableWhitespace() methods.  Original patch by
+  Sebastian Ortiz Vasquez.
 
-- Issue #16601: Restarting iteration over tarfile no more continues from where
-  it left off.  Patch by Michael Birtwell.
+- bpo-16601: Restarting iteration over tarfile no more continues from where
+  it left off. Patch by Michael Birtwell.
 
-- Issue #16584: in filecomp._cmp, catch IOError as well as os.error.
-  Patch by Till Maas.
+- bpo-16584: in filecomp._cmp, catch IOError as well as os.error. Patch by
+  Till Maas.
 
-- Issue #17926: Fix dbm.__contains__ on 64-bit big-endian machines.
+- bpo-17926: Fix dbm.__contains__ on 64-bit big-endian machines.
 
-- Issue #19267: Fix support of multibyte encoding (ex: UTF-16) in the logging
+- bpo-19267: Fix support of multibyte encoding (ex: UTF-16) in the logging
   module.
 
-- Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed
-  on the new socket, the socket would linger indefinitely.  Thanks to
-  Peter Saveliev for reporting.
+- bpo-17918: When using SSLSocket.accept(), if the SSL handshake failed on
+  the new socket, the socket would linger indefinitely.  Thanks to Peter
+  Saveliev for reporting.
 
-- Issue #17289: The readline module now plays nicer with external modules
-  or applications changing the rl_completer_word_break_characters global
+- bpo-17289: The readline module now plays nicer with external modules or
+  applications changing the rl_completer_word_break_characters global
   variable.  Initial patch by Bradley Froehle.
 
-- Issue #12181: select module: Fix struct kevent definition on OpenBSD 64-bit
+- bpo-12181: select module: Fix struct kevent definition on OpenBSD 64-bit
   platforms. Patch by Federico Schwindt.
 
-- Issue #14173: Avoid crashing when reading a signal handler during
-  interpreter shutdown.
+- bpo-14173: Avoid crashing when reading a signal handler during interpreter
+  shutdown.
 
-- Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.
+- bpo-16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.
 
-- Issue #17192: Restore the patch for Issue #10309 which was ommitted
-  in 2.7.4 when updating the bundled version of libffi used by ctypes.
+- bpo-17192: Restore the patch for Issue #10309 which was ommitted in 2.7.4
+  when updating the bundled version of libffi used by ctypes.
 
-- Issue #17843: Removed test data file that was triggering false-positive virus
+- bpo-17843: Removed test data file that was triggering false-positive virus
   warnings with certain antivirus software.
 
-- Issue #17353: Plistlib emitted empty data tags with deeply nested datastructures
+- bpo-17353: Plistlib emitted empty data tags with deeply nested
+  datastructures
 
-- Issue #11714: Use 'with' statements to assure a Semaphore releases a
-  condition variable.  Original patch by Thomas Rachel.
+- bpo-11714: Use 'with' statements to assure a Semaphore releases a
+  condition variable. Original patch by Thomas Rachel.
 
-- Issue #17795: Reverted backwards-incompatible change in SysLogHandler with
+- bpo-17795: Reverted backwards-incompatible change in SysLogHandler with
   Unix domain sockets.
 
-- Issue #17555: Fix ForkAwareThreadLock so that size of after fork
-  registry does not grow exponentially with generation of process.
+- bpo-17555: Fix ForkAwareThreadLock so that size of after fork registry
+  does not grow exponentially with generation of process.
 
-- Issue #17710: Fix cPickle raising a SystemError on bogus input.
+- bpo-17710: Fix cPickle raising a SystemError on bogus input.
 
-- Issue #17341: Include the invalid name in the error messages from re about
+- bpo-17341: Include the invalid name in the error messages from re about
   invalid group names.
 
-- Issue #17016: Get rid of possible pointer wraparounds and integer overflows
+- bpo-17016: Get rid of possible pointer wraparounds and integer overflows
   in the re module.  Patch by Nickolai Zeldovich.
 
-- Issue #17536: Add to webbrowser's browser list: xdg-open, gvfs-open,
-  www-browser, x-www-browser, chromium browsers, iceweasel, iceape.
+- bpo-17536: Add to webbrowser's browser list: xdg-open, gvfs-open, www-
+  browser, x-www- browser, chromium browsers, iceweasel, iceape.
 
-- Issue #17656: Fix extraction of zip files with unicode member paths.
+- bpo-17656: Fix extraction of zip files with unicode member paths.
 
-- Issue #17666: Fix reading gzip files with an extra field.
+- bpo-17666: Fix reading gzip files with an extra field.
 
-- Issue #13150, #17512: sysconfig no longer parses the Makefile and config.h
-  files when imported, instead doing it at build time.  This makes importing
-  sysconfig faster and reduces Python startup time by 20%.
+- bpo-13150: sysconfig no longer parses the Makefile and config.h files when
+  imported, instead doing it at build time.  This makes importing sysconfig
+  faster and reduces Python startup time by 20%. (See also: bpo-17512)
 
-- Issue #13163: Rename operands in smtplib.SMTP._get_socket to correct names;
+- bpo-13163: Rename operands in smtplib.SMTP._get_socket to correct names;
   fixes otherwise misleading output in tracebacks and when when debug is on.
 
-- Issue #17526: fix an IndexError raised while passing code without filename to
+- bpo-17526: fix an IndexError raised while passing code without filename to
   inspect.findsource().  Initial patch by Tyler Doyle.
 
 Build
 -----
 
-- Issue #17547: In configure, explicitly pass -Wformat for the benefit for GCC
+- bpo-17547: In configure, explicitly pass -Wformat for the benefit for GCC
   4.8.
 
-- Issue #17682: Add the _io module to Modules/Setup.dist (commented out).
+- bpo-17682: Add the _io module to Modules/Setup.dist (commented out).
 
-- Issue #17086: Search the include and library directories provided by the
+- bpo-17086: Search the include and library directories provided by the
   compiler.
 
 Tests
 -----
 
-- Issue #17928: Fix test_structmembers on 64-bit big-endian machines.
+- bpo-17928: Fix test_structmembers on 64-bit big-endian machines.
 
-- Issue #17883: Fix buildbot testing of Tkinter on Windows.
-  Patch by Zachary Ware.
+- bpo-17883: Fix buildbot testing of Tkinter on Windows. Patch by Zachary
+  Ware.
 
-- Issue #7855: Add tests for ctypes/winreg for issues found in IronPython.
+- bpo-7855: Add tests for ctypes/winreg for issues found in IronPython.
   Initial patch by Dino Viehland.
 
-- Issue #17712: Fix test_gdb failures on Ubuntu 13.04.
+- bpo-17712: Fix test_gdb failures on Ubuntu 13.04.
 
-- Issue #17065: Use process-unique key for winreg tests to avoid failures if
+- bpo-17065: Use process-unique key for winreg tests to avoid failures if
   test is run multiple times in parallel (eg: on a buildbot host).
 
 IDLE
 ----
 
-- Issue #17838: Allow sys.stdin to be reassigned.
+- bpo-17838: Allow sys.stdin to be reassigned.
 
-- Issue #14735: Update IDLE docs to omit "Control-z on Windows".
+- bpo-14735: Update IDLE docs to omit "Control-z on Windows".
 
-- Issue #17585: Fixed IDLE regression. Now closes when using exit() or quit().
+- bpo-17585: Fixed IDLE regression. Now closes when using exit() or quit().
 
-- Issue #17657: Show full Tk version in IDLE's about dialog.
-  Patch by Todd Rovito.
+- bpo-17657: Show full Tk version in IDLE's about dialog. Patch by Todd
+  Rovito.
 
-- Issue #17613: Prevent traceback when removing syntax colorizer in IDLE.
+- bpo-17613: Prevent traceback when removing syntax colorizer in IDLE.
 
-- Issue #1207589: Backwards-compatibility patch for right-click menu in IDLE.
+- bpo-1207589: Backwards-compatibility patch for right-click menu in IDLE.
 
-- Issue #16887: IDLE now accepts Cancel in tabify/untabify dialog box.
+- bpo-16887: IDLE now accepts Cancel in tabify/untabify dialog box.
 
-- Issue #14254: IDLE now handles readline correctly across shell restarts.
+- bpo-14254: IDLE now handles readline correctly across shell restarts.
 
-- Issue #17614: IDLE no longer raises exception when quickly closing a file.
+- bpo-17614: IDLE no longer raises exception when quickly closing a file.
 
-- Issue #6698: IDLE now opens just an editor window when configured to do so.
+- bpo-6698: IDLE now opens just an editor window when configured to do so.
 
-- Issue #8900: Using keyboard shortcuts in IDLE to open a file no longer
-  raises an exception.
+- bpo-8900: Using keyboard shortcuts in IDLE to open a file no longer raises
+  an exception.
 
-- Issue #6649: Fixed missing exit status in IDLE. Patch by Guilherme Polo.
+- bpo-6649: Fixed missing exit status in IDLE. Patch by Guilherme Polo.
 
-- Issue #17390: Display Python version on Idle title bar.
-  Initial patch by Edmond Burnett.
+- bpo-17390: Display Python version on Idle title bar. Initial patch by
+  Edmond Burnett.
 
 Documentation
 -------------
 
-- Issue #15940: Specify effect of locale on time functions.
+- bpo-15940: Specify effect of locale on time functions.
 
-- Issue #6696: add documentation for the Profile objects, and improve
+- bpo-6696: add documentation for the Profile objects, and improve
   profile/cProfile docs.  Patch by Tom Pinckney.
 
 
-What's New in Python 2.7.4?
-===========================
+What's New in Python 2.7.4 final?
+=================================
 
 *Release date: 2013-04-06*
 
 Build
 -----
 
-- Issue #17550: Fix the --enable-profiling configure switch.
+- bpo-17550: Fix the --enable-profiling configure switch.
 
 Core and Builtins
 -----------------
 
-- Issue #15801 (again): With string % formatting, relax the type check for a
-  mapping such that any type with a __getitem__ can be used on the right hand
-  side.
+- bpo-15801: With string % formatting, relax the type check for a mapping
+  such that any type with a __getitem__ can be used on the right hand side.
 
 IDLE
 ----
 
-- Issue #17625: In IDLE, close the replace dialog after it is used.
+- bpo-17625: In IDLE, close the replace dialog after it is used.
 
 Tests
 -----
 
-- Issue #17835: Fix test_io when the default OS pipe buffer size is larger
-  than one million bytes.
+- bpo-17835: Fix test_io when the default OS pipe buffer size is larger than
+  one million bytes.
 
-- Issue #17531: Fix tests that thought group and user ids were always the int
+- bpo-17531: Fix tests that thought group and user ids were always the int
   type. Also, always allow -1 as a valid group and user id.
 
-- Issue #17533: Fix test_xpickle with older versions of Python 2.5.
+- bpo-17533: Fix test_xpickle with older versions of Python 2.5.
 
 Documentation
 -------------
 
-- Issue #17538: Document XML vulnerabilties
+- bpo-17538: Document XML vulnerabilties
 
 
-What's New in Python 2.7.4 release candidate 1
-==============================================
+What's New in Python 2.7.4 release candidate 1?
+===============================================
 
 *Release date: 2013-03-23*
 
 Core and Builtins
 -----------------
 
-- Issue #10211: Buffer objects expose the new buffer interface internally
+- bpo-10211: Buffer objects expose the new buffer interface internally
 
-- Issue #16445: Fixed potential segmentation fault when deleting an exception
+- bpo-16445: Fixed potential segmentation fault when deleting an exception
   message.
 
-- Issue #17275: Corrected class name in init error messages of the C version of
+- bpo-17275: Corrected class name in init error messages of the C version of
   BufferedWriter and BufferedRandom.
 
-- Issue #7963: Fixed misleading error message that issued when object is
-  called without arguments.
+- bpo-7963: Fixed misleading error message that issued when object is called
+  without arguments.
 
-- Issue #5308: Raise ValueError when marshalling too large object (a sequence
+- bpo-5308: Raise ValueError when marshalling too large object (a sequence
   with size >= 2**31), instead of producing illegal marshal data.
 
-- Issue #17043: The unicode-internal decoder no longer read past the end of
+- bpo-17043: The unicode-internal decoder no longer read past the end of
   input buffer.
 
-- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder.
+- bpo-16979: Fix error handling bugs in the unicode-escape-decode decoder.
 
-- Issue #10156: In the interpreter's initialization phase, unicode globals
-  are now initialized dynamically as needed.
+- bpo-10156: In the interpreter's initialization phase, unicode globals are
+  now initialized dynamically as needed.
 
-- Issue #16975: Fix error handling bug in the escape-decode decoder.
+- bpo-16975: Fix error handling bug in the escape-decode decoder.
 
-- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping"
-  in any mapping, not only in a Unicode string.
+- bpo-14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in
+  any mapping, not only in a Unicode string.
 
-- Issue #11461: Fix the incremental UTF-16 decoder. Original patch by
-  Amaury Forgeot d'Arc.
+- bpo-11461: Fix the incremental UTF-16 decoder. Original patch by Amaury
+  Forgeot d'Arc.
 
-- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
+- bpo-16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
 
-- Issue #15516: Fix a bug in PyString_FromFormat where it failed to properly
+- bpo-15516: Fix a bug in PyString_FromFormat where it failed to properly
   ignore errors from a __int__() method.
 
-- Issue #16839: Fix a segfault when calling unicode() on a classic class early
+- bpo-16839: Fix a segfault when calling unicode() on a classic class early
   in interpreter initialization.
 
-- Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only
-  now raises TypeError.
+- bpo-16761: Calling ``int()`` and ``long()`` with *base* argument only now
+  raises TypeError.
 
-- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py
-  when retrieving a REG_DWORD value. This corrects functions like
+- bpo-16759: Support the full DWORD (unsigned long) range in Reg2Py when
+  retrieving a REG_DWORD value. This corrects functions like
   winreg.QueryValueEx that may have been returning truncated values.
 
-- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg
-  when passed a REG_DWORD value. Fixes ValueError in winreg.SetValueEx when
-  given a long.
+- bpo-14420: Support the full DWORD (unsigned long) range in Py2Reg when
+  passed a REG_DWORD value. Fixes ValueError in winreg.SetValueEx when given
+  a long.
 
-- Issue #13863: Work around buggy 'fstat' implementation on Windows / NTFS that
-  lead to incorrect timestamps (off by one hour) being stored in .pyc files on
-  some systems.
+- bpo-13863: Work around buggy 'fstat' implementation on Windows / NTFS that
+  lead to incorrect timestamps (off by one hour) being stored in .pyc files
+  on some systems.
 
-- Issue #16602: When a weakref's target was part of a long deallocation
-  chain, the object could remain reachable through its weakref even though
-  its refcount had dropped to zero.
+- bpo-16602: When a weakref's target was part of a long deallocation chain,
+  the object could remain reachable through its weakref even though its
+  refcount had dropped to zero.
 
-- Issue #9011: Fix hacky AST code that modified the CST when compiling
-  negated numeric literal.
+- bpo-9011: Fix hacky AST code that modified the CST when compiling a
+  negated numeric literal.
 
-- Issue #16306: Fix multiple error messages when unknown command line
+- bpo-16306: Fix multiple error messages when unknown command line
   parameters where passed to the interpreter.  Patch by Hieu Nguyen.
 
-- Issue #15379: Fix passing of non-BMP characters as integers for the charmap
+- bpo-15379: Fix passing of non-BMP characters as integers for the charmap
   decoder (already working as unicode strings).  Patch by Serhiy Storchaka.
 
-- Issue #16453: Fix equality testing of dead weakref objects.
+- bpo-16453: Fix equality testing of dead weakref objects.
 
-- Issue #9535: Fix pending signals that have been received but not yet
-  handled by Python to not persist after os.fork() in the child process.
+- bpo-9535: Fix pending signals that have been received but not yet handled
+  by Python to not persist after os.fork() in the child process.
 
-- Issue #15001: fix segfault on "del sys.modules['__main__']". Patch by Victor
+- bpo-15001: fix segfault on "del sys.modules['__main__']". Patch by Victor
   Stinner.
 
-- Issue #5057: the peepholer no longer optimizes subscription on unicode
+- bpo-5057: the peepholer no longer optimizes subscription on unicode
   literals (e.g. u'foo'[0]) in order to produce compatible pyc files between
   narrow and wide builds.
 
-- Issue #8401: assigning an int to a bytearray slice (e.g. b[3:4] = 5) now
+- bpo-8401: assigning an int to a bytearray slice (e.g. b[3:4] = 5) now
   raises an error.
 
-- Issue #14700: Fix buggy overflow checks for large width and precision
-  in string formatting operations.
+- bpo-14700: Fix buggy overflow checks for large width and precision in
+  string formatting operations.
 
-- Issue #16345: Fix an infinite loop when ``fromkeys`` on a dict subclass
+- bpo-16345: Fix an infinite loop when ``fromkeys`` on a dict subclass
   received a nonempty dict from the constructor.
 
-- Issue #6074: Ensure cached bytecode files can always be updated by the
-  user that created them, even when the source file is read-only.
+- bpo-6074: Ensure cached bytecode files can always be updated by the user
+  that created them, even when the source file is read-only.
 
-- Issue #14783: Improve int() and long() docstrings and switch docstrings for
+- bpo-14783: Improve int() and long() docstrings and switch docstrings for
   unicode(), slice(), range(), and xrange() to use multi-line signatures.
 
-- Issue #16030: Fix overflow bug in computing the `repr` of an xrange object
+- bpo-16030: Fix overflow bug in computing the `repr` of an xrange object
   with large start, step or length.
 
-- Issue #16029: Fix overflow bug occurring when pickling xranges with large
+- bpo-16029: Fix overflow bug occurring when pickling xranges with large
   start, step or length.
 
-- Issue #16037: Limit httplib's _read_status() function to work around broken
+- bpo-16037: Limit httplib's _read_status() function to work around broken
   HTTP servers and reduce memory usage. It's actually a backport of a Python
   3.2 fix. Thanks to Adrien Kunysz.
 
-- Issue #16588: Silence unused-but-set warnings in Python/thread_pthread
+- bpo-16588: Silence unused-but-set warnings in Python/thread_pthread
 
-- Issue #13992: The trashcan mechanism is now thread-safe.  This eliminates
+- bpo-13992: The trashcan mechanism is now thread-safe.  This eliminates
   sporadic crashes in multi-thread programs when several long deallocator
   chains ran concurrently and involved subclasses of built-in container
   types.
 
-- Issue #15801: Make sure mappings passed to '%' formatting are actually
+- bpo-15801: Make sure mappings passed to '%' formatting are actually
   subscriptable.
 
-- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
-  errors correctly.  Patch by Serhiy Storchaka.
+- bpo-15604: Update uses of PyObject_IsTrue() to check for and handle errors
+  correctly. Patch by Serhiy Storchaka.
 
-- Issue #14579: Fix error handling bug in the utf-16 decoder.  Patch by
-  Serhiy Storchaka.
+- bpo-14579: Fix error handling bug in the utf-16 decoder.  Patch by Serhiy
+  Storchaka.
 
-- Issue #15368: An issue that caused bytecode generation to be
-  non-deterministic when using randomized hashing (-R) has been fixed.
+- bpo-15368: An issue that caused bytecode generation to be non-
+  deterministic when using randomized hashing (-R) has been fixed.
 
-- Issue #15897: zipimport.c doesn't check return value of fseek().
-  Patch by Felipe Cruz.
+- bpo-15897: zipimport.c doesn't check return value of fseek(). Patch by
+  Felipe Cruz.
 
-- Issue #16369: Global PyTypeObjects not initialized with PyType_Ready(...).
+- bpo-16369: Global PyTypeObjects not initialized with PyType_Ready(...).
 
-- Issue #15033: Fix the exit status bug when modules invoked using -m switch,
-  return the proper failure return value (1). Patch contributed by Jeff Knupp.
+- bpo-15033: Fix the exit status bug when modules invoked using -m switch,
+  return the proper failure return value (1). Patch contributed by Jeff
+  Knupp.
 
-- Issue #12268: File readline, readlines and read() methods no longer lose
-  data when an underlying read system call is interrupted.  IOError is no
-  longer raised due to a read system call returning EINTR from within these
+- bpo-12268: File readline, readlines and read() methods no longer lose data
+  when an underlying read system call is interrupted.  IOError is no longer
+  raised due to a read system call returning EINTR from within these
   methods.
 
-- Issue #13512: Create ~/.pypirc securely (CVE-2011-4944).  Initial patch by
+- bpo-13512: Create ~/.pypirc securely (CVE-2011-4944).  Initial patch by
   Philip Jenvey, tested by Mageia and Debian.
 
-- Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later
+- bpo-7719: Make distutils ignore ``.nfs*`` files instead of choking later
   on.  Initial patch by SilentGhost and Jeff Ramnani.
 
-- Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on
+- bpo-10053: Don't close FDs when FileIO.__init__ fails. Loosely based on
   the work by Hirokazu Yamamoto.
 
-- Issue #14775: Fix a potential quadratic dict build-up due to the garbage
+- bpo-14775: Fix a potential quadratic dict build-up due to the garbage
   collector repeatedly trying to untrack dicts.
 
-- Issue #14494: Fix __future__.py and its documentation to note that
-  absolute imports are the default behavior in 3.0 instead of 2.7.
-  Patch by Sven Marnach.
+- bpo-14494: Fix __future__.py and its documentation to note that absolute
+  imports are the default behavior in 3.0 instead of 2.7. Patch by Sven
+  Marnach.
 
-- Issue #14761: Fix potential leak on an error case in the import machinery.
+- bpo-14761: Fix potential leak on an error case in the import machinery.
 
-- Issue #14699: Fix calling the classmethod descriptor directly.
+- bpo-14699: Fix calling the classmethod descriptor directly.
 
-- Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError
-  when repr() or str() is called on such an object.
+- bpo-11603: Setting __repr__ to __str__ now raises a RuntimeError when
+  repr() or str() is called on such an object.
 
-- Issue #14658: Fix binding a special method to a builtin implementation of a
+- bpo-14658: Fix binding a special method to a builtin implementation of a
   special method with a different name.
 
-- Issue #14612: Fix jumping around with blocks by setting f_lineno.
+- bpo-14612: Fix jumping around with blocks by setting f_lineno.
 
-- Issue #13889: Check and (if necessary) set FPU control word before calling
+- bpo-13889: Check and (if necessary) set FPU control word before calling
   any of the dtoa.c string <-> float conversion functions, on MSVC builds of
-  Python.  This fixes issues when embedding Python in a Delphi app.
+  Python. This fixes issues when embedding Python in a Delphi app.
 
-- Issue #14505: Fix file descriptor leak when deallocating file objects
-  created with PyFile_FromString().
+- bpo-14505: Fix file descriptor leak when deallocating file objects created
+  with PyFile_FromString().
 
-- Issue #14474: Save and restore exception state in thread.start_new_thread()
+- bpo-14474: Save and restore exception state in thread.start_new_thread()
   while writing error message if the thread leaves an unhandled exception.
 
-- Issue #13019: Fix potential reference leaks in bytearray.extend().  Patch
-  by Suman Saha.
+- bpo-13019: Fix potential reference leaks in bytearray.extend().  Patch by
+  Suman Saha.
 
-- Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as
-  the module name that was not interned.
+- bpo-14378: Fix compiling ast.ImportFrom nodes with a "__future__" string
+  as the module name that was not interned.
 
-- Issue #14331: Use significantly less stack space when importing modules by
+- bpo-14331: Use significantly less stack space when importing modules by
   allocating path buffers on the heap instead of the stack.
 
-- Issue #14334: Prevent in a segfault in type.__getattribute__ when it was not
+- bpo-14334: Prevent in a segfault in type.__getattribute__ when it was not
   passed strings. Also fix segfaults in the __getattribute__ and __setattr__
   methods of old-style classes.
 
-- Issue #14161: fix the __repr__ of file objects to escape the file name.
+- bpo-14161: fix the __repr__ of file objects to escape the file name.
 
-- Issue #1469629: Allow cycles through an object's __dict__ slot to be
+- bpo-1469629: Allow cycles through an object's __dict__ slot to be
   collected. (For example if ``x.__dict__ is x``).
 
-- Issue #13521: dict.setdefault() now does only one lookup for the given key,
+- bpo-13521: dict.setdefault() now does only one lookup for the given key,
   making it "atomic" for many purposes.  Patch by Filip Gruszczyński.
 
-- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
-  now fills the ``os.environ`` variable correctly.
+- bpo-1602133: on Mac OS X a shared library build (``--enable-shared``) now
+  fills the ``os.environ`` variable correctly.
 
-- Issue #10538: When using the "s*" code with PyArg_ParseTuple() to fill a
+- bpo-10538: When using the "s*" code with PyArg_ParseTuple() to fill a
   Py_buffer structure with data from an object supporting only the old
-  PyBuffer interface, a reference to the source objects is now properly added
-  to the Py_buffer.obj member.
+  PyBuffer interface, a reference to the source objects is now properly
+  added to the Py_buffer.obj member.
 
 Library
 -------
 
-- Issue #12718: Fix interaction with winpdb overriding __import__ by setting
+- bpo-12718: Fix interaction with winpdb overriding __import__ by setting
   importer attribute on BaseConfigurator instance.
 
-- Issue #17521: Corrected non-enabling of logger following two calls to
+- bpo-17521: Corrected non-enabling of logger following two calls to
   fileConfig().
 
-- Issue #17508: Corrected MemoryHandler configuration in dictConfig() where
-  the target handler wasn't configured first.
+- bpo-17508: Corrected MemoryHandler configuration in dictConfig() where the
+  target handler wasn't configured first.
 
-- Issue #10212: cStringIO and struct.unpack support new buffer objects.
+- bpo-10212: cStringIO and struct.unpack support new buffer objects.
 
-- Issue #12098: multiprocessing on Windows now starts child processes
-  using the same sys.flags as the current process.  Initial patch by
-  Sergey Mezentsev.
+- bpo-12098: multiprocessing on Windows now starts child processes using the
+  same sys.flags as the current process.  Initial patch by Sergey Mezentsev.
 
-- Issue #8862: Fixed curses cleanup when getkey is interrupted by a signal.
+- bpo-8862: Fixed curses cleanup when getkey is interrupted by a signal.
 
-- Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
+- bpo-9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
   retry the select() loop instead of bailing out.  This is because select()
   can incorrectly report a socket as ready for reading (for example, if it
   received some data with an invalid checksum).
 
-- Issue #1285086: Get rid of the refcounting hack and speed up urllib.unquote().
+- bpo-1285086: Get rid of the refcounting hack and speed up
+  urllib.unquote().
 
-- Issue #17368: Fix an off-by-one error in the Python JSON decoder that caused
+- bpo-17368: Fix an off-by-one error in the Python JSON decoder that caused
   a failure while decoding empty object literals when object_pairs_hook was
   specified.
 
-- Issue #17278: Fix a crash in heapq.heappush() and heapq.heappop() when
-  the list is being resized concurrently.
+- bpo-17278: Fix a crash in heapq.heappush() and heapq.heappop() when the
+  list is being resized concurrently.
 
-- Issue #17018: Make Process.join() retry if os.waitpid() fails with EINTR.
+- bpo-17018: Make Process.join() retry if os.waitpid() fails with EINTR.
 
-- Issue #14720: sqlite3: Convert datetime microseconds correctly.
-  Patch by Lowe Thiderman.
+- bpo-14720: sqlite3: Convert datetime microseconds correctly. Patch by Lowe
+  Thiderman.
 
-- Issue #17225: JSON decoder now counts columns in the first line starting
-  with 1, as in other lines.
+- bpo-17225: JSON decoder now counts columns in the first line starting with
+  1, as in other lines.
 
-- Issue #7842: backported fix for py_compile.compile() syntax error handling.
+- bpo-7842: backported fix for py_compile.compile() syntax error handling.
 
-- Issue #13153: Tkinter functions now raise TclError instead of ValueError when
+- bpo-13153: Tkinter functions now raise TclError instead of ValueError when
   a unicode argument contains non-BMP character.
 
-- Issue #9669: Protect re against infinite loops on zero-width matching in
-  non-greedy repeat.  Patch by Matthew Barnett.
+- bpo-9669: Protect re against infinite loops on zero-width matching in non-
+  greedy repeat.  Patch by Matthew Barnett.
 
-- Issue #13169: The maximal repetition number in a regular expression has been
+- bpo-13169: The maximal repetition number in a regular expression has been
   increased from 65534 to 2147483647 (on 32-bit platform) or 4294967294 (on
   64-bit).
 
-- Issue #16743: Fix mmap overflow check on 32 bit Windows.
+- bpo-16743: Fix mmap overflow check on 32 bit Windows.
 
-- Issue #11311: StringIO.readline(0) now returns an empty string as all other
+- bpo-11311: StringIO.readline(0) now returns an empty string as all other
   file-like objects.
 
-- Issue #16800: tempfile.gettempdir() no longer left temporary files when
-  the disk is full.  Original patch by Amir Szekely.
+- bpo-16800: tempfile.gettempdir() no longer left temporary files when the
+  disk is full. Original patch by Amir Szekely.
 
-- Issue #13555: cPickle now supports files larger than 2 GiB.
+- bpo-13555: cPickle now supports files larger than 2 GiB.
 
-- Issue #17052: unittest discovery should use self.testLoader.
+- bpo-17052: unittest discovery should use self.testLoader.
 
-- Issue #4591: Uid and gid values larger than 2**31 are supported now.
+- bpo-4591: Uid and gid values larger than 2**31 are supported now.
 
-- Issue #17141: random.vonmisesvariate() no more hangs for large kappas.
+- bpo-17141: random.vonmisesvariate() no more hangs for large kappas.
 
-- Issue #17149: Fix random.vonmisesvariate to always return results in
-  the range [0, 2*math.pi].
+- bpo-17149: Fix random.vonmisesvariate to always return results in the
+  range [0, 2*math.pi].
 
-- Issue #1470548: XMLGenerator now works with UTF-16 and UTF-32 encodings.
+- bpo-1470548: XMLGenerator now works with UTF-16 and UTF-32 encodings.
 
-- Issue #6975: os.path.realpath() now correctly resolves multiple nested
+- bpo-6975: os.path.realpath() now correctly resolves multiple nested
   symlinks on POSIX platforms.
 
-- Issue #7358: cStringIO.StringIO now supports writing to and reading from
-  stream larger than 2 GiB on 64-bit systems.
+- bpo-7358: cStringIO.StringIO now supports writing to and reading from a
+  stream larger than 2 GiB on 64-bit systems.
 
-- Issue #10355: In SpooledTemporaryFile class mode and name properties and
+- bpo-10355: In SpooledTemporaryFile class mode and name properties and
   xreadlines method now work for unrolled files.  encoding and newlines
   properties now removed as they have no sense and always produced
   AttributeError.
 
-- Issue #16686: Fixed a lot of bugs in audioop module.  Fixed crashes in
-  avgpp(), maxpp() and ratecv().  Fixed an integer overflow in add(), bias(),
-  and ratecv().  reverse(), lin2lin() and ratecv() no more lose precision for
-  32-bit samples.  max() and rms() no more returns a negative result and
-  various other functions now work correctly with 32-bit sample -0x80000000.
+- bpo-16686: Fixed a lot of bugs in audioop module.  Fixed crashes in
+  avgpp(), maxpp() and ratecv().  Fixed an integer overflow in add(),
+  bias(), and ratecv(). reverse(), lin2lin() and ratecv() no more lose
+  precision for 32-bit samples. max() and rms() no more returns a negative
+  result and various other functions now work correctly with 32-bit sample
+  -0x80000000.
 
-- Issue #17073: Fix some integer overflows in sqlite3 module.
+- bpo-17073: Fix some integer overflows in sqlite3 module.
 
-- Issue #6083: Fix multiple segmentation faults occurred when PyArg_ParseTuple
+- bpo-6083: Fix multiple segmentation faults occurred when PyArg_ParseTuple
   parses nested mutating sequence.
 
-- Issue #5289: Fix ctypes.util.find_library on Solaris.
+- bpo-5289: Fix ctypes.util.find_library on Solaris.
 
-- Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
+- bpo-17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
   stream or a decoder produces data of an unexpected type (i.e. when
-  io.TextIOWrapper initialized with text stream or use bytes-to-bytes codec).
+  io.TextIOWrapper initialized with text stream or use bytes-to-bytes
+  codec).
 
-- Issue #13994: Add compatibility alias in distutils.ccompiler for
+- bpo-13994: Add compatibility alias in distutils.ccompiler for
   distutils.sysconfig.customize_compiler.
 
-- Issue #15633: httplib.HTTPResponse is now mark closed when the server
-  sends less than the advertised Content-Length.
+- bpo-15633: httplib.HTTPResponse is now mark closed when the server sends
+  less than the advertised Content-Length.
 
-- Issue #15881: Fixed atexit hook in multiprocessing.
+- bpo-15881: Fixed atexit hook in multiprocessing.
 
-- Issue #14340: Upgrade the embedded expat library to version 2.1.0.
+- bpo-14340: Upgrade the embedded expat library to version 2.1.0.
 
-- Issue #11159: SAX parser now supports unicode file names.
+- bpo-11159: SAX parser now supports unicode file names.
 
-- Issue #6972: The zipfile module no longer overwrites files outside of
-  its destination path when extracting malicious zip files.
+- bpo-6972: The zipfile module no longer overwrites files outside of its
+  destination path when extracting malicious zip files.
 
-- Issue #17049: Localized calendar methods now return unicode if a locale
+- bpo-17049: Localized calendar methods now return unicode if a locale
   includes an encoding and the result string contains month or weekday (was
   regression from Python 2.6).
 
-- Issue #4844: ZipFile now raises BadZipfile when opens a ZIP file with an
+- bpo-4844: ZipFile now raises BadZipfile when opens a ZIP file with an
   incomplete "End of Central Directory" record.  Original patch by Guilherme
   Polo and Alan McIntyre.
 
-- Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is
+- bpo-15505: `unittest.installHandler` no longer assumes SIGINT handler is
   set to a callable object.
 
-- Issue #17051: Fix a memory leak in os.path.isdir() on Windows. Patch by
+- bpo-17051: Fix a memory leak in os.path.isdir() on Windows. Patch by
   Robert Xiao.
 
-- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee()
-  if all other iterators were very advanced before.
+- bpo-13454: Fix a crash when deleting an iterator created by
+  itertools.tee() if all other iterators were very advanced before.
 
-- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file
+- bpo-16992: On Windows in signal.set_wakeup_fd, validate the file
   descriptor argument.
 
-- Issue #15861: tkinter now correctly works with lists and tuples containing
+- bpo-15861: tkinter now correctly works with lists and tuples containing
   strings with whitespaces, backslashes or unbalanced braces.
 
-- Issue #10527: Use poll() instead of select() for multiprocessing pipes.
+- bpo-10527: Use poll() instead of select() for multiprocessing pipes.
 
-- Issue #9720: zipfile now writes correct local headers for files larger than
-  GiB.
+- bpo-9720: zipfile now writes correct local headers for files larger than 4
+  GiB.
 
-- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals
-  when used inside character classes (e.g. '[\A]').  Patch by Matthew Barnett.
+- bpo-13899: \A, \Z, and \B now correctly match the A, Z, and B literals
+  when used inside character classes (e.g. '[\A]').  Patch by Matthew
+  Barnett.
 
-- Issue #16398: Optimize deque.rotate() so that it only moves pointers
-  and doesn't touch the underlying data with increfs and decrefs.
+- bpo-16398: Optimize deque.rotate() so that it only moves pointers and
+  doesn't touch the underlying data with increfs and decrefs.
 
-- Issue #15109: Fix regression in sqlite3's iterdump method where it would
-  die with an encoding error if the database contained string values
-  containing non-ASCII.  (Regression was introduced by fix for 9750).
+- bpo-15109: Fix regression in sqlite3's iterdump method where it would die
+  with an encoding error if the database contained string values containing
+  non-ASCII. (Regression was introduced by fix for 9750).
 
-- Issue #15545: Fix regression in sqlite3's iterdump method where it was
+- bpo-15545: Fix regression in sqlite3's iterdump method where it was
   failing if the connection used a row factory (such as sqlite3.Row) that
   produced unsortable objects. (Regression was introduced by fix for 9750).
 
-- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by
+- bpo-16828: Fix error incorrectly raised by bz2.compress(''). Patch by
   Martin Packman.
 
-- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy.
+- bpo-9586: Redefine SEM_FAILED on MacOSX to keep compiler happy.
 
-- Issue #10527: make multiprocessing use poll() instead of select() if available.
+- bpo-10527: make multiprocessing use poll() instead of select() if
+  available.
 
-- Issue #16485: Now file descriptors are closed if file header patching failed
+- bpo-16485: Now file descriptors are closed if file header patching failed
   on closing an aifc file.
 
-- Issue #12065: connect_ex() on an SSL socket now returns the original errno
+- bpo-12065: connect_ex() on an SSL socket now returns the original errno
   when the socket's timeout expires (it used to return None).
 
-- Issue #16713: Fix the parsing of tel url with params using urlparse module.
+- bpo-16713: Fix the parsing of tel url with params using urlparse module.
 
-- Issue #16443: Add docstrings to regular expression match objects.
-  Patch by Anton Kasyanov.
+- bpo-16443: Add docstrings to regular expression match objects. Patch by
+  Anton Kasyanov.
 
-- Issue #8853: Allow port to be of type long for socket.getaddrinfo().
+- bpo-8853: Allow port to be of type long for socket.getaddrinfo().
 
-- Issue #16597: In buffered and text IO, call close() on the underlying stream
+- bpo-16597: In buffered and text IO, call close() on the underlying stream
   if invoking flush() fails.
 
-- Issue #15701: Fix HTTPError info method call to return the headers information.
+- bpo-15701: Fix HTTPError info method call to return the headers
+  information.
 
-- Issue #16646: ftplib.FTP.makeport() might lose socket error details.
-  (patch by Serhiy Storchaka)
+- bpo-16646: ftplib.FTP.makeport() might lose socket error details. (patch
+  by Serhiy Storchaka)
 
-- Issue #16626: Fix infinite recursion in glob.glob() on Windows when the
+- bpo-16626: Fix infinite recursion in glob.glob() on Windows when the
   pattern contains a wildcard in the drive or UNC path.  Patch by Serhiy
   Storchaka.
 
-- Issue #16298: In HTTPResponse.read(), close the socket when there is no
+- bpo-16298: In HTTPResponse.read(), close the socket when there is no
   Content-Length and the incoming stream is finished.  Patch by Eran
   Rundstein.
 
-- Issue #16248: Disable code execution from the user's home directory by
+- bpo-16248: Disable code execution from the user's home directory by
   tkinter when the -E flag is passed to Python.  Patch by Zachary Ware.
 
-- Issue #16628: Fix a memory leak in ctypes.resize().
+- bpo-16628: Fix a memory leak in ctypes.resize().
 
-- Issue #13614: Fix setup.py register failure with invalid rst in description.
+- bpo-13614: Fix setup.py register failure with invalid rst in description.
   Patch by Julien Courteau and Pierre Paul Lefebvre.
 
-- Issue #10182: The re module doesn't truncate indices to 32 bits anymore.
+- bpo-10182: The re module doesn't truncate indices to 32 bits anymore.
   Patch by Serhiy Storchaka.
 
-- Issue #16573: In 2to3, treat enumerate() like a consuming call, so superfluous
-  list() calls aren't added to filter(), map(), and zip() which are directly
-  passed enumerate().
+- bpo-16573: In 2to3, treat enumerate() like a consuming call, so
+  superfluous list() calls aren't added to filter(), map(), and zip() which
+  are directly passed enumerate().
 
-- Issue #1160: Fix compiling large regular expressions on UCS2 builds.
-  Patch by Serhiy Storchaka.
+- bpo-1160: Fix compiling large regular expressions on UCS2 builds. Patch by
+  Serhiy Storchaka.
 
-- Issue #14313: zipfile now raises NotImplementedError when the compression
+- bpo-14313: zipfile now raises NotImplementedError when the compression
   type is unknown.
 
-- Issue #16408: Fix file descriptors not being closed in error conditions
-  in the zipfile module.  Patch by Serhiy Storchaka.
+- bpo-16408: Fix file descriptors not being closed in error conditions in
+  the zipfile module.  Patch by Serhiy Storchaka.
 
-- Issue #16327: The subprocess module no longer leaks file descriptors
-  used for stdin/stdout/stderr pipes to the child when fork() fails.
+- bpo-16327: The subprocess module no longer leaks file descriptors used for
+  stdin/stdout/stderr pipes to the child when fork() fails.
 
-- Issue #14396: Handle the odd rare case of waitpid returning 0 when not
+- bpo-14396: Handle the odd rare case of waitpid returning 0 when not
   expected in subprocess.Popen.wait().
 
-- Issue #16411: Fix a bug where zlib.decompressobj().flush() might try to access
-  previously-freed memory. Patch by Serhiy Storchaka.
+- bpo-16411: Fix a bug where zlib.decompressobj().flush() might try to
+  access previously- freed memory. Patch by Serhiy Storchaka.
 
-- Issue #16350: zlib.decompressobj().decompress() now accumulates data from
-  successive calls after EOF in unused_data, instead of only saving the argument
-  to the last call. decompressobj().flush() now correctly sets unused_data and
-  unconsumed_tail. A bug in the handling of MemoryError when setting the
-  unconsumed_tail attribute has also been fixed. Patch by Serhiy Storchaka.
+- bpo-16350: zlib.decompressobj().decompress() now accumulates data from
+  successive calls after EOF in unused_data, instead of only saving the
+  argument to the last call. decompressobj().flush() now correctly sets
+  unused_data and unconsumed_tail. A bug in the handling of MemoryError when
+  setting the unconsumed_tail attribute has also been fixed. Patch by Serhiy
+  Storchaka.
 
-- Issue #12759: sre_parse now raises a proper error when the name of the group
-  is missing.  Initial patch by Serhiy Storchaka.
+- bpo-12759: sre_parse now raises a proper error when the name of the group
+  is missing. Initial patch by Serhiy Storchaka.
 
-- Issue #16152: fix tokenize to ignore whitespace at the end of the code when
+- bpo-16152: fix tokenize to ignore whitespace at the end of the code when
   no newline is found.  Patch by Ned Batchelder.
 
-- Issue #16230: Fix a crash in select.select() when one of the lists changes
+- bpo-16230: Fix a crash in select.select() when one of the lists changes
   size while iterated on.  Patch by Serhiy Storchaka.
 
-- Issue #16228: Fix a crash in the json module where a list changes size
-  while it is being encoded.  Patch by Serhiy Storchaka.
+- bpo-16228: Fix a crash in the json module where a list changes size while
+  it is being encoded.  Patch by Serhiy Storchaka.
 
-- Issue #14897: Enhance error messages of struct.pack and
-  struct.pack_into. Patch by Matti Mäki.
+- bpo-14897: Enhance error messages of struct.pack and struct.pack_into.
+  Patch by Matti Mäki.
 
-- Issue #12890: cgitb no longer prints spurious <p> tags in text
-  mode when the logdir option is specified.
+- bpo-12890: cgitb no longer prints spurious <p> tags in text mode when the
+  logdir option is specified.
 
-- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
+- bpo-14398: Fix size truncation and overflow bugs in the bz2 module.
 
-- Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile().
+- bpo-5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile().
 
-- Issue #16220: wsgiref now always calls close() on an iterable response.
-  Patch by Brent Tubbs.
+- bpo-16220: wsgiref now always calls close() on an iterable response. Patch
+  by Brent Tubbs.
 
-- Issue #16461: Wave library should be able to deal with 4GB wav files,
-  and sample rate of 44100 Hz.
+- bpo-16461: Wave library should be able to deal with 4GB wav files, and
+  sample rate of 44100 Hz.
 
-- Issue #16176: Properly identify Windows 8 via platform.platform()
+- bpo-16176: Properly identify Windows 8 via platform.platform()
 
-- Issue #15756: subprocess.poll() now properly handles errno.ECHILD to
-  return a returncode of 0 when the child has already exited or cannot
-  be waited on.
+- bpo-15756: subprocess.poll() now properly handles errno.ECHILD to return a
+  returncode of 0 when the child has already exited or cannot be waited on.
 
-- Issue #12376: Pass on parameters in TextTestResult.__init__ super call
+- bpo-12376: Pass on parameters in TextTestResult.__init__ super call
 
-- Issue #15222: Insert blank line after each message in mbox mailboxes
+- bpo-15222: Insert blank line after each message in mbox mailboxes
 
-- Issue #16013: Fix CSV Reader parsing issue with ending quote characters.
+- bpo-16013: Fix CSV Reader parsing issue with ending quote characters.
   Patch by Serhiy Storchaka.
 
-- Issue #15421: fix an OverflowError in Calendar.itermonthdates() after
-  datetime.MAXYEAR.  Patch by Cédric Krier.
+- bpo-15421: fix an OverflowError in Calendar.itermonthdates() after
+  datetime.MAXYEAR. Patch by Cédric Krier.
 
-- Issue #15970: xml.etree.ElementTree now serializes correctly the empty HTML
+- bpo-15970: xml.etree.ElementTree now serializes correctly the empty HTML
   elements 'meta' and 'param'.
 
-- Issue #15676: Now "mmap" check for empty files before doing the
-  offset check.  Patch by Steven Willis.
+- bpo-15676: Now "mmap" check for empty files before doing the offset check.
+  Patch by Steven Willis.
 
-- Issue #15340: Fix importing the random module when /dev/urandom cannot
-  be opened.  This was a regression caused by the hash randomization patch.
+- bpo-15340: Fix importing the random module when /dev/urandom cannot be
+  opened.  This was a regression caused by the hash randomization patch.
 
-- Issue #15841: The readable(), writable() and seekable() methods of
-  io.BytesIO and io.StringIO objects now raise ValueError when the object has
-  been closed.  Patch by Alessandro Moura.
+- bpo-15841: The readable(), writable() and seekable() methods of io.BytesIO
+  and io.StringIO objects now raise ValueError when the object has been
+  closed. Patch by Alessandro Moura.
 
-- Issue #16112: platform.architecture does not correctly escape argument to
-  /usr/bin/file.  Patch by David Benjamin.
+- bpo-16112: platform.architecture does not correctly escape argument to
+  /usr/bin/file. Patch by David Benjamin.
 
-- Issue #12776,#11839: call argparse type function (specified by add_argument)
-  only once. Before, the type function was called twice in the case where the
+- bpo-12776: call argparse type function (specified by add_argument) only
+  once. Before, the type function was called twice in the case where the
   default was specified and the argument was given as well.  This was
-  especially problematic for the FileType type, as a default file would always
-  be opened, even if a file argument was specified on the command line.
+  especially problematic for the FileType type, as a default file would
+  always be opened, even if a file argument was specified on the command
+  line. (See also: bpo-11839)
 
-- Issue #15906: Fix a regression in argparse caused by the preceding change,
+- bpo-15906: Fix a regression in argparse caused by the preceding change,
   when action='append', type='str' and default=[].
 
-- Issue #13370: Ensure that ctypes works on Mac OS X when Python is
-  compiled using the clang compiler
+- bpo-13370: Ensure that ctypes works on Mac OS X when Python is compiled
+  using the clang compiler
 
-- Issue #15544: Fix Decimal.__float__ to work with payload-carrying NaNs.
+- bpo-15544: Fix Decimal.__float__ to work with payload-carrying NaNs.
 
-- Issue #15199: Fix JavaScript's default MIME type to application/javascript.
+- bpo-15199: Fix JavaScript's default MIME type to application/javascript.
   Patch by Bohuslav Kabrda.
 
-- Issue #15477: In cmath and math modules, add workaround for platforms whose
-  system-supplied log1p function doesn't respect signs of zeros.
+- bpo-15477: In cmath and math modules, add workaround for platforms whose
+  system- supplied log1p function doesn't respect signs of zeros.
 
-- Issue #11062: Fix adding a message from file to Babyl mailbox.
+- bpo-11062: Fix adding a message from file to Babyl mailbox.
 
-- Issue #15646: Prevent equivalent of a fork bomb when using
-  multiprocessing on Windows without the "if __name__ == '__main__'"
-  idiom.
+- bpo-15646: Prevent equivalent of a fork bomb when using multiprocessing on
+  Windows without the "if __name__ == '__main__'" idiom.
 
-- Issue #15567: Fix NameError when running threading._test
+- bpo-15567: Fix NameError when running threading._test
 
-- Issue #15424: Add a __sizeof__ implementation for array objects.
-  Patch by Ludwig Hähne.
+- bpo-15424: Add a __sizeof__ implementation for array objects. Patch by
+  Ludwig Hähne.
 
-- Issue #15538: Fix compilation of the getnameinfo() / getaddrinfo()
-  emulation code.  Patch by Philipp Hagemeister.
+- bpo-15538: Fix compilation of the getnameinfo() / getaddrinfo() emulation
+  code.  Patch by Philipp Hagemeister.
 
-- Issue #12288: Consider '0' and '0.0' as valid initialvalue
-  for tkinter SimpleDialog.
+- bpo-12288: Consider '0' and '0.0' as valid initialvalue for tkinter
+  SimpleDialog.
 
-- Issue #15489: Add a __sizeof__ implementation for BytesIO objects.
-  Patch by Serhiy Storchaka.
+- bpo-15489: Add a __sizeof__ implementation for BytesIO objects. Patch by
+  Serhiy Storchaka.
 
-- Issue #15469: Add a __sizeof__ implementation for deque objects.
-  Patch by Serhiy Storchaka.
+- bpo-15469: Add a __sizeof__ implementation for deque objects. Patch by
+  Serhiy Storchaka.
 
-- Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
-  Patch by Serhiy Storchaka.
+- bpo-15487: Add a __sizeof__ implementation for buffered I/O objects. Patch
+  by Serhiy Storchaka.
 
-- Issue #15512: Add a __sizeof__ implementation for parser.
-  Patch by Serhiy Storchaka.
+- bpo-15512: Add a __sizeof__ implementation for parser. Patch by Serhiy
+  Storchaka.
 
-- Issue #15402: An issue in the struct module that caused sys.getsizeof to
+- bpo-15402: An issue in the struct module that caused sys.getsizeof to
   return incorrect results for struct.Struct instances has been fixed.
   Initial patch by Serhiy Storchaka.
 
-- Issue #15232: when mangle_from is True, email.Generator now correctly mangles
+- bpo-15232: when mangle_from is True, email.Generator now correctly mangles
   lines that start with 'From ' that occur in a MIME preamble or epilog.
 
-- Issue #13922: argparse no longer incorrectly strips '--'s that appear
-  after the first one.
+- bpo-13922: argparse no longer incorrectly strips '--'s that appear after
+  the first one.
 
-- Issue #12353: argparse now correctly handles null argument values.
+- bpo-12353: argparse now correctly handles null argument values.
 
-- Issue #6493: An issue in ctypes on Windows that caused structure bitfields
-  of type ctypes.c_uint32 and width 32 to incorrectly be set has been fixed.
+- bpo-6493: An issue in ctypes on Windows that caused structure bitfields of
+  type ctypes.c_uint32 and width 32 to incorrectly be set has been fixed.
 
-- Issue #14635: telnetlib will use poll() rather than select() when possible
-  to avoid failing due to the select() file descriptor limit.
+- bpo-14635: telnetlib will use poll() rather than select() when possible to
+  avoid failing due to the select() file descriptor limit.
 
-- Issue #15247: FileIO now raises an error when given a file descriptor
+- bpo-15247: FileIO now raises an error when given a file descriptor
   pointing to a directory.
 
-- Issue #14591: Fix bug in Random.jumpahead that could produce an invalid
+- bpo-14591: Fix bug in Random.jumpahead that could produce an invalid
   Mersenne Twister state on 64-bit machines.
 
-- Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox
-  files on flush().
+- bpo-5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on
+  flush().
 
-- Issue #15219: Fix a reference leak when hashlib.new() is called with
-  invalid parameters.
+- bpo-15219: Fix a reference leak when hashlib.new() is called with invalid
+  parameters.
 
-- Issue #9559: If messages were only added, a new file is no longer
-  created and renamed over the old file when flush() is called on an
-  mbox, MMDF or Babyl mailbox.
+- bpo-9559: If messages were only added, a new file is no longer created and
+  renamed over the old file when flush() is called on an mbox, MMDF or Babyl
+  mailbox.
 
-- Issue #14653: email.utils.mktime_tz() no longer relies on system
-  mktime() when timezone offest is supplied.
+- bpo-14653: email.utils.mktime_tz() no longer relies on system mktime()
+  when timezone offest is supplied.
 
-- Issue #6056: Make multiprocessing use setblocking(True) on the
-  sockets it uses.  Original patch by J Derek Wilson.
+- bpo-6056: Make multiprocessing use setblocking(True) on the sockets it
+  uses.  Original patch by J Derek Wilson.
 
-- Issue #15101: Make pool finalizer avoid joining current thread.
+- bpo-15101: Make pool finalizer avoid joining current thread.
 
-- Issue #15054: A bug in tokenize.tokenize that caused string literals
-  with 'b' and 'br' prefixes to be incorrectly tokenized has been fixed.
-  Patch by Serhiy Storchaka.
+- bpo-15054: A bug in tokenize.tokenize that caused string literals with 'b'
+  and 'br' prefixes to be incorrectly tokenized has been fixed. Patch by
+  Serhiy Storchaka.
 
-- Issue #15036: Mailbox no longer throws an error if a flush is done
-  between operations when removing or changing multiple items in mbox,
-  MMDF, or Babyl mailboxes.
+- bpo-15036: Mailbox no longer throws an error if a flush is done between
+  operations when removing or changing multiple items in mbox, MMDF, or
+  Babyl mailboxes.
 
-- Issue #10133: Make multiprocessing deallocate buffer if socket read
-  fails.  Patch by Hallvard B Furuseth.
+- bpo-10133: Make multiprocessing deallocate buffer if socket read fails.
+  Patch by Hallvard B Furuseth.
 
-- Issue #13854: Make multiprocessing properly handle non-integer
-  non-string argument to SystemExit.
+- bpo-13854: Make multiprocessing properly handle non-integer non-string
+  argument to SystemExit.
 
-- Issue #12157: Make pool.map() empty iterables correctly.  Initial
-  patch by mouad.
+- bpo-12157: Make pool.map() empty iterables correctly.  Initial patch by
+  mouad.
 
-- Issue #14036: Add an additional check to validate that port in urlparse does
+- bpo-14036: Add an additional check to validate that port in urlparse does
   not go in illegal range and returns None.
 
-- Issue #14888: Fix misbehaviour of the _md5 module when called on data
-  larger than 2**32 bytes.
+- bpo-14888: Fix misbehaviour of the _md5 module when called on data larger
+  than 2**32 bytes.
 
-- Issue #15908: Fix misbehaviour of the sha1 module when called on data
-  larger than 2**32 bytes.
+- bpo-15908: Fix misbehaviour of the sha1 module when called on data larger
+  than 2**32 bytes.
 
-- Issue #15910: Fix misbehaviour of _md5 and sha1 modules when "updating"
-  on data larger than 2**32 bytes.
+- bpo-15910: Fix misbehaviour of _md5 and sha1 modules when "updating" on
+  data larger than 2**32 bytes.
 
-- Issue #14875: Use float('inf') instead of float('1e66666') in the json module.
+- bpo-14875: Use float('inf') instead of float('1e66666') in the json
+  module.
 
-- Issue #14572: Prevent build failures with pre-3.5.0 versions of
-  sqlite3, such as was shipped with Centos 5 and Mac OS X 10.4.
+- bpo-14572: Prevent build failures with pre-3.5.0 versions of sqlite3, such
+  as was shipped with Centos 5 and Mac OS X 10.4.
 
-- Issue #14426: Correct the Date format in Expires attribute of Set-Cookie
+- bpo-14426: Correct the Date format in Expires attribute of Set-Cookie
   Header in Cookie.py.
 
-- Issue #14721: Send proper header, Content-length: 0 when the body is an empty
+- bpo-14721: Send proper header, Content-length: 0 when the body is an empty
   string ''. Initial Patch contributed by Arve Knudsen.
 
-- Issue #14072: Fix parsing of 'tel' URIs in urlparse by making the check for
+- bpo-14072: Fix parsing of 'tel' URIs in urlparse by making the check for
   ports stricter.
 
-- Issue #9374: Generic parsing of query and fragment portions of url for any
+- bpo-9374: Generic parsing of query and fragment portions of url for any
   scheme. Supported both by RFC3986 and RFC2396.
 
-- Issue #14798: Fix the functions in pyclbr to raise an ImportError
-  when the first part of a dotted name is not a package. Patch by
-  Xavier de Gaye.
+- bpo-14798: Fix the functions in pyclbr to raise an ImportError when the
+  first part of a dotted name is not a package. Patch by Xavier de Gaye.
 
-- Issue #14832: fixed the order of the argument references in the error
-  message produced by unittest's assertItemsEqual.
+- bpo-14832: fixed the order of the argument references in the error message
+  produced by unittest's assertItemsEqual.
 
-- Issue #14829: Fix bisect issues under 64-bit Windows.
+- bpo-14829: Fix bisect issues under 64-bit Windows.
 
-- Issue #14777: tkinter may return undecoded UTF-8 bytes as a string when
+- bpo-14777: tkinter may return undecoded UTF-8 bytes as a string when
   accessing the Tk clipboard.  Modify clipboard_get() to first request type
   UTF8_STRING when no specific type is requested in an X11 windowing
-  environment, falling back to the current default type STRING if that fails.
-  Original patch by Thomas Kluyver.
+  environment, falling back to the current default type STRING if that
+  fails. Original patch by Thomas Kluyver.
 
-- Issue #12541: Be lenient with quotes around Realm field with HTTP Basic
+- bpo-12541: Be lenient with quotes around Realm field with HTTP Basic
   Authentation in urllib2.
 
-- Issue #14662: Prevent shutil failures on OS X when destination does not
+- bpo-14662: Prevent shutil failures on OS X when destination does not
   support chflag operations.  Patch by Hynek Schlawack.
 
-- Issue #14157: Fix time.strptime failing without a year on February 29th.
+- bpo-14157: Fix time.strptime failing without a year on February 29th.
   Patch by Hynek Schlawack.
 
-- Issue #14768: os.path.expanduser('~/a') doesn't work correctly when HOME is '/'.
+- bpo-14768: os.path.expanduser('~/a') doesn't work correctly when HOME is
+  '/'.
 
-- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running
+- bpo-13183: Fix pdb skipping frames after hitting a breakpoint and running
   step.  Patch by Xavier de Gaye.
 
-- Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a
-  test class that doesn't inherit from TestCase (i.e. a mixin).
+- bpo-14664: It is now possible to use @unittest.skip{If,Unless} on a test
+  class that doesn't inherit from TestCase (i.e. a mixin).
 
-- Issue #14160: TarFile.extractfile() failed to resolve symbolic links when
-  the links were not located in an archive subdirectory.
+- bpo-14160: TarFile.extractfile() failed to resolve symbolic links when the
+  links were not located in an archive subdirectory.
 
-- Issue #14638: pydoc now treats non-string __name__ values as if they
-  were missing, instead of raising an error.
+- bpo-14638: pydoc now treats non-string __name__ values as if they were
+  missing, instead of raising an error.
 
-- Issue #13684: Fix httplib tunnel issue of infinite loops for certain sites
+- bpo-13684: Fix httplib tunnel issue of infinite loops for certain sites
   which send EOF without trailing \r\n.
 
-- Issue #14308: Fix an exception when a "dummy" thread is in the threading
+- bpo-14308: Fix an exception when a "dummy" thread is in the threading
   module's active list after a fork().
 
-- Issue #14538: HTMLParser can now parse correctly start tags that contain
-  bare '/'.
+- bpo-14538: HTMLParser can now parse correctly start tags that contain a
+  bare '/'.
 
-- Issue #14452: SysLogHandler no longer inserts a UTF-8 BOM into the message.
+- bpo-14452: SysLogHandler no longer inserts a UTF-8 BOM into the message.
 
-- Issue #13496: Fix potential overflow in bisect.bisect algorithm when applied
+- bpo-13496: Fix potential overflow in bisect.bisect algorithm when applied
   to a collection of size > sys.maxsize / 2.
 
-- Issue #14399: zipfile now recognizes that the archive has been modified even
-  if only the comment is changed.  As a consequence of this fix, ZipFile is now
-  a new style class.
+- bpo-14399: zipfile now recognizes that the archive has been modified even
+  if only the comment is changed.  As a consequence of this fix, ZipFile is
+  now a new style class.
 
-- Issue #7978: SocketServer now restarts the select() call when EINTR is
+- bpo-7978: SocketServer now restarts the select() call when EINTR is
   returned.  This avoids crashing the server loop when a signal is received.
   Patch by Jerzy Kozera.
 
-- Issue #10340: asyncore - properly handle EINVAL in dispatcher constructor on
+- bpo-10340: asyncore - properly handle EINVAL in dispatcher constructor on
   OSX; avoid to call handle_connect in case of a disconnected socket which
   was not meant to connect.
 
-- Issue #12757: Fix the skipping of doctests when python is run with -OO so
+- bpo-12757: Fix the skipping of doctests when python is run with -OO so
   that it works in unittest's verbose mode as well as non-verbose mode.
 
-- Issue #13694: asynchronous connect in asyncore.dispatcher does not set addr
+- bpo-13694: asynchronous connect in asyncore.dispatcher does not set addr
   attribute.
 
-- Issue #10484: Fix the CGIHTTPServer's PATH_INFO handling problem.
+- bpo-10484: Fix the CGIHTTPServer's PATH_INFO handling problem.
 
-- Issue #11199: Fix the with urllib which hangs on particular ftp urls.
+- bpo-11199: Fix the with urllib which hangs on particular ftp urls.
 
-- Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under
+- bpo-14252: Fix subprocess.Popen.terminate() to not raise an error under
   Windows when the child process has already exited.
 
-- Issue #14195: An issue that caused weakref.WeakSet instances to incorrectly
-  return True for a WeakSet instance 'a' in both 'a < a' and 'a > a' has been
-  fixed.
+- bpo-14195: An issue that caused weakref.WeakSet instances to incorrectly
+  return True for a WeakSet instance 'a' in both 'a < a' and 'a > a' has
+  been fixed.
 
-- Issue #14159: Fix the len() of weak sets to return a better approximation
+- bpo-14159: Fix the len() of weak sets to return a better approximation
   when some objects are dead or dying.  Moreover, the implementation is now
   O(1) rather than O(n).
 
-- Issue #2945: Make the distutils upload command aware of bdist_rpm products.
+- bpo-2945: Make the distutils upload command aware of bdist_rpm products.
 
-- Issue #6884: Fix long-standing bugs with MANIFEST.in parsing in distutils
-  on Windows.
+- bpo-6884: Fix long-standing bugs with MANIFEST.in parsing in distutils on
+  Windows.
 
-- Issue #16441: Avoid excessive memory usage working with large gzip
-  files using the gzip module.
+- bpo-16441: Avoid excessive memory usage working with large gzip files
+  using the gzip module.
 
-- Issue #15782: Prevent compile errors of OS X Carbon modules _Fm, _Qd, and
+- bpo-15782: Prevent compile errors of OS X Carbon modules _Fm, _Qd, and
   _Qdoffs when compiling with an SDK of 10.7 or later.  The OS X APIs they
-  wrap have long been deprecated and have now been removed with 10.7.
-  These modules were already empty for 64-bit builds and have been removed
-  in Python 3.
+  wrap have long been deprecated and have now been removed with 10.7. These
+  modules were already empty for 64-bit builds and have been removed in
+  Python 3.
 
-Extension Modules
------------------
-
-- Issue #17477: Update the bsddb module to pybsddb 5.3.0, supporting
-  db-5.x, and dropping support for db-4.1 and db-4.2.
+- bpo-17477: Update the bsddb module to pybsddb 5.3.0, supporting db-5.x,
+  and dropping support for db-4.1 and db-4.2.
 
-- Issue #17192: Update the ctypes module's libffi to v3.0.13.  This
+- bpo-17192: Update the ctypes module's libffi to v3.0.13.  This
   specifically addresses a stack misalignment issue on x86 and issues on
   some more recent platforms.
 
-- Issue #12268: The io module file object write methods no longer abort early
+- bpo-12268: The io module file object write methods no longer abort early
   when a write system calls is interrupted (EINTR).
 
 - Fix the leak of a dict in the time module when used in an embedded
   interpreter that is repeatedly initialized and shutdown and reinitialized.
 
-- Issue #12268: File readline, readlines and read or readall methods
-  no longer lose data when an underlying read system call is interrupted
-  within an io module object.  IOError is no longer raised due to a read
-  system call returning EINTR from within these methods.
+- bpo-12268: File readline, readlines and read or readall methods no longer
+  lose data when an underlying read system call is interrupted within an io
+  module object.  IOError is no longer raised due to a read system call
+  returning EINTR from within these methods.
 
-- Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD()
+- bpo-16012: Fix a regression in pyexpat. The parser's UseForeignDTD()
   method doesn't require an argument again.
 
-- Issue #13590: OS X Xcode 4 - improve support for universal extension modules
+- bpo-13590: OS X Xcode 4 - improve support for universal extension modules
   In particular, fix extension module build failures when trying to use
-  32-bit-only installer Pythons on systems with Xcode 4 (currently
-  OS X 10.8, 10.7, and optionally 10.6).
-  * Backport 3.3.0 fixes to 2.7 branch (for release in 2.7.4)
-  * Since Xcode 4 removes ppc support, extension module builds now
-    check for ppc compiler support and by default remove ppc and
-    ppc64 archs when they are not available.
-  * Extension module builds now revert to using system installed
-    headers and libs (/usr and /System/Library) if the SDK used
-    to build the interpreter is not installed or has moved.
-  * Try to avoid building extension modules with deprecated
-    and problematic Apple llvm-gcc compiler.  If original compiler
-    is not available, use clang instead by default.
+  32-bit- only installer Pythons on systems with Xcode 4 (currently OS X
+  10.8, 10.7, and optionally 10.6). * Backport 3.3.0 fixes to 2.7 branch
+  (for release in 2.7.4) * Since Xcode 4 removes ppc support, extension
+  module builds now check for ppc compiler support and by default remove ppc
+  and   ppc64 archs when they are not available. * Extension module builds
+  now revert to using system installed   headers and libs (/usr and
+  /System/Library) if the SDK used   to build the interpreter is not
+  installed or has moved. * Try to avoid building extension modules with
+  deprecated   and problematic Apple llvm-gcc compiler.  If original
+  compiler   is not available, use clang instead by default.
 
 IDLE
 ----
@@ -4184,289 +4622,290 @@ IDLE
 - IDLE was displaying spurious SystemExit tracebacks when running scripts
   that terminated by raising SystemExit (i.e. unittest and turtledemo).
 
-- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
+- bpo-9290: In IDLE the sys.std* streams now implement io.TextIOBase
   interface and support all mandatory methods and properties.
 
-- Issue #16829: IDLE printing no longer fails if there are spaces or other
+- bpo-16829: IDLE printing no longer fails if there are spaces or other
   special characters in the file path.
 
-- Issue #16819: IDLE method completion now correctly works for unicode literals.
+- bpo-16819: IDLE method completion now correctly works for unicode
+  literals.
 
-- Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by
+- bpo-16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by
   Roger Serwy.
 
-- Issue #1207589: Add Cut/Copy/Paste items to IDLE right click Context Menu.
+- bpo-1207589: Add Cut/Copy/Paste items to IDLE right click Context Menu.
   Patch by Todd Rovito.
 
-- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
+- bpo-13052: Fix IDLE crashing when replace string in Search/Replace dialog
   ended with '\'. Patch by Roger Serwy.
 
-- Issue #9803: Don't close IDLE on saving if breakpoint is open.
-  Patch by Roger Serwy.
+- bpo-9803: Don't close IDLE on saving if breakpoint is open. Patch by Roger
+  Serwy.
 
-- Issue #14958: Change IDLE systax highlighting to recognize all string and byte
-  literals currently supported in Python 2.7.
+- bpo-14958: Change IDLE systax highlighting to recognize all string and
+  byte literals currently supported in Python 2.7.
 
-- Issue #14962: Update text coloring in IDLE shell window after changing
+- bpo-14962: Update text coloring in IDLE shell window after changing
   options.  Patch by Roger Serwy.
 
-- Issue #10997: Prevent a duplicate entry in IDLE's "Recent Files" menu.
+- bpo-10997: Prevent a duplicate entry in IDLE's "Recent Files" menu.
 
-- Issue #12510: Attempting to get invalid tooltip no longer closes IDLE.
+- bpo-12510: Attempting to get invalid tooltip no longer closes IDLE.
   Original patch by Roger Serwy.
 
-- Issue #10365: File open dialog now works instead of crashing
-  even when parent window is closed. Patch by Roger Serwy.
+- bpo-10365: File open dialog now works instead of crashing even when parent
+  window is closed. Patch by Roger Serwy.
 
-- Issue #14876: Use user-selected font for highlight configuration.
-  Patch by Roger Serwy.
+- bpo-14876: Use user-selected font for highlight configuration. Patch by
+  Roger Serwy.
 
-- Issue #14409: IDLE now properly executes commands in the Shell window
-  when it cannot read the normal config files on startup and
-  has to use the built-in default key bindings.
-  There was previously a bug in one of the defaults.
+- bpo-14409: IDLE now properly executes commands in the Shell window when it
+  cannot read the normal config files on startup and has to use the built-in
+  default key bindings. There was previously a bug in one of the defaults.
 
-- Issue #3573: IDLE hangs when passing invalid command line args
+- bpo-3573: IDLE hangs when passing invalid command line args
   (directory(ies) instead of file(s)) (Patch by Guilherme Polo)
 
-- Issue #5219: Prevent event handler cascade in IDLE.
+- bpo-5219: Prevent event handler cascade in IDLE.
 
-- Issue #15318: Prevent writing to sys.stdin.
+- bpo-15318: Prevent writing to sys.stdin.
 
-- Issue #13532, #15319: Check that arguments to sys.stdout.write are strings.
+- bpo-13532: Check that arguments to sys.stdout.write are strings. (See
+  also: bpo-15319)
 
-- Issue #10365: File open dialog now works instead of crashing even when
-  parent window is closed while dialog is open.
+- bpo-10365: File open dialog now works instead of crashing even when parent
+  window is closed while dialog is open.
 
-- Issue #14018: Update checks for unstable system Tcl/Tk versions on OS X
-  to include versions shipped with OS X 10.7 and 10.8 in addition to 10.6.
+- bpo-14018: Update checks for unstable system Tcl/Tk versions on OS X to
+  include versions shipped with OS X 10.7 and 10.8 in addition to 10.6.
 
-- Issue #15853: Prevent IDLE crash on OS X when opening Preferences menu
-  with certain versions of Tk 8.5.  Initial patch by Kevin Walzer.
+- bpo-15853: Prevent IDLE crash on OS X when opening Preferences menu with
+  certain versions of Tk 8.5.  Initial patch by Kevin Walzer.
 
 Tests
 -----
 
-- Issue #16702: test_urllib2_localnet tests now correctly ignores proxies for
+- bpo-16702: test_urllib2_localnet tests now correctly ignores proxies for
   localhost tests.
 
-- Issue #13447: Add a test file to host regression tests for bugs in the
+- bpo-13447: Add a test file to host regression tests for bugs in the
   scripts found in the Tools directory.
 
-- Issue #11420: make test suite pass with -B/DONTWRITEBYTECODE set.
-  Initial patch by Thomas Wouters.
+- bpo-11420: make test suite pass with -B/DONTWRITEBYTECODE set. Initial
+  patch by Thomas Wouters.
 
-- Issue #17299: Add test coverage for cPickle with file objects and general IO
-  objects.  Original patch by Aman Shah.
+- bpo-17299: Add test coverage for cPickle with file objects and general IO
+  objects. Original patch by Aman Shah.
 
-- Issue #11963: remove human verification from test_parser and test_subprocess.
+- bpo-11963: remove human verification from test_parser and test_subprocess.
 
-- Issue #17249: convert a test in test_capi to use unittest and reap threads.
+- bpo-17249: convert a test in test_capi to use unittest and reap threads.
 
 - We now run both test_email.py and test_email_renamed.py when running the
   test_email regression test.  test_email_renamed contains some tests that
   test_email does not.
 
-- Issue #17041: Fix testing when Python is configured with the
-  --without-doc-strings option.
+- bpo-17041: Fix testing when Python is configured with the --without-doc-
+  strings option.
 
-- Issue #15539: Added regression tests for Tools/scripts/pindent.py.
+- bpo-15539: Added regression tests for Tools/scripts/pindent.py.
 
-- Issue #15324: Fix regrtest parsing of --fromfile and --randomize options.
+- bpo-15324: Fix regrtest parsing of --fromfile and --randomize options.
 
-- Issue #16618: Add more regression tests for glob.
-  Patch by Serhiy Storchaka.
+- bpo-16618: Add more regression tests for glob. Patch by Serhiy Storchaka.
 
-- Issue #16664: Add regression tests for glob's behaviour concerning entries
+- bpo-16664: Add regression tests for glob's behaviour concerning entries
   starting with a ".".  Patch by Sebastian Kreft.
 
-- Issue #15747: ZFS always returns EOPNOTSUPP when attempting to set the
+- bpo-15747: ZFS always returns EOPNOTSUPP when attempting to set the
   UF_IMMUTABLE flag (via either chflags or lchflags); refactor affected
   tests in test_posix.py to account for this.
 
-- Issue #16549: Add tests for json.tools.  Initial patch by Berker Peksag
-  and Serhiy Storchaka.
+- bpo-16549: Add tests for json.tools.  Initial patch by Berker Peksag and
+  Serhiy Storchaka.
 
-- Issue #16559: Add more tests for the json module, including some from the
+- bpo-16559: Add more tests for the json module, including some from the
   official test suite at json.org.  Patch by Serhiy Storchaka.
 
-- Issue #16274: Fix test_asyncore on Solaris.  Patch by Giampaolo Rodola'.
+- bpo-16274: Fix test_asyncore on Solaris.  Patch by Giampaolo Rodola'.
 
-- Issue #15040: Close files in mailbox tests for PyPy compatibility.
-  Original patch by Matti Picus.
+- bpo-15040: Close files in mailbox tests for PyPy compatibility. Original
+  patch by Matti Picus.
 
-- Issue #15802: Fix test logic in TestMaildir.test_create_tmp. Patch
-  by Serhiy Storchaka.
+- bpo-15802: Fix test logic in TestMaildir.test_create_tmp. Patch by Serhiy
+  Storchaka.
 
-- Issue #15765: Extend a previous fix to Solaris and OpenBSD for quirky
+- bpo-15765: Extend a previous fix to Solaris and OpenBSD for quirky
   getcwd() behaviour (issue #9185) to NetBSD as well.
 
-- Issue #15615: Add some tests for the json module's handling of invalid
-  input data.  Patch by Kushal Das.
+- bpo-15615: Add some tests for the json module's handling of invalid input
+  data.  Patch by Kushal Das.
 
-- Issue #15496: Add directory removal helpers for tests on Windows.
-  Patch by Jeremy Kloth.
+- bpo-15496: Add directory removal helpers for tests on Windows. Patch by
+  Jeremy Kloth.
 
-- Issue #15043: test_gdb is now skipped entirely if gdb security settings
-  block loading of the gdb hooks
+- bpo-15043: test_gdb is now skipped entirely if gdb security settings block
+  loading of the gdb hooks
 
-- Issue #14589: Update certificate chain for sha256.tbs-internet.com, fixing
-  test failure in test_ssl.
+- bpo-14589: Update certificate chain for sha256.tbs-internet.com, fixing a
+  test failure in test_ssl.
 
-- Issue #16698: Skip posix test_getgroups when built with OS X
-  deployment target prior to 10.6.
+- bpo-16698: Skip posix test_getgroups when built with OS X deployment
+  target prior to 10.6.
 
-- Issue #17111: Prevent test_surrogates (test_fileio) failure on OS X 10.4.
+- bpo-17111: Prevent test_surrogates (test_fileio) failure on OS X 10.4.
 
 Build
 -----
 
-- Issue #17425: Build against openssl 0.9.8y on Windows.
+- bpo-17425: Build against openssl 0.9.8y on Windows.
 
-- Issue #16004: Add `make touch`.
+- bpo-16004: Add `make touch`.
 
-- Issue #5033: Fix building of the sqlite3 extension module when the
-  SQLite library version has "beta" in it. Patch by Andreas Pelme.
+- bpo-5033: Fix building of the sqlite3 extension module when the SQLite
+  library version has "beta" in it. Patch by Andreas Pelme.
 
-- Issue #17228: Fix building without pymalloc.
+- bpo-17228: Fix building without pymalloc.
 
-- Issue #17086: Backport the patches from the 3.3 branch to cross-build
-  the package.
+- bpo-17086: Backport the patches from the 3.3 branch to cross-build the
+  package.
 
-- Issue #3754: fix typo in pthread AC_CACHE_VAL.
+- bpo-3754: fix typo in pthread AC_CACHE_VAL.
 
-- Issue #17029: Let h2py search the multiarch system include directory.
+- bpo-17029: Let h2py search the multiarch system include directory.
 
-- Issue #16953: Fix socket module compilation on platforms with
+- bpo-16953: Fix socket module compilation on platforms with
   HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong.
 
-- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host.
+- bpo-16836: Enable IPv6 support even if IPv6 is disabled on the build host.
 
-- Issue #15923: fix a mistake in asdl_c.py that resulted in a TypeError after
+- bpo-15923: fix a mistake in asdl_c.py that resulted in a TypeError after
   2801bf875a24 (see #15801).
 
-- Issue #11715: Fix multiarch detection without having Debian development
-  tools (dpkg-dev) installed.
+- bpo-11715: Fix multiarch detection without having Debian development tools
+  (dpkg-dev) installed.
 
-- Issue #15819: Make sure we can build Python out-of-tree from a readonly
-  source directory.  (Somewhat related to Issue #9860.)
+- bpo-15819: Make sure we can build Python out-of-tree from a readonly
+  source directory. (Somewhat related to Issue #9860.)
 
-- Issue #15822: Ensure 2to3 grammar pickles are properly installed.
+- bpo-15822: Ensure 2to3 grammar pickles are properly installed.
 
-- Issue #15560: Fix building _sqlite3 extension on OS X with an SDK.
+- bpo-15560: Fix building _sqlite3 extension on OS X with an SDK.
 
-- Issue #8847: Disable COMDAT folding in Windows PGO builds.
+- bpo-8847: Disable COMDAT folding in Windows PGO builds.
 
-- Issue #14018: Fix OS X Tcl/Tk framework checking when using OS X SDKs.
+- bpo-14018: Fix OS X Tcl/Tk framework checking when using OS X SDKs.
 
-- Issue #16256: OS X installer now sets correct permissions for doc directory.
+- bpo-16256: OS X installer now sets correct permissions for doc directory.
 
-- Issue #8767: Restore building with --disable-unicode.
-  Patch by Stefano Taschini.
+- bpo-8767: Restore building with --disable-unicode. Patch by Stefano
+  Taschini.
 
 - Build against bzip2 1.0.6 and openssl 0.9.8x on Windows.
 
-- Issue #14557: Fix extensions build on HP-UX. Patch by Adi Roiban.
+- bpo-14557: Fix extensions build on HP-UX. Patch by Adi Roiban.
 
-- Issue #14437: Fix building the _io module under Cygwin.
+- bpo-14437: Fix building the _io module under Cygwin.
 
-- Issue #15587: Enable Tk high-resolution text rendering on Macs with
-  Retina displays.  Applies to Tkinter apps, such as IDLE, on OS X
-  framework builds linked with Cocoa Tk 8.5.
+- bpo-15587: Enable Tk high-resolution text rendering on Macs with Retina
+  displays. Applies to Tkinter apps, such as IDLE, on OS X framework builds
+  linked with Cocoa Tk 8.5.
 
-- Issue #17161: make install now also installs a python2 and python man page.
+- bpo-17161: make install now also installs a python2 and python man page.
 
-- Issue #16848: python-config now returns proper --ldflags values for OS X
+- bpo-16848: python-config now returns proper --ldflags values for OS X
   framework builds.
 
 Tools/Demos
 -----------
 
-- Issue #17156: pygettext.py now correctly escapes non-ascii characters.
+- bpo-17156: pygettext.py now correctly escapes non-ascii characters.
 
-- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py.  Now
+- bpo-15539: Fix a number of bugs in Tools/scripts/pindent.py.  Now
   pindent.py works with a "with" statement.  pindent.py no longer produces
-  improper indentation.  pindent.py now works with continued lines broken after
-  "class" or "def" keywords and with continuations at the start of line.
+  improper indentation. pindent.py now works with continued lines broken
+  after "class" or "def" keywords and with continuations at the start of
+  line.
 
-- Issue #16476: Fix json.tool to avoid including trailing whitespace.
+- bpo-16476: Fix json.tool to avoid including trailing whitespace.
 
-- Issue #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py.
-  Patch by Serhiy Storchaka.
+- bpo-13301: use ast.literal_eval() instead of eval() in
+  Tools/i18n/msgfmt.py. Patch by Serhiy Storchaka.
 
 Documentation
 -------------
 
-- Issue #15041: Update "see also" list in tkinter documentation.
+- bpo-15041: Update "see also" list in tkinter documentation.
 
-- Issue #17412: update 2.7 Doc/make.bat to also use sphinx-1.0.7.
+- bpo-17412: update 2.7 Doc/make.bat to also use sphinx-1.0.7.
 
-- Issue #17047: remove doubled words in docs and docstrings
-  reported by Serhiy Storchaka and Matthew Barnett.
+- bpo-17047: remove doubled words in docs and docstrings reported by Serhiy
+  Storchaka and Matthew Barnett.
 
-- Issue #16406: combine the pages for uploading and registering to PyPI.
+- bpo-16406: combine the pages for uploading and registering to PyPI.
 
-- Issue #16403: Document how distutils uses the maintainer field in
-  PKG-INFO. Patch by Jyrki Pulliainen.
+- bpo-16403: Document how distutils uses the maintainer field in PKG-INFO.
+  Patch by Jyrki Pulliainen.
 
-- Issue #16695: Document how glob handles filenames starting with a
-  dot. Initial patch by Jyrki Pulliainen.
+- bpo-16695: Document how glob handles filenames starting with a dot.
+  Initial patch by Jyrki Pulliainen.
 
-- Issue #8890: Stop advertising an insecure practice by replacing uses
-  of the /tmp directory with better alternatives in the documentation.
-  Patch by Geoff Wilson.
+- bpo-8890: Stop advertising an insecure practice by replacing uses of the
+  /tmp directory with better alternatives in the documentation. Patch by
+  Geoff Wilson.
 
-- Issue #17203: add long option names to unittest discovery docs.
+- bpo-17203: add long option names to unittest discovery docs.
 
-- Issue #13094: add "Why do lambdas defined in a loop with different values
-  all return the same result?" programming FAQ.
+- bpo-13094: add "Why do lambdas defined in a loop with different values all
+  return the same result?" programming FAQ.
 
-- Issue #14901: Update portions of the Windows FAQ.
-  Patch by Ashish Nitin Patil.
+- bpo-14901: Update portions of the Windows FAQ. Patch by Ashish Nitin
+  Patil.
 
-- Issue #15990: Improve argument/parameter documentation.
+- bpo-15990: Improve argument/parameter documentation.
 
-- Issue #16400: Update the description of which versions of a given package
+- bpo-16400: Update the description of which versions of a given package
   PyPI displays.
 
-- Issue #15677: Document that zlib and gzip accept a compression level of 0 to
+- bpo-15677: Document that zlib and gzip accept a compression level of 0 to
   mean 'no compression'. Patch by Brian Brazil.
 
-- Issue #8040: added a version switcher to the documentation.  Patch by
-  Yury Selivanov.
+- bpo-8040: added a version switcher to the documentation.  Patch by Yury
+  Selivanov.
 
-- Issue #16115: Improve subprocess.Popen() documentation around args, shell,
+- bpo-16115: Improve subprocess.Popen() documentation around args, shell,
   and executable arguments.
 
-- Issue #15979: Improve timeit documentation.
+- bpo-15979: Improve timeit documentation.
 
-- Issue #16036: Improve documentation of built-in int()'s signature and
+- bpo-16036: Improve documentation of built-in int()'s signature and
   arguments.
 
-- Issue #15935: Clarification of argparse docs, re: add_argument() type and
+- bpo-15935: Clarification of argparse docs, re: add_argument() type and
   default arguments.  Patch contributed by Chris Jerdonek.
 
-- Issue #13769: Document the effect of ensure_ascii to the return type
-  of JSON decoding functions.
+- bpo-13769: Document the effect of ensure_ascii to the return type of JSON
+  decoding functions.
 
-- Issue #14880: Fix kwargs notation in csv.reader, .writer & .register_dialect.
+- bpo-14880: Fix kwargs notation in csv.reader, .writer & .register_dialect.
   Patch by Chris Rebert.
 
-- Issue #14674: Add a discussion of the json module's standard compliance.
+- bpo-14674: Add a discussion of the json module's standard compliance.
   Patch by Chris Rebert.
 
-- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
+- bpo-15630: Add an example for "continue" stmt in the tutorial. Patch by
   Daniel Ellis.
 
-- Issue #13557: Clarify effect of giving two different namespaces to exec or
+- bpo-13557: Clarify effect of giving two different namespaces to exec or
   execfile().
 
-- Issue #14034: added the argparse tutorial.
+- bpo-14034: added the argparse tutorial.
 
-- Issue #15250: Document that filecmp.dircmp compares files shallowly. Patch
+- bpo-15250: Document that filecmp.dircmp compares files shallowly. Patch
   contributed by Chris Jerdonek.
 
-- Issue #15116: Remove references to appscript as it is no longer being
+- bpo-15116: Remove references to appscript as it is no longer being
   supported.
 
 
@@ -4478,10 +4917,10 @@ What's New in Python 2.7.3 release candidate 2?
 Library
 -------
 
-- Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes in the hash
-  table internal to the pyexpat module's copy of the expat library to avoid a
-  denial of service due to hash collisions.  Patch by David Malcolm with some
-  modifications by the expat project.
+- bpo-14234: CVE-2012-0876: Randomize hashes of xml attributes in the hash
+  table internal to the pyexpat module's copy of the expat library to avoid
+  a denial of service due to hash collisions.  Patch by David Malcolm with
+  some modifications by the expat project.
 
 
 What's New in Python 2.7.3 release candidate 1?
@@ -4492,87 +4931,87 @@ What's New in Python 2.7.3 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #13020: Fix a reference leak when allocating a structsequence object
+- bpo-13020: Fix a reference leak when allocating a structsequence object
   fails.  Patch by Suman Saha.
 
-- Issue #13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED
-  environment variable, to provide an opt-in way to protect against denial of
-  service attacks due to hash collisions within the dict and set types.  Patch
-  by David Malcolm, based on work by Victor Stinner.
+- bpo-13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED
+  environment variable, to provide an opt-in way to protect against denial
+  of service attacks due to hash collisions within the dict and set types.
+  Patch by David Malcolm, based on work by Victor Stinner.
 
-- Issue #11235: Fix OverflowError when trying to import a source file whose
+- bpo-11235: Fix OverflowError when trying to import a source file whose
   modification time doesn't fit in a 32-bit timestamp.
 
-- Issue #11638: Unicode strings in 'name' and 'version' no longer cause
+- bpo-11638: Unicode strings in 'name' and 'version' no longer cause
   UnicodeDecodeErrors.
 
 - Fix the fix for issue #12149: it was incorrect, although it had the side
   effect of appearing to resolve the issue.  Thanks to Mark Shannon for
   noticing.
 
-- Issue #13546: Fixed an overflow issue that could crash the intepreter when
+- bpo-13546: Fixed an overflow issue that could crash the intepreter when
   calling sys.setrecursionlimit((1<<31)-1).
 
-- Issue #13333: The UTF-7 decoder now accepts lone surrogates (the encoder
+- bpo-13333: The UTF-7 decoder now accepts lone surrogates (the encoder
   already accepts them).
 
-- Issue #10519: Avoid unnecessary recursive function calls in
-  setobject.c.
+- bpo-10519: Avoid unnecessary recursive function calls in setobject.c.
 
-- Issue #13268: Fix the assert statement when a tuple is passed as the message.
+- bpo-13268: Fix the assert statement when a tuple is passed as the message.
 
-- Issue #13018: Fix reference leaks in error paths in dictobject.c.
-  Patch by Suman Saha.
+- bpo-13018: Fix reference leaks in error paths in dictobject.c. Patch by
+  Suman Saha.
 
-- Issue #12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
+- bpo-12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
   warnings. Patch by Josh Triplett and Petri Lehtinen.
 
-- Issue #7833: Extension modules built using distutils on Windows will no
+- bpo-7833: Extension modules built using distutils on Windows will no
   longer include a "manifest" to prevent them failing at import time in some
   embedded situations.
 
-- Issue #13186: Fix __delitem__ on old-style instances when invoked through
+- bpo-13186: Fix __delitem__ on old-style instances when invoked through
   PySequence_DelItem.
 
-- Issue #13156: Revert the patch for issue #10517 (reset TLS upon fork()),
+- bpo-13156: Revert the patch for issue #10517 (reset TLS upon fork()),
   which was only relevant for the native pthread TLS implementation.
 
-- Issue #7732: Fix a crash on importing a module if a directory has the same
-  name than a Python module (e.g. "__init__.py"): don't close the file twice.
+- bpo-7732: Fix a crash on importing a module if a directory has the same
+  name than a Python module (e.g. "__init__.py"): don't close the file
+  twice.
 
-- Issue #12973: Fix overflow checks that invoked undefined behaviour in
+- bpo-12973: Fix overflow checks that invoked undefined behaviour in
   int.__pow__.  These overflow checks were causing int.__pow__ to produce
   incorrect results with recent versions of Clang, as a result of the
-  compiler optimizing the check away.  Also fix similar overflow checks
-  in list_repeat (listobject.c) and islice_next (itertoolsmodule.c).  These
+  compiler optimizing the check away.  Also fix similar overflow checks in
+  list_repeat (listobject.c) and islice_next (itertoolsmodule.c).  These
   bugs caused test failures with recent versions of Clang.
 
-- Issue #12266: Fix str.capitalize() to correctly uppercase/lowercase
+- bpo-12266: Fix str.capitalize() to correctly uppercase/lowercase
   titlecased and cased non-letter characters.
 
-- Issues #12610 and #12609: Verify that user generated AST has correct string
-  and identifier types before compiling.
+- bpo-12610: Verify that user generated AST has correct string and
+  identifier types before compiling. (See also: bpo-12609)
 
-- Issue #11627: Fix segfault when __new__ on an exception returns a
-  non-exception class.
+- bpo-11627: Fix segfault when __new__ on an exception returns a non-
+  exception class.
 
-- Issue #12149: Update the method cache after a type's dictionnary gets
-  cleared by the garbage collector.  This fixes a segfault when an instance
-  and its type get caught in a reference cycle, and the instance's
-  deallocator calls one of the methods on the type (e.g. when subclassing
-  IOBase).  Diagnosis and patch by Davide Rizzo.
+- bpo-12149: Update the method cache after a type's dictionnary gets cleared
+  by the garbage collector.  This fixes a segfault when an instance and its
+  type get caught in a reference cycle, and the instance's deallocator calls
+  one of the methods on the type (e.g. when subclassing IOBase).  Diagnosis
+  and patch by Davide Rizzo.
 
-- Issue #12501: Remove Py3k warning for callable. callable() is supported
-  again in Python 3.2.
+- bpo-12501: Remove Py3k warning for callable. callable() is supported again
+  in Python 3.2.
 
-- Issue #9611, #9015: FileIO.read(), FileIO.readinto(), FileIO.write() and
-  os.write() clamp the length to INT_MAX on Windows.
+- bpo-9611: FileIO.read(), FileIO.readinto(), FileIO.write() and os.write()
+  clamp the length to INT_MAX on Windows. (See also: bpo-9015)
 
-- Issue #1195: my_fgets() now always clears errors before calling fgets(). Fix
+- bpo-1195: my_fgets() now always clears errors before calling fgets(). Fix
   the following case: sys.stdin.read() stopped with CTRL+d (end of file),
   raw_input() interrupted by CTRL+c.
 
-- Issue #10860: httplib now correctly handles an empty port after port
+- bpo-10860: httplib now correctly handles an empty port after port
   delimiter in URLs.
 
 - dict_proxy objects now display their contents rather than just the class
@@ -4581,339 +5020,338 @@ Core and Builtins
 Library
 -------
 
-- Issue #8033: sqlite3: Fix 64-bit integer handling in user functions
-  on 32-bit architectures. Initial patch by Philippe Devalkeneer.
+- bpo-8033: sqlite3: Fix 64-bit integer handling in user functions on 32-bit
+  architectures. Initial patch by Philippe Devalkeneer.
 
 - HTMLParser is now able to handle slashes in the start tag.
 
-- Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in
+- bpo-14001: CVE-2012-0845: xmlrpc: Fix an endless loop in
   SimpleXMLRPCServer upon malformed POST request.
 
-- Issue #2489: pty.spawn could consume 100% cpu when it encountered an EOF.
+- bpo-2489: pty.spawn could consume 100% cpu when it encountered an EOF.
 
-- Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
+- bpo-13014: Fix a possible reference leak in SSLSocket.getpeercert().
 
-- Issue #13987: HTMLParser is now able to handle EOFs in the middle of a
+- bpo-13987: HTMLParser is now able to handle EOFs in the middle of a
   construct and malformed start tags.
 
-- Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
-  Patch by Suman Saha.
+- bpo-13015: Fix a possible reference leak in defaultdict.__repr__. Patch by
+  Suman Saha.
 
-- Issue #13979: A bug in ctypes.util.find_library that caused
-  the wrong library name to be returned has been fixed.
+- bpo-13979: A bug in ctypes.util.find_library that caused the wrong library
+  name to be returned has been fixed.
 
-- Issue #1326113: distutils' build_ext command --libraries option now
-  correctly parses multiple values separated by whitespace or commas.
+- bpo-1326113: distutils' build_ext command --libraries option now correctly
+  parses multiple values separated by whitespace or commas.
 
-- Issue #13993: HTMLParser is now able to handle broken end tags.
+- bpo-13993: HTMLParser is now able to handle broken end tags.
 
-- Issue #13960: HTMLParser is now able to handle broken comments.
+- bpo-13960: HTMLParser is now able to handle broken comments.
 
-- Issue #9750: Fix sqlite3.Connection.iterdump on tables and fields
-  with a name that is a keyword or contains quotes. Patch by Marko
-  Kohtala.
+- bpo-9750: Fix sqlite3.Connection.iterdump on tables and fields with a name
+  that is a keyword or contains quotes. Patch by Marko Kohtala.
 
-- Issue #13994: Earlier partial revert of Distutils enhancements in 2.7
-  has left two versions of customize_compiler, the original in
+- bpo-13994: Earlier partial revert of Distutils enhancements in 2.7 has
+  left two versions of customize_compiler, the original in
   distutils.sysconfig and another copy in distutils.ccompiler, with some
-  parts of distutils calling one and others using the other.
-  Complete the revert back to only having one in distutils.sysconfig as
-  is the case in 3.x.
-
-- Issue #13590: On OS X 10.7 and 10.6 with Xcode 4.2, building
-  Distutils-based packages with C extension modules may fail because
-  Apple has removed gcc-4.2, the version used to build python.org
-  64-bit/32-bit Pythons.  If the user does not explicitly override
-  the default C compiler by setting the CC environment variable,
-  Distutils will now attempt to compile extension modules with clang
-  if gcc-4.2 is required but not found. Also as a convenience, if
-  the user does explicitly set CC, substitute its value as the default
-  compiler in the Distutils LDSHARED configuration variable for OS X.
-  (Note, the python.org 32-bit-only Pythons use gcc-4.0 and the 10.4u
+  parts of distutils calling one and others using the other. Complete the
+  revert back to only having one in distutils.sysconfig as is the case in
+  3.x.
+
+- bpo-13590: On OS X 10.7 and 10.6 with Xcode 4.2, building Distutils-based
+  packages with C extension modules may fail because Apple has removed
+  gcc-4.2, the version used to build python.org 64-bit/32-bit Pythons.  If
+  the user does not explicitly override the default C compiler by setting
+  the CC environment variable, Distutils will now attempt to compile
+  extension modules with clang if gcc-4.2 is required but not found. Also as
+  a convenience, if the user does explicitly set CC, substitute its value as
+  the default compiler in the Distutils LDSHARED configuration variable for
+  OS X. (Note, the python.org 32-bit-only Pythons use gcc-4.0 and the 10.4u
   SDK, neither of which are available in Xcode 4.  This change does not
   attempt to override settings to support their use with Xcode 4.)
 
-- Issue #9021: Add an introduction to the copy module documentation.
+- bpo-9021: Add an introduction to the copy module documentation.
 
-- Issue #6005: Examples in the socket library documentation use sendall, where
+- bpo-6005: Examples in the socket library documentation use sendall, where
   relevant, instead send method.
 
-- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
-  raise a ProgrammingError now.
+- bpo-10811: Fix recursive usage of cursors. Instead of crashing, raise a
+  ProgrammingError now.
 
-- Issue #13676: Handle strings with embedded zeros correctly in sqlite3.
+- bpo-13676: Handle strings with embedded zeros correctly in sqlite3.
 
-- Issue #13806: The size check in audioop decompression functions was too
+- bpo-13806: The size check in audioop decompression functions was too
   strict and could reject valid compressed data.  Patch by Oleg Plakhotnyuk.
 
-- Issue #13885: CVE-2011-3389: the _ssl module would always disable the CBC
-  IV attack countermeasure.
+- bpo-13885: CVE-2011-3389: the _ssl module would always disable the CBC IV
+  attack countermeasure.
 
-- Issue #6631: Disallow relative file paths in urllib urlopen methods.
+- bpo-6631: Disallow relative file paths in urllib urlopen methods.
 
-- Issue #13781: Prevent gzip.GzipFile from using the dummy filename provided by
+- bpo-13781: Prevent gzip.GzipFile from using the dummy filename provided by
   file objects opened with os.fdopen().
 
-- Issue #13589: Fix some serialization primitives in the aifc module.
-  Patch by Oleg Plakhotnyuk.
+- bpo-13589: Fix some serialization primitives in the aifc module. Patch by
+  Oleg Plakhotnyuk.
 
-- Issue #13803: Under Solaris, distutils doesn't include bitness
-  in the directory name.
+- bpo-13803: Under Solaris, distutils doesn't include bitness in the
+  directory name.
 
-- Issue #13642: Unquote before b64encoding user:password during Basic
+- bpo-13642: Unquote before b64encoding user:password during Basic
   Authentication. Patch contributed by Joonas Kuorilehto and Michele Orrù.
 
-- Issue #13636: Weak ciphers are now disabled by default in the ssl module
+- bpo-13636: Weak ciphers are now disabled by default in the ssl module
   (except when SSLv2 is explicitly asked for).
 
-- Issue #12798: Updated the mimetypes documentation.
+- bpo-12798: Updated the mimetypes documentation.
 
-- Issue #13639: Accept unicode filenames in tarfile.open(mode="w|gz").
+- bpo-13639: Accept unicode filenames in tarfile.open(mode="w|gz").
 
-- Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
+- bpo-1785: Fix inspect and pydoc with misbehaving descriptors.
 
-- Issue #7502: Fix equality comparison for DocTestCase instances.  Patch by
+- bpo-7502: Fix equality comparison for DocTestCase instances.  Patch by
   Cédric Krier.
 
-- Issue #11870: threading: Properly reinitialize threads internal locks and
+- bpo-11870: threading: Properly reinitialize threads internal locks and
   condition variables to avoid deadlocks in child processes.
 
-- Issue #8035: urllib: Fix a bug where the client could remain stuck after a
+- bpo-8035: urllib: Fix a bug where the client could remain stuck after a
   redirection or an error.
 
 - tarfile.py: Correctly detect bzip2 compressed streams with blocksizes
   other than 900k.
 
-- Issue #13573: The csv.writer now uses the repr() for floats rather than str().
-  This allows floats to round-trip without loss of precision.
+- bpo-13573: The csv.writer now uses the repr() for floats rather than
+  str(). This allows floats to round-trip without loss of precision.
 
-- Issue #13439: Fix many errors in turtle docstrings.
+- bpo-13439: Fix many errors in turtle docstrings.
 
-- Issue #12856: Ensure child processes do not inherit the parent's random
-  seed for filename generation in the tempfile module.  Patch by Brian
-  Harring.
+- bpo-12856: Ensure child processes do not inherit the parent's random seed
+  for filename generation in the tempfile module.  Patch by Brian Harring.
 
-- Issue #13458: Fix a memory leak in the ssl module when decoding a
-  certificate with a subjectAltName.  Patch by Robert Xiao.
+- bpo-13458: Fix a memory leak in the ssl module when decoding a certificate
+  with a subjectAltName.  Patch by Robert Xiao.
 
-- Issue #13415: os.unsetenv() doesn't ignore errors anymore.
+- bpo-13415: os.unsetenv() doesn't ignore errors anymore.
 
-- Issue #13322: Fix BufferedWriter.write() to ensure that BlockingIOError is
-  raised when the wrapped raw file is non-blocking and the write would block.
-  Previous code assumed that the raw write() would raise BlockingIOError, but
-  RawIOBase.write() is defined to returned None when the call would block.
-  Patch by sbt.
+- bpo-13322: Fix BufferedWriter.write() to ensure that BlockingIOError is
+  raised when the wrapped raw file is non-blocking and the write would
+  block. Previous code assumed that the raw write() would raise
+  BlockingIOError, but RawIOBase.write() is defined to returned None when
+  the call would block. Patch by sbt.
 
-- Issue #13358: HTMLParser now calls handle_data only once for each CDATA.
+- bpo-13358: HTMLParser now calls handle_data only once for each CDATA.
 
-- Issue #4147: minidom's toprettyxml no longer adds whitespace around a text
+- bpo-4147: minidom's toprettyxml no longer adds whitespace around a text
   node when it is the only child of an element.  Initial patch by Dan
   Kenigsberg.
 
-- Issues #1745761, #755670, #13357, #12629, #1200313: HTMLParser now correctly
-  handles non-valid attributes, including adjacent and unquoted attributes.
+- bpo-1745761: HTMLParser now correctly handles non-valid attributes,
+  including adjacent and unquoted attributes. (See also: bpo-755670,
+  bpo-13357, bpo-12629, bpo-1200313)
 
-- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
+- bpo-13373: multiprocessing.Queue.get() could sometimes block indefinitely
   when called with a timeout.  Patch by Arnaud Ysmal.
 
-- Issue #3067: Enhance the documentation and docstring of
-  locale.setlocale().
+- bpo-3067: Enhance the documentation and docstring of locale.setlocale().
 
-- Issue #13254: Fix Maildir initialization so that maildir contents
-  are read correctly.
+- bpo-13254: Fix Maildir initialization so that maildir contents are read
+  correctly.
 
-- Issue #13140: Fix the daemon_threads attribute of ThreadingMixIn.
+- bpo-13140: Fix the daemon_threads attribute of ThreadingMixIn.
 
-- Issue #2892: preserve iterparse events in case of SyntaxError.
+- bpo-2892: preserve iterparse events in case of SyntaxError.
 
-- Issue #670664: Fix HTMLParser to correctly handle the content of
+- bpo-670664: Fix HTMLParser to correctly handle the content of
   ``<script>...</script>`` and ``<style>...</style>``.
 
-- Issue #10817: Fix urlretrieve function to raise ContentTooShortError even
+- bpo-10817: Fix urlretrieve function to raise ContentTooShortError even
   when reporthook is None. Patch by Jyrki Pulliainen.
 
-- Issue #7334: close source files on ElementTree.parse and iterparse.
+- bpo-7334: close source files on ElementTree.parse and iterparse.
 
-- Issue #13232: logging: Improved logging of exceptions in the presence of
+- bpo-13232: logging: Improved logging of exceptions in the presence of
   multiple encodings.
 
-- Issue #10332: multiprocessing: fix a race condition when a Pool is closed
+- bpo-10332: multiprocessing: fix a race condition when a Pool is closed
   before all tasks have completed.
 
-- Issue #1548891: The cStringIO.StringIO() constructor now encodes unicode
+- bpo-1548891: The cStringIO.StringIO() constructor now encodes unicode
   arguments with the system default encoding just like the write() method
-  does, instead of converting it to a raw buffer.  This also fixes handling of
-  unicode input in the shlex module (#6988, #1170).
+  does, instead of converting it to a raw buffer.  This also fixes handling
+  of unicode input in the shlex module (#6988, #1170).
 
-- Issue #9168: now smtpd is able to bind privileged port.
+- bpo-9168: now smtpd is able to bind privileged port.
 
-- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
+- bpo-12529: fix cgi.parse_header issue on strings with double-quotes and
   semicolons together. Patch by Ben Darnell and Petri Lehtinen.
 
-- Issue #6090: zipfile raises a ValueError when a document with a timestamp
+- bpo-6090: zipfile raises a ValueError when a document with a timestamp
   earlier than 1980 is provided. Patch contributed by Petri Lehtinen.
 
-- Issue #13194: zlib.compressobj().copy() and zlib.decompressobj().copy() are
+- bpo-13194: zlib.compressobj().copy() and zlib.decompressobj().copy() are
   now available on Windows.
 
-- Issue #13114: Fix the distutils commands check and register when the
-  long description is a Unicode string with non-ASCII characters.
+- bpo-13114: Fix the distutils commands check and register when the long
+  description is a Unicode string with non-ASCII characters.
 
-- Issue #7367: Fix pkgutil.walk_paths to skip directories whose
-  contents cannot be read.
+- bpo-7367: Fix pkgutil.walk_paths to skip directories whose contents cannot
+  be read.
 
-- Issue #7425: Prevent pydoc -k failures due to module import errors.
-  (Backport to 2.7 of existing 3.x fix)
+- bpo-7425: Prevent pydoc -k failures due to module import errors. (Backport
+  to 2.7 of existing 3.x fix)
 
-- Issue #13099: Fix sqlite3.Cursor.lastrowid under a Turkish locale.
-  Reported and diagnosed by Thomas Kluyver.
+- bpo-13099: Fix sqlite3.Cursor.lastrowid under a Turkish locale. Reported
+  and diagnosed by Thomas Kluyver.
 
-- Issue #7689: Allow pickling of dynamically created classes when their
+- bpo-7689: Allow pickling of dynamically created classes when their
   metaclass is registered with copy_reg.  Patch by Nicolas M. Thiéry and
   Craig Citro.
 
-- Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by
+- bpo-13058: ossaudiodev: fix a file descriptor leak on error. Patch by
   Thomas Jarosch.
 
-- Issue #12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of
+- bpo-12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of
   failing with a UnicodeDecodeError.
 
-- Issue #8933: distutils' PKG-INFO files will now correctly report
-  Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
+- bpo-8933: distutils' PKG-INFO files will now correctly report Metadata-
+  Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
   present.
 
-- Issue #8286: The distutils command sdist will print a warning message instead
+- bpo-8286: The distutils command sdist will print a warning message instead
   of crashing when an invalid path is given in the manifest template.
 
-- Issue #12841: tarfile unnecessarily checked the existence of numerical user
-  and group ids on extraction. If one of them did not exist the respective id
-  of the current user (i.e. root) was used for the file and ownership
+- bpo-12841: tarfile unnecessarily checked the existence of numerical user
+  and group ids on extraction. If one of them did not exist the respective
+  id of the current user (i.e. root) was used for the file and ownership
   information was lost.
 
-- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
+- bpo-10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
   now respect a --skip-build option given to bdist.
 
-- Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
+- bpo-12287: Fix a stack corruption in ossaudiodev module when the FD is
   greater than FD_SETSIZE.
 
-- Issue #12839: Fix crash in zlib module due to version mismatch.
-  Fix by Richard M. Tew.
+- bpo-12839: Fix crash in zlib module due to version mismatch. Fix by
+  Richard M. Tew.
 
-- Issue #12786: Set communication pipes used by subprocess.Popen CLOEXEC to
+- bpo-12786: Set communication pipes used by subprocess.Popen CLOEXEC to
   avoid them being inherited by other subprocesses.
 
-- Issue #4106: Fix occasional exceptions printed out by multiprocessing on
+- bpo-4106: Fix occasional exceptions printed out by multiprocessing on
   interpreter shutdown.
 
-- Issue #11657: Fix sending file descriptors over 255 over a multiprocessing
+- bpo-11657: Fix sending file descriptors over 255 over a multiprocessing
   Pipe.
 
-- Issue #12213: Fix a buffering bug with interleaved reads and writes that
+- bpo-12213: Fix a buffering bug with interleaved reads and writes that
   could appear on io.BufferedRandom streams.
 
-- Issue #12326: sys.platform is now always 'linux2' on Linux, even if Python
-  is compiled on Linux 3.
+- bpo-12326: sys.platform is now always 'linux2' on Linux, even if Python is
+  compiled on Linux 3.
 
-- Issue #13007: whichdb should recognize gdbm 1.9 magic numbers.
+- bpo-13007: whichdb should recognize gdbm 1.9 magic numbers.
 
-- Issue #9173: Let shutil._make_archive work if the logger argument is None.
+- bpo-9173: Let shutil._make_archive work if the logger argument is None.
 
-- Issue #12650: Fix a race condition where a subprocess.Popen could leak
+- bpo-12650: Fix a race condition where a subprocess.Popen could leak
   resources (FD/zombie) when killed at the wrong time.
 
-- Issue #12752: Fix regression which prevented locale.normalize() from
+- bpo-12752: Fix regression which prevented locale.normalize() from
   accepting unicode strings.
 
-- Issue #12683: urlparse updated to include svn as schemes that uses relative
+- bpo-12683: urlparse updated to include svn as schemes that uses relative
   paths. (svn from 1.5 onwards support relative path).
 
-- Issue #11933: Fix incorrect mtime comparison in distutils.
+- bpo-11933: Fix incorrect mtime comparison in distutils.
 
-- Issues #11104, #8688: Fix the behavior of distutils' sdist command with
-  manually-maintained MANIFEST files.
+- bpo-11104: Fix the behavior of distutils' sdist command with manually-
+  maintained MANIFEST files. (See also: bpo-8688)
 
-- Issue #8887: "pydoc somebuiltin.somemethod" (or help('somebuiltin.somemethod')
-  in Python code) now finds the doc of the method.
+- bpo-8887: "pydoc somebuiltin.somemethod" (or
+  help('somebuiltin.somemethod') in Python code) now finds the doc of the
+  method.
 
-- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
+- bpo-12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
 
-- Issue #12514: Use try/finally to assure the timeit module restores garbage
+- bpo-12514: Use try/finally to assure the timeit module restores garbage
   collections when it is done.
 
-- Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
+- bpo-12607: In subprocess, fix issue where if stdin, stdout or stderr is
   given as a low fd, it gets overwritten.
 
-- Issue #12102: Document that buffered files must be flushed before being used
+- bpo-12102: Document that buffered files must be flushed before being used
   with mmap. Patch by Steffen Daode Nurpmeso.
 
-- Issue #12560: Build libpython.so on OpenBSD. Patch by Stefan Sperling.
+- bpo-12560: Build libpython.so on OpenBSD. Patch by Stefan Sperling.
 
-- Issue #1813: Fix codec lookup and setting/getting locales under Turkish
+- bpo-1813: Fix codec lookup and setting/getting locales under Turkish
   locales.
 
-- Issue #10883: Fix socket leaks in urllib when using FTP.
+- bpo-10883: Fix socket leaks in urllib when using FTP.
 
-- Issue #12592: Make Python build on OpenBSD 5 (and future major releases).
+- bpo-12592: Make Python build on OpenBSD 5 (and future major releases).
 
-- Issue #12372: POSIX semaphores are broken on AIX: don't use them.
+- bpo-12372: POSIX semaphores are broken on AIX: don't use them.
 
-- Issue #12571: Add a plat-linux3 directory mirroring the plat-linux2
-  directory, so that "import DLFCN" and other similar imports work on
-  Linux 3.0.
+- bpo-12571: Add a plat-linux3 directory mirroring the plat-linux2
+  directory, so that "import DLFCN" and other similar imports work on Linux
+  3.0.
 
-- Issue #7484: smtplib no longer puts <> around addresses in VRFY and EXPN
-  commands; they aren't required and in fact postfix doesn't support that form.
+- bpo-7484: smtplib no longer puts <> around addresses in VRFY and EXPN
+  commands; they aren't required and in fact postfix doesn't support that
+  form.
 
-- Issue #11603: Fix a crash when __str__ is rebound as __repr__.  Patch by
+- bpo-11603: Fix a crash when __str__ is rebound as __repr__.  Patch by
   Andreas Stührk.
 
-- Issue #12502: asyncore: fix polling loop with AF_UNIX sockets.
+- bpo-12502: asyncore: fix polling loop with AF_UNIX sockets.
 
-- Issue #4376: ctypes now supports nested structures in an endian different than
-  the parent structure. Patch by Vlad Riscutia.
+- bpo-4376: ctypes now supports nested structures in an endian different
+  than the parent structure. Patch by Vlad Riscutia.
 
-- Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors
+- bpo-12493: subprocess: Popen.communicate() now also handles EINTR errors
   if the process has only one pipe.
 
-- Issue #12467: warnings: fix a race condition if a warning is emitted at
+- bpo-12467: warnings: fix a race condition if a warning is emitted at
   shutdown, if globals()['__file__'] is None.
 
-- Issue #12352: Fix a deadlock in multiprocessing.Heap when a block is freed by
+- bpo-12352: Fix a deadlock in multiprocessing.Heap when a block is freed by
   the garbage collector while the Heap lock is held.
 
-- Issue #9516: On Mac OS X, change Distutils to no longer globally attempt to
+- bpo-9516: On Mac OS X, change Distutils to no longer globally attempt to
   check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the
-  interpreter process.  This could cause failures in non-Distutils subprocesses
-  and was unreliable since tests or user programs could modify the interpreter
-  environment after Distutils set it.  Instead, have Distutils set the
-  deployment target only in the environment of each build subprocess.  It is
-  still possible to globally override the default by setting
-  MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be
-  greater or equal to the default value, the value with which the interpreter
-  was built.
-
-- Issue #11802: The cache in filecmp now has a maximum size of 100 so that
-  it won't grow without bound.
-
-- Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira
+  interpreter process.  This could cause failures in non-Distutils
+  subprocesses and was unreliable since tests or user programs could modify
+  the interpreter environment after Distutils set it.  Instead, have
+  Distutils set the deployment target only in the environment of each build
+  subprocess.  It is still possible to globally override the default by
+  setting MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its
+  value must be greater or equal to the default value, the value with which
+  the interpreter was built.
+
+- bpo-11802: The cache in filecmp now has a maximum size of 100 so that it
+  won't grow without bound.
+
+- bpo-12404: Remove C89 incompatible code from mmap module. Patch by Akira
   Kitada.
 
-- Issue #11700: mailbox proxy object close methods can now be called multiple
+- bpo-11700: mailbox proxy object close methods can now be called multiple
   times without error, and _ProxyFile now closes the wrapped file.
 
-- Issue #12133: AbstractHTTPHandler.do_open() of urllib.request closes the HTTP
+- bpo-12133: AbstractHTTPHandler.do_open() of urllib.request closes the HTTP
   connection if its getresponse() method fails with a socket error. Patch
   written by Ezio Melotti.
 
-- Issue #9284: Allow inspect.findsource() to find the source of doctest
+- bpo-9284: Allow inspect.findsource() to find the source of doctest
   functions.
 
-- Issue #10694: zipfile now ignores garbage at the end of a zipfile.
+- bpo-10694: zipfile now ignores garbage at the end of a zipfile.
 
-- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
+- bpo-11583: Speed up os.path.isdir on Windows by using GetFileAttributes
   instead of os.stat.
 
-- Issue #12080: Fix a performance issue in Decimal._power_exact that caused
+- bpo-12080: Fix a performance issue in Decimal._power_exact that caused
   some corner-case Decimal.__pow__ calls to take an unreasonably long time.
 
 - Named tuples now work correctly with vars().
@@ -4922,216 +5360,209 @@ Library
   updating the check interval, so if the user decreases the check interval,
   the ticker doesn't have to wind down to zero from the old starting point
   before the new interval takes effect.  And if the user increases the
-  interval, it makes sure the new limit takes effect right away rather have an
-  early task switch before recognizing the new interval.
-
-- Issue #12085: Fix an attribute error in subprocess.Popen destructor if the
-  constructor has failed, e.g. because of an undeclared keyword argument. Patch
-  written by Oleg Oshmyan.
+  interval, it makes sure the new limit takes effect right away rather have
+  an early task switch before recognizing the new interval.
 
-Extension Modules
------------------
+- bpo-12085: Fix an attribute error in subprocess.Popen destructor if the
+  constructor has failed, e.g. because of an undeclared keyword argument.
+  Patch written by Oleg Oshmyan.
 
-- Issue #9041: An issue in ctypes.c_longdouble, ctypes.c_double, and
+- bpo-9041: An issue in ctypes.c_longdouble, ctypes.c_double, and
   ctypes.c_float that caused an incorrect exception to be returned in the
   case of overflow has been fixed.
 
 - bsddb module: Erratic behaviour of "DBEnv->rep_elect()" because a typo.
   Possible crash.
 
-- Issue #13774: json: Fix a SystemError when a bogus encoding is passed to
+- bpo-13774: json: Fix a SystemError when a bogus encoding is passed to
   json.loads().
 
-- Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
+- bpo-9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
   Vilmos Nebehaj.
 
-- Issue #13159: FileIO, BZ2File, and the built-in file class now use a
-  linear-time buffer growth strategy instead of a quadratic one.
+- bpo-13159: FileIO, BZ2File, and the built-in file class now use a linear-
+  time buffer growth strategy instead of a quadratic one.
 
-- Issue #13070: Fix a crash when a TextIOWrapper caught in a reference cycle
+- bpo-13070: Fix a crash when a TextIOWrapper caught in a reference cycle
   would be finalized after the reference to its underlying BufferedRWPair's
   writer got cleared by the GC.
 
-- Issue #12881: ctypes: Fix segfault with large structure field names.
+- bpo-12881: ctypes: Fix segfault with large structure field names.
 
-- Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype.
-  Thanks to Suman Saha for finding the bug and providing a patch.
+- bpo-13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype. Thanks
+  to Suman Saha for finding the bug and providing a patch.
 
-- Issue #13022: Fix: _multiprocessing.recvfd() doesn't check that
-  file descriptor was actually received.
+- bpo-13022: Fix: _multiprocessing.recvfd() doesn't check that file
+  descriptor was actually received.
 
-- Issue #12483: ctypes: Fix a crash when the destruction of a callback
-  object triggers the garbage collector.
+- bpo-12483: ctypes: Fix a crash when the destruction of a callback object
+  triggers the garbage collector.
 
-- Issue #12950: Fix passing file descriptors in multiprocessing, under
+- bpo-12950: Fix passing file descriptors in multiprocessing, under
   OpenIndiana/Illumos.
 
-- Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
+- bpo-12764: Fix a crash in ctypes when the name of a Structure field is not
   a string.
 
-- Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
+- bpo-9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
   some functions like file.write().
 
-- Issue #10309: Define _GNU_SOURCE so that mremap() gets the proper
-  signature.  Without this, architectures where sizeof void* != sizeof int are
-  broken.  Patch given by Hallvard B Furuseth.
+- bpo-10309: Define _GNU_SOURCE so that mremap() gets the proper signature.
+  Without this, architectures where sizeof void* != sizeof int are broken.
+  Patch given by Hallvard B Furuseth.
 
 IDLE
 ----
 
-- Issue #964437: Make IDLE help window non-modal.
-  Patch by Guilherme Polo and Roger Serwy.
+- bpo-964437: Make IDLE help window non-modal. Patch by Guilherme Polo and
+  Roger Serwy.
 
-- Issue #13933: IDLE auto-complete did not work with some imported
-  module, like hashlib.  (Patch by Roger Serwy)
+- bpo-13933: IDLE auto-complete did not work with some imported module, like
+  hashlib. (Patch by Roger Serwy)
 
-- Issue #13506: Add '' to path for IDLE Shell when started and restarted with Restart Shell.
-  Original patches by Marco Scataglini and Roger Serwy.
+- bpo-13506: Add '' to path for IDLE Shell when started and restarted with
+  Restart Shell. Original patches by Marco Scataglini and Roger Serwy.
 
-- Issue #4625: If IDLE cannot write to its recent file or breakpoint
-  files, display a message popup and continue rather than crash.
-  (original patch by Roger Serwy)
+- bpo-4625: If IDLE cannot write to its recent file or breakpoint files,
+  display a message popup and continue rather than crash. (original patch by
+  Roger Serwy)
 
-- Issue #8793: Prevent IDLE crash when given strings with invalid hex escape
+- bpo-8793: Prevent IDLE crash when given strings with invalid hex escape
   sequences.
 
-- Issue #13296: Fix IDLE to clear compile __future__ flags on shell restart.
+- bpo-13296: Fix IDLE to clear compile __future__ flags on shell restart.
   (Patch by Roger Serwy)
 
-- Issue #14409: IDLE now properly executes commands in the Shell window
-  when it cannot read the normal config files on startup and
-  has to use the built-in default key bindings.
-  There was previously a bug in one of the defaults.
+- bpo-14409: IDLE now properly executes commands in the Shell window when it
+  cannot read the normal config files on startup and has to use the built-in
+  default key bindings. There was previously a bug in one of the defaults.
 
-- Issue #3573: IDLE hangs when passing invalid command line args
+- bpo-3573: IDLE hangs when passing invalid command line args
   (directory(ies) instead of file(s)).
 
 Build
 -----
 
-- Issue #6807: Run msisupport.mak earlier.
+- bpo-6807: Run msisupport.mak earlier.
 
-- Issue #10580: Minor grammar change in Windows installer.
+- bpo-10580: Minor grammar change in Windows installer.
 
-- Issue #12627: Implement PEP 394 for Python 2.7 ("python2").
+- bpo-12627: Implement PEP 394 for Python 2.7 ("python2").
 
-- Issue #8746: Correct faulty configure checks so that os.chflags() and
-  os.lchflags() are once again built on systems that support these
-  functions (*BSD and OS X).  Also add new stat file flags for OS X
-  (UF_HIDDEN and UF_COMPRESSED).
+- bpo-8746: Correct faulty configure checks so that os.chflags() and
+  os.lchflags() are once again built on systems that support these functions
+  (*BSD and OS X). Also add new stat file flags for OS X (UF_HIDDEN and
+  UF_COMPRESSED).
 
 Tools/Demos
 -----------
 
-- Issue #14053: patchcheck.py ("make patchcheck") now works with MQ patches.
+- bpo-14053: patchcheck.py ("make patchcheck") now works with MQ patches.
   Patch by Francisco Martín Brugué.
 
-- Issue #13930: 2to3 is now able to write its converted output files to another
+- bpo-13930: 2to3 is now able to write its converted output files to another
   directory tree as well as copying unchanged files and altering the file
   suffix.  See its new -o, -W and --add-suffix options.  This makes it more
   useful in many automated code translation workflows.
 
-- Issue #10639: reindent.py no longer converts newlines and will raise
-  an error if attempting to convert a file with mixed newlines.
+- bpo-10639: reindent.py no longer converts newlines and will raise an error
+  if attempting to convert a file with mixed newlines.
 
-- Issue #13628: python-gdb.py is now able to retrieve more frames in the Python
+- bpo-13628: python-gdb.py is now able to retrieve more frames in the Python
   traceback if Python is optimized.
 
 Tests
 -----
 
-- Issue #15467: Move helpers for __sizeof__ tests into test_support.
-  Patch by Serhiy Storchaka.
+- bpo-15467: Move helpers for __sizeof__ tests into test_support. Patch by
+  Serhiy Storchaka.
 
-- Issue #11689: Fix a variable scoping error in an sqlite3 test.
-  Initial patch by Torsten Landschoff.
+- bpo-11689: Fix a variable scoping error in an sqlite3 test. Initial patch
+  by Torsten Landschoff.
 
-- Issue #10881: Fix test_site failures with OS X framework builds.
+- bpo-10881: Fix test_site failures with OS X framework builds.
 
-- Issue #13901: Prevent test_distutils failures on OS X with --enable-shared.
+- bpo-13901: Prevent test_distutils failures on OS X with --enable-shared.
 
-- Issue #13304: Skip test case if user site-packages disabled (-s or
-  PYTHONNOUSERSITE).  (Patch by Carl Meyer)
+- bpo-13304: Skip test case if user site-packages disabled (-s or
+  PYTHONNOUSERSITE). (Patch by Carl Meyer)
 
-- Issue #13218: Fix test_ssl failures on Debian/Ubuntu.
+- bpo-13218: Fix test_ssl failures on Debian/Ubuntu.
 
-- Issue #12821: Fix test_fcntl failures on OpenBSD 5.
+- bpo-12821: Fix test_fcntl failures on OpenBSD 5.
 
-- Issue #12331: The test suite for lib2to3 can now run from an installed
+- bpo-12331: The test suite for lib2to3 can now run from an installed
   Python.
 
-- Issue #12549: Correct test_platform to not fail when OS X returns 'x86_64'
-  as the processor type on some Mac systems.
+- bpo-12549: Correct test_platform to not fail when OS X returns 'x86_64' as
+  the processor type on some Mac systems.
 
-- Skip network tests when getaddrinfo() returns EAI_AGAIN, meaning a temporary
-  failure in name resolution.
+- Skip network tests when getaddrinfo() returns EAI_AGAIN, meaning a
+  temporary failure in name resolution.
 
-- Issue #11812: Solve transient socket failure to connect to 'localhost'
-  in test_telnetlib.py.
+- bpo-11812: Solve transient socket failure to connect to 'localhost' in
+  test_telnetlib.py.
 
 - Solved a potential deadlock in test_telnetlib.py. Related to issue #11812.
 
-- Avoid failing in test_robotparser when mueblesmoraleda.com is flaky and
-  an overzealous DNS service (e.g. OpenDNS) redirects to a placeholder
-  Web site.
+- Avoid failing in test_robotparser when mueblesmoraleda.com is flaky and an
+  overzealous DNS service (e.g. OpenDNS) redirects to a placeholder Web
+  site.
 
-- Avoid failing in test_urllibnet.test_bad_address when some overzealous
-  DNS service (e.g. OpenDNS) resolves a non-existent domain name.  The test
-  is now skipped instead.
+- Avoid failing in test_urllibnet.test_bad_address when some overzealous DNS
+  service (e.g. OpenDNS) resolves a non-existent domain name.  The test is
+  now skipped instead.
 
-- Issue #8716: Avoid crashes caused by Aqua Tk on OSX when attempting to run
+- bpo-8716: Avoid crashes caused by Aqua Tk on OSX when attempting to run
   test_tk or test_ttk_guionly under a username that is not currently logged
   in to the console windowserver (as may be the case under buildbot or ssh).
 
-- Issue #12141: Install a copy of template C module file so that
-  test_build_ext of test_distutils is no longer silently skipped when
-  run outside of a build directory.
+- bpo-12141: Install a copy of template C module file so that test_build_ext
+  of test_distutils is no longer silently skipped when run outside of a
+  build directory.
 
-- Issue #8746: Add additional tests for os.chflags() and os.lchflags().
-  Patch by Garrett Cooper.
+- bpo-8746: Add additional tests for os.chflags() and os.lchflags(). Patch
+  by Garrett Cooper.
 
-- Issue #10736: Fix test_ttk test_widgets failures with Cocoa Tk 8.5.9
-  on Mac OS X.  (Patch by Ronald Oussoren)
+- bpo-10736: Fix test_ttk test_widgets failures with Cocoa Tk 8.5.9 on Mac
+  OS X.  (Patch by Ronald Oussoren)
 
-- Issue #12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2,
+- bpo-12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2,
   iso2022_kr).
 
 Documentation
 -------------
 
-- Issues #13491 and #13995: Fix many errors in sqlite3 documentation.
-  Initial patch for #13491 by Johannes Vogel.
+- bpo-13491: Fix many errors in sqlite3 documentation. Initial patch for
+  #13491 by Johannes Vogel. (See also: bpo-13995)
 
-- Issue #13402: Document absoluteness of sys.executable.
+- bpo-13402: Document absoluteness of sys.executable.
 
-- Issue #13883: PYTHONCASEOK also works on OS X, OS/2, and RiscOS.
+- bpo-13883: PYTHONCASEOK also works on OS X, OS/2, and RiscOS.
 
-- Issue #2134: The tokenize documentation has been clarified to explain why
-  all operator and delimiter tokens are treated as token.OP tokens.
+- bpo-2134: The tokenize documentation has been clarified to explain why all
+  operator and delimiter tokens are treated as token.OP tokens.
 
-- Issue #13513: Fix io.IOBase documentation to correctly link to the
+- bpo-13513: Fix io.IOBase documentation to correctly link to the
   io.IOBase.readline method instead of the readline module.
 
-- Issue #13237: Reorganise subprocess documentation to emphasise convenience
+- bpo-13237: Reorganise subprocess documentation to emphasise convenience
   functions and the most commonly needed arguments to Popen.
 
-- Issue #13141: Demonstrate recommended style for SocketServer examples.
+- bpo-13141: Demonstrate recommended style for SocketServer examples.
 
 
-What's New in Python 2.7.2?
-===========================
+What's New in Python 2.7.2 final?
+=================================
 
 *Release date: 2011-06-11*
 
 Library
 -------
 
-- Issue #12009: Fixed regression in netrc file comment handling.
-
-Extension Modules
------------------
+- bpo-12009: Fixed regression in netrc file comment handling.
 
-- Issue #1221: Make pyexpat.__version__ equal to the Python version.
+- bpo-1221: Make pyexpat.__version__ equal to the Python version.
 
 
 What's New in Python 2.7.2 release candidate 1?
@@ -5142,598 +5573,600 @@ What's New in Python 2.7.2 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #9670: Increase the default stack size for secondary threads on
-  Mac OS X and FreeBSD to reduce the chances of a crash instead of a
-  "maximum recursion depth" RuntimeError exception.
-  (patch by Ronald Oussoren)
+- bpo-9670: Increase the default stack size for secondary threads on Mac OS
+  X and FreeBSD to reduce the chances of a crash instead of a "maximum
+  recursion depth" RuntimeError exception. (patch by Ronald Oussoren)
 
-- Correct lookup of __dir__ on objects. This allows old-style classes to have
-  __dir__. It also causes errors besides AttributeError found on lookup to be
-  propagated.
+- Correct lookup of __dir__ on objects. This allows old-style classes to
+  have __dir__. It also causes errors besides AttributeError found on lookup
+  to be propagated.
 
-- Issue #1195: Fix input() if it is interrupted by CTRL+d and then CTRL+c,
-  clear the end-of-file indicator after CTRL+d.
+- bpo-1195: Fix input() if it is interrupted by CTRL+d and then CTRL+c,
+  clear the end- of-file indicator after CTRL+d.
 
-- Issue #8651: PyArg_Parse*() functions raise an OverflowError if the file
+- bpo-8651: PyArg_Parse*() functions raise an OverflowError if the file
   doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int
   (length bigger than 2^31-1 bytes).
 
-- Issue #8651: Fix "z#" format of PyArg_Parse*() function: the size was not
+- bpo-8651: Fix "z#" format of PyArg_Parse*() function: the size was not
   written if PY_SSIZE_T_CLEAN is defined.
 
-- Issue #9756: When calling a method descriptor or a slot wrapper descriptor,
+- bpo-9756: When calling a method descriptor or a slot wrapper descriptor,
   the check of the object type doesn't read the __class__ attribute anymore.
-  Fix a crash if a class override its __class__ attribute (e.g. a proxy of the
-  str type). Patch written by Andreas Stührk.
+  Fix a crash if a class override its __class__ attribute (e.g. a proxy of
+  the str type). Patch written by Andreas Stührk.
 
-- Issue #10517: After fork(), reinitialize the TLS used by the PyGILState_*
+- bpo-10517: After fork(), reinitialize the TLS used by the PyGILState_*
   APIs, to avoid a crash with the pthread implementation in RHEL 5.  Patch
   by Charles-François Natali.
 
-- Issue #6780: fix starts/endswith error message to mention that tuples are
+- bpo-6780: fix starts/endswith error message to mention that tuples are
   accepted too.
 
-- Issue #5057: fix a bug in the peepholer that led to non-portable pyc files
+- bpo-5057: fix a bug in the peepholer that led to non-portable pyc files
   between narrow and wide builds while optimizing BINARY_SUBSCR on non-BMP
   chars (e.g. u"\U00012345"[0]).
 
-- Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
-  (EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
-  written by Charles-Francois Natali.
+- bpo-11650: PyOS_StdioReadline() retries fgets() if it was interrupted
+  (EINTR), for example if the program is stopped with CTRL+z on Mac OS X.
+  Patch written by Charles-Francois Natali.
 
-- Issue #11144: Ensure that int(a_float) returns an int whenever possible.
+- bpo-11144: Ensure that int(a_float) returns an int whenever possible.
   Previously, there were some corner cases where a long was returned even
   though the result was within the range of an int.
 
-- Issue #11450: Don't truncate hg version info in Py_GetBuildInfo() when
-  there are many tags (e.g. when using mq).  Patch by Nadeem Vawda.
+- bpo-11450: Don't truncate hg version info in Py_GetBuildInfo() when there
+  are many tags (e.g. when using mq).  Patch by Nadeem Vawda.
 
-- Issue #10451: memoryview objects could allow mutating a readable buffer.
+- bpo-10451: memoryview objects could allow mutating a readable buffer.
   Initial patch by Ross Lagerwall.
 
-- Issue #10892: Don't segfault when trying to delete __abstractmethods__ from a
+- bpo-10892: Don't segfault when trying to delete __abstractmethods__ from a
   class.
 
-- Issue #8020: Avoid a crash where the small objects allocator would read
-  non-Python managed memory while it is being modified by another thread.
-  Patch by Matt Bandy.
+- bpo-8020: Avoid a crash where the small objects allocator would read non-
+  Python managed memory while it is being modified by another thread. Patch
+  by Matt Bandy.
 
-- Issue #11004: Repaired edge case in deque.count().
+- bpo-11004: Repaired edge case in deque.count().
 
-- Issue #8278: On Windows and with a NTFS filesystem, os.stat() and os.utime()
+- bpo-8278: On Windows and with a NTFS filesystem, os.stat() and os.utime()
   can now handle dates after 2038.
 
-- Issue #4236: Py_InitModule4 now checks the import machinery directly
-  rather than the Py_IsInitialized flag, avoiding a Fatal Python
-  error in certain circumstances when an import is done in __del__.
+- bpo-4236: Py_InitModule4 now checks the import machinery directly rather
+  than the Py_IsInitialized flag, avoiding a Fatal Python error in certain
+  circumstances when an import is done in __del__.
 
-- Issue #11828: startswith and endswith don't accept None as slice index.
-  Patch by Torsten Becker.
+- bpo-11828: startswith and endswith don't accept None as slice index. Patch
+  by Torsten Becker.
 
-- Issue #10674: Remove unused 'dictmaker' rule from grammar.
+- bpo-10674: Remove unused 'dictmaker' rule from grammar.
 
-- Issue #10596: Fix float.__mod__ to have the same behaviour as
-  float.__divmod__ with respect to signed zeros.  -4.0 % 4.0 should be
-  0.0, not -0.0.
+- bpo-10596: Fix float.__mod__ to have the same behaviour as
+  float.__divmod__ with respect to signed zeros.  -4.0 % 4.0 should be 0.0,
+  not -0.0.
 
-- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
+- bpo-11386: bytearray.pop() now throws IndexError when the bytearray is
   empty, instead of OverflowError.
 
 Library
 -------
 
-- Issue #12161: Cause StringIO.getvalue() to raise a ValueError when used on a
+- bpo-12161: Cause StringIO.getvalue() to raise a ValueError when used on a
   closed StringIO instance.
 
-- Issue #12182: Fix pydoc.HTMLDoc.multicolumn() if Python uses the new (true)
+- bpo-12182: Fix pydoc.HTMLDoc.multicolumn() if Python uses the new (true)
   division (python -Qnew). Patch written by Ralf W. Grosse-Kunstleve.
 
-- Issue #12175: RawIOBase.readall() now returns None if read() returns None.
+- bpo-12175: RawIOBase.readall() now returns None if read() returns None.
 
-- Issue #12175: FileIO.readall() now raises a ValueError instead of an IOError
+- bpo-12175: FileIO.readall() now raises a ValueError instead of an IOError
   if the file is closed.
 
-- Issue #1441530: In imaplib, use makefile() to wrap the SSL socket to avoid
+- bpo-1441530: In imaplib, use makefile() to wrap the SSL socket to avoid
   heap fragmentation and MemoryError with some malloc implementations.
 
-- Issue #12100: Don't reset incremental encoders of CJK codecs at each call to
-  their encode() method anymore, but continue to call the reset() method if the
-  final argument is True.
+- bpo-12100: Don't reset incremental encoders of CJK codecs at each call to
+  their encode() method anymore, but continue to call the reset() method if
+  the final argument is True.
 
-- Issue #12124: zipimport doesn't keep a reference to zlib.decompress() anymore
+- bpo-12124: zipimport doesn't keep a reference to zlib.decompress() anymore
   to be able to unload the module.
 
-- Issue #10154, #10090: change the normalization of UTF-8 to "UTF-8" instead
-  of "UTF8" in the locale module as the latter is not supported MacOSX and OpenBSD.
+- bpo-10154: change the normalization of UTF-8 to "UTF-8" instead of "UTF8"
+  in the locale module as the latter is not supported MacOSX and OpenBSD.
+  (See also: bpo-10090)
 
-- Issue #9516: avoid errors in sysconfig when MACOSX_DEPLOYMENT_TARGET is
-  set in shell.
+- bpo-9516: avoid errors in sysconfig when MACOSX_DEPLOYMENT_TARGET is set
+  in shell.
 
-- Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
-  attribute when called without a max_length argument.
+- bpo-12050: zlib.decompressobj().decompress() now clears the
+  unconsumed_tail attribute when called without a max_length argument.
 
-- Issue #12062: In the `io` module, fix a flushing bug when doing a certain
+- bpo-12062: In the `io` module, fix a flushing bug when doing a certain
   type of I/O sequence on a file opened in read+write mode (namely: reading,
   seeking a bit forward, writing, then seeking before the previous write but
   still within buffered data, and writing again).
 
-- Issue #8498: In socket.accept(), allow specifying 0 as a backlog value in
+- bpo-8498: In socket.accept(), allow specifying 0 as a backlog value in
   order to accept exactly one connection.  Patch by Daniel Evers.
 
-- Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional.
+- bpo-12012: ssl.PROTOCOL_SSLv2 becomes optional.
 
-- Issue #11927: SMTP_SSL now uses port 465 by default as documented.  Patch
-  by Kasun Herath.
+- bpo-11927: SMTP_SSL now uses port 465 by default as documented.  Patch by
+  Kasun Herath.
 
-- Issue #11999: fixed sporadic sync failure mailbox.Maildir due to its trying to
-  detect mtime changes by comparing to the system clock instead of to the
+- bpo-11999: fixed sporadic sync failure mailbox.Maildir due to its trying
+  to detect mtime changes by comparing to the system clock instead of to the
   previous value of the mtime.
 
-- Issue #10684: shutil.move used to delete a folder on case insensitive
-  filesystems when the source and destination name where the same except
-  for the case.
+- bpo-10684: shutil.move used to delete a folder on case insensitive
+  filesystems when the source and destination name where the same except for
+  the case.
 
-- Issue #11982: fix json.loads('""') to return u'' rather than ''.
+- bpo-11982: fix json.loads('""') to return u'' rather than ''.
 
-- Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get
-  around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso.
+- bpo-11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get
+  around a mmap bug with sparse files. Patch written by Steffen Daode
+  Nurpmeso.
 
-- Issue #10761: Fix tarfile.extractall failure when symlinked files are
+- bpo-10761: Fix tarfile.extractall failure when symlinked files are
   present. Initial patch by Scott Leerssen.
 
-- Issue #11763: don't use difflib in TestCase.assertMultiLineEqual if the
+- bpo-11763: don't use difflib in TestCase.assertMultiLineEqual if the
   strings are too long.
 
-- Issue #11236: getpass.getpass responds to ctrl-c or ctrl-z on terminal.
+- bpo-11236: getpass.getpass responds to ctrl-c or ctrl-z on terminal.
 
-- Issue #11768: The signal handler of the signal module only calls
+- bpo-11768: The signal handler of the signal module only calls
   Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
   parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
 
-- Issue #11875: collections.OrderedDict's __reduce__ was temporarily
-  mutating the object instead of just working on a copy.
+- bpo-11875: collections.OrderedDict's __reduce__ was temporarily mutating
+  the object instead of just working on a copy.
 
-- Issue #11442: Add a charset parameter to the Content-type in SimpleHTTPServer
+- bpo-11442: Add a charset parameter to the Content-type in SimpleHTTPServer
   to avoid XSS attacks.
 
-- Issue #11467: Fix urlparse behavior when handling urls which contains scheme
+- bpo-11467: Fix urlparse behavior when handling urls which contains scheme
   specific part only digits. Patch by Santoso Wijaya.
 
 - collections.Counter().copy() now works correctly for subclasses.
 
-- Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
+- bpo-11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
   Patch by Santoso Wijaya.
 
-- Issue #9233: Fix json.loads('{}') to return a dict (instead of a list), when
+- bpo-9233: Fix json.loads('{}') to return a dict (instead of a list), when
   _json is not available.
 
-- Issue #11703: urllib2.geturl() does not return correct url when the original
+- bpo-11703: urllib2.geturl() does not return correct url when the original
   url contains #fragment.
 
-- Issue #10019: Fixed regression in json module where an indent of 0 stopped
+- bpo-10019: Fixed regression in json module where an indent of 0 stopped
   adding newlines and acted instead like 'None'.
 
-- Issue #5162: Treat services like frozen executables to allow child spawning
+- bpo-5162: Treat services like frozen executables to allow child spawning
   from multiprocessing.forking on Windows.
 
-- Issue #4877: Fix a segfault in xml.parsers.expat while attempting to parse
-  closed file.
+- bpo-4877: Fix a segfault in xml.parsers.expat while attempting to parse a
+  closed file.
 
-- Issue #11830: Remove unnecessary introspection code in the decimal module.
-  It was causing a failed import in the Turkish locale where the locale
+- bpo-11830: Remove unnecessary introspection code in the decimal module. It
+  was causing a failed import in the Turkish locale where the locale
   sensitive str.upper() method caused a name mismatch.
 
-- Issue #8428: Fix a race condition in multiprocessing.Pool when terminating
+- bpo-8428: Fix a race condition in multiprocessing.Pool when terminating
   worker processes: new processes would be spawned while the pool is being
-  shut down.  Patch by Charles-François Natali.
+  shut down. Patch by Charles-François Natali.
 
-- Issue #7311: Fix HTMLParser to accept non-ASCII attribute values.
+- bpo-7311: Fix HTMLParser to accept non-ASCII attribute values.
 
-- Issue #10963: Ensure that subprocess.communicate() never raises EPIPE.
+- bpo-10963: Ensure that subprocess.communicate() never raises EPIPE.
 
-- Issue #11662: Make urllib and urllib2 ignore redirections if the
-  scheme is not HTTP, HTTPS or FTP (CVE-2011-1521).
+- bpo-11662: Make urllib and urllib2 ignore redirections if the scheme is
+  not HTTP, HTTPS or FTP (CVE-2011-1521).
 
-- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
+- bpo-11256: Fix inspect.getcallargs on functions that take only keyword
   arguments.
 
-- Issue #11696: Fix ID generation in msilib.
+- bpo-11696: Fix ID generation in msilib.
 
-- Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
+- bpo-9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
   trying to pack a negative (in-range) integer.
 
-- Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
+- bpo-11675: multiprocessing.[Raw]Array objects created from an integer size
   are now zeroed on creation.  This matches the behaviour specified by the
   documentation.
 
-- Issue #7639: Fix short file name generation in bdist_msi.
+- bpo-7639: Fix short file name generation in bdist_msi.
 
-- Issue #11666: let help() display named tuple attributes and methods
-  that start with a leading underscore.
+- bpo-11666: let help() display named tuple attributes and methods that
+  start with a leading underscore.
 
-- Issue #11673: Fix multiprocessing Array and RawArray constructors to accept a
+- bpo-11673: Fix multiprocessing Array and RawArray constructors to accept a
   size of type 'long', rather than only accepting 'int'.
 
-- Issue #10042: Fixed the total_ordering decorator to handle cross-type
+- bpo-10042: Fixed the total_ordering decorator to handle cross-type
   comparisons that could lead to infinite recursion.
 
-- Issue #10979: unittest stdout buffering now works with class and module
-  setup and teardown.
+- bpo-10979: unittest stdout buffering now works with class and module setup
+  and teardown.
 
-- Issue #11569: use absolute path to the sysctl command in multiprocessing to
+- bpo-11569: use absolute path to the sysctl command in multiprocessing to
   ensure that it will be found regardless of the shell PATH. This ensures
   that multiprocessing.cpu_count works on default installs of MacOSX.
 
-- Issue #11500: Fixed a bug in the os x proxy bypass code for fully qualified
+- bpo-11500: Fixed a bug in the os x proxy bypass code for fully qualified
   IP addresses in the proxy exception list.
 
-- Issue #11131: Fix sign of zero in plus and minus operations when
-  the context rounding mode is ROUND_FLOOR.
+- bpo-11131: Fix sign of zero in plus and minus operations when the context
+  rounding mode is ROUND_FLOOR.
 
-- Issue #5622: Fix curses.wrapper to raise correct exception if curses
+- bpo-5622: Fix curses.wrapper to raise correct exception if curses
   initialization fails.
 
-- Issue #11391: Writing to a mmap object created with
+- bpo-11391: Writing to a mmap object created with
   ``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a
   TypeError.  Patch by Charles-François Natali.
 
-- Issue #11306: mailbox in certain cases adapts to an inability to open
-  certain files in read-write mode.  Previously it detected this by
-  checking for EACCES, now it also checks for EROFS.
+- bpo-11306: mailbox in certain cases adapts to an inability to open certain
+  files in read-write mode.  Previously it detected this by checking for
+  EACCES, now it also checks for EROFS.
 
-- Issue #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
+- bpo-11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
   on accept(), send() and recv().
 
-- Issue #11326: Add the missing connect_ex() implementation for SSL sockets,
+- bpo-11326: Add the missing connect_ex() implementation for SSL sockets,
   and make it work for non-blocking connects.
 
-- Issue #10956: Buffered I/O classes retry reading or writing after a signal
+- bpo-10956: Buffered I/O classes retry reading or writing after a signal
   has arrived and the handler returned successfully.
 
-- Issue #10680: Fix mutually exclusive arguments for argument groups in
+- bpo-10680: Fix mutually exclusive arguments for argument groups in
   argparse.
 
-- Issue #4681: Allow mmap() to work on file sizes and offsets larger than
-  4GB, even on 32-bit builds.  Initial patch by Ross Lagerwall, adapted for
+- bpo-4681: Allow mmap() to work on file sizes and offsets larger than 4GB,
+  even on 32-bit builds.  Initial patch by Ross Lagerwall, adapted for
   32-bit Windows.
 
-- Issue #10360: In WeakSet, do not raise TypeErrors when testing for
-  membership of non-weakrefable objects.
+- bpo-10360: In WeakSet, do not raise TypeErrors when testing for membership
+  of non- weakrefable objects.
 
-- Issue #10549: Fix pydoc traceback when text-documenting certain classes.
+- bpo-10549: Fix pydoc traceback when text-documenting certain classes.
 
-- Issue #940286: pydoc.Helper.help() ignores input/output init parameters.
+- bpo-940286: pydoc.Helper.help() ignores input/output init parameters.
 
-- Issue #11171: Fix detection of config/Makefile when --prefix !=
-  --exec-prefix, which caused Python to not start.
+- bpo-11171: Fix detection of config/Makefile when --prefix != --exec-
+  prefix, which caused Python to not start.
 
-- Issue #11116: any error during addition of a message to a mailbox now causes
+- bpo-11116: any error during addition of a message to a mailbox now causes
   a rollback, instead of leaving the mailbox partially modified.
 
-- Issue #8275: Fix passing of callback arguments with ctypes under Win64.
-  Patch by Stan Mihai.
+- bpo-8275: Fix passing of callback arguments with ctypes under Win64. Patch
+  by Stan Mihai.
 
-- Issue #10949: Improved robustness of rotating file handlers.
+- bpo-10949: Improved robustness of rotating file handlers.
 
-- Issue #10955: Fix a potential crash when trying to mmap() a file past its
+- bpo-10955: Fix a potential crash when trying to mmap() a file past its
   length.  Initial patch by Ross Lagerwall.
 
-- Issue #10898: Allow compiling the posix module when the C library defines
-  symbol named FSTAT.
+- bpo-10898: Allow compiling the posix module when the C library defines a
+  symbol named FSTAT.
 
-- Issue #10916: mmap should not segfault when a file is mapped using 0 as
-  length and a non-zero offset, and an attempt to read past the end of file
+- bpo-10916: mmap should not segfault when a file is mapped using 0 as
+  length and a non- zero offset, and an attempt to read past the end of file
   is made (IndexError is raised instead).  Patch by Ross Lagerwall.
 
-- Issue #10875: Update Regular Expression HOWTO; patch by 'SilentGhost'.
+- bpo-10875: Update Regular Expression HOWTO; patch by 'SilentGhost'.
 
-- Issue #10827: Changed the rules for 2-digit years.  The time.asctime
-  function will now format any year when ``time.accept2dyear`` is
-  false and will accept years >= 1000 otherwise.  The year range
-  accepted by ``time.mktime`` and ``time.strftime`` is still system
-  dependent, but ``time.mktime`` will now accept full range supported
-  by the OS.  Conversion of 2-digit years to 4-digit is deprecated.
+- bpo-10827: Changed the rules for 2-digit years.  The time.asctime function
+  will now format any year when ``time.accept2dyear`` is false and will
+  accept years >= 1000 otherwise.  The year range accepted by
+  ``time.mktime`` and ``time.strftime`` is still system dependent, but
+  ``time.mktime`` will now accept full range supported by the OS.
+  Conversion of 2-digit years to 4-digit is deprecated.
 
-- Issue #10869: Fixed bug where ast.increment_lineno modified the root
-  node twice.
+- bpo-10869: Fixed bug where ast.increment_lineno modified the root node
+  twice.
 
-- Issue #7858: Raise an error properly when os.utime() fails under Windows
-  on an existing file.
+- bpo-7858: Raise an error properly when os.utime() fails under Windows on
+  an existing file.
 
-- Issue #3839: wsgiref should not override a Content-Length header set by
-  the application.  Initial patch by Clovis Fabricio.
+- bpo-3839: wsgiref should not override a Content-Length header set by the
+  application. Initial patch by Clovis Fabricio.
 
-- Issue #10806, issue #9905: Fix subprocess pipes when some of the standard
-  file descriptors (0, 1, 2) are closed in the parent process.  Initial
-  patch by Ross Lagerwall.
+- bpo-10806: Fix subprocess pipes when some of the standard file descriptors
+  (0, 1, 2) are closed in the parent process.  Initial patch by Ross
+  Lagerwall. (See also: bpo-9905)
 
-- Issue #4662: os.tempnam(), os.tmpfile() and os.tmpnam() now raise a py3k
+- bpo-4662: os.tempnam(), os.tmpfile() and os.tmpnam() now raise a py3k
   DeprecationWarning.
 
 - Subclasses of collections.OrderedDict now work correctly with __missing__.
 
-- Issue #10753: Characters ';', '=' and ',' in the PATH_INFO environment
-  variable won't be quoted when the URI is constructed by the wsgiref.util 's
-  request_uri method. According to RFC 3986, these characters can be a part of
-  params in PATH component of URI and need not be quoted.
+- bpo-10753: Characters ';', '=' and ',' in the PATH_INFO environment
+  variable won't be quoted when the URI is constructed by the wsgiref.util
+  's request_uri method. According to RFC 3986, these characters can be a
+  part of params in PATH component of URI and need not be quoted.
 
-- Issue #10738: Fix webbrowser.Opera.raise_opts
+- bpo-10738: Fix webbrowser.Opera.raise_opts
 
-- Issue #9824: SimpleCookie now encodes , and ; in values to cater to how
+- bpo-9824: SimpleCookie now encodes , and ; in values to cater to how
   browsers actually parse cookies.
 
-- Issue #1379416: eliminated a source of accidental unicode promotion in
+- bpo-1379416: eliminated a source of accidental unicode promotion in
   email.header.Header.encode.
 
-- Issue #5258/#10642: if site.py encounters a .pth file that generates an error,
-  it now prints the filename, line number, and traceback to stderr and skips
+- bpo-5258: if site.py encounters a .pth file that generates an error, it
+  now prints the filename, line number, and traceback to stderr and skips
   the rest of that individual file, instead of stopping processing entirely.
+  (See also: bpo-10642)
 
-- Issue #10750: The ``raw`` attribute of buffered IO objects is now read-only.
+- bpo-10750: The ``raw`` attribute of buffered IO objects is now read-only.
 
-- Issue #10242: unittest.TestCase.assertItemsEqual makes too many assumptions
+- bpo-10242: unittest.TestCase.assertItemsEqual makes too many assumptions
   about input.
 
-- Issue #10611: SystemExit should not cause a unittest test run to exit.
+- bpo-10611: SystemExit should not cause a unittest test run to exit.
 
-- Issue #6791: Limit header line length (to 65535 bytes) in http.client,
-  to avoid denial of services from the other party.
+- bpo-6791: Limit header line length (to 65535 bytes) in http.client, to
+  avoid denial of services from the other party.
 
-- Issue #9907: Fix tab handling on OSX when using editline by calling
-  rl_initialize first, then setting our custom defaults, then reading .editrc.
+- bpo-9907: Fix tab handling on OSX when using editline by calling
+  rl_initialize first, then setting our custom defaults, then reading
+  .editrc.
 
-- Issue #4188: Avoid creating dummy thread objects when logging operations
-  from the threading module (with the internal verbose flag activated).
+- bpo-4188: Avoid creating dummy thread objects when logging operations from
+  the threading module (with the internal verbose flag activated).
 
-- Issue #9721: Fix the behavior of urljoin when the relative url starts with a
+- bpo-9721: Fix the behavior of urljoin when the relative url starts with a
   ';' character. Patch by Wes Chow.
 
-- Issue #10714: Limit length of incoming request in http.server to 65536 bytes
+- bpo-10714: Limit length of incoming request in http.server to 65536 bytes
   for security reasons.  Initial patch by Ross Lagerwall.
 
-- Issue #9558: Fix distutils.command.build_ext with VS 8.0.
+- bpo-9558: Fix distutils.command.build_ext with VS 8.0.
 
-- Issue #10695: passing the port as a string value to telnetlib no longer
+- bpo-10695: passing the port as a string value to telnetlib no longer
   causes debug mode to fail.
 
-- Issue #10478: Reentrant calls inside buffered IO objects (for example by
-  way of a signal handler) now raise a RuntimeError instead of freezing the
+- bpo-10478: Reentrant calls inside buffered IO objects (for example by way
+  of a signal handler) now raise a RuntimeError instead of freezing the
   current process.
 
-- Issue #10497: Fix incorrect use of gettext in argparse.
+- bpo-10497: Fix incorrect use of gettext in argparse.
 
-- Issue #10464: netrc now correctly handles lines with embedded '#' characters.
+- bpo-10464: netrc now correctly handles lines with embedded '#' characters.
 
-- Issue #1731717: Fixed the problem where subprocess.wait() could cause an
-  OSError exception when The OS had been told to ignore SIGCLD in our process
-  or otherwise not wait for exiting child processes.
+- bpo-1731717: Fixed the problem where subprocess.wait() could cause an
+  OSError exception when The OS had been told to ignore SIGCLD in our
+  process or otherwise not wait for exiting child processes.
 
-- Issue #9509: argparse now properly handles IOErrors raised by
+- bpo-9509: argparse now properly handles IOErrors raised by
   argparse.FileType.
 
-- Issue #9348: Raise an early error if argparse nargs and metavar don't match.
+- bpo-9348: Raise an early error if argparse nargs and metavar don't match.
 
-- Issue #8982: Improve the documentation for the argparse Namespace object.
+- bpo-8982: Improve the documentation for the argparse Namespace object.
 
-- Issue #9343: Document that argparse parent parsers must be configured before
+- bpo-9343: Document that argparse parent parsers must be configured before
   their children.
 
-- Issue #9026: Fix order of argparse sub-commands in help messages.
+- bpo-9026: Fix order of argparse sub-commands in help messages.
 
-- Issue #9347: Fix formatting for tuples in argparse type= error messages.
+- bpo-9347: Fix formatting for tuples in argparse type= error messages.
 
-Extension Modules
------------------
-
-- Stop using the old interface for providing methods and attributes in the _sre
-  module. Among other things, this gives these classes ``__class__``
+- Stop using the old interface for providing methods and attributes in the
+  _sre module. Among other things, this gives these classes ``__class__``
   attributes. (See #12099)
 
-- Issue #10169: Fix argument parsing in socket.sendto() to avoid error masking.
+- bpo-10169: Fix argument parsing in socket.sendto() to avoid error masking.
 
-- Issue #12051: Fix segfault in json.dumps() while encoding highly-nested
+- bpo-12051: Fix segfault in json.dumps() while encoding highly-nested
   objects using the C accelerations.
 
-- Issue #12017: Fix segfault in json.loads() while decoding highly-nested
+- bpo-12017: Fix segfault in json.loads() while decoding highly-nested
   objects using the C accelerations.
 
-- Issue #1838: Prevent segfault in ctypes, when _as_parameter_ on a class is set
-  to an instance of the class.
+- bpo-1838: Prevent segfault in ctypes, when _as_parameter_ on a class is
+  set to an instance of the class.
 
-- Issue #678250: Make mmap flush a noop on ACCESS_READ and ACCESS_COPY.
+- bpo-678250: Make mmap flush a noop on ACCESS_READ and ACCESS_COPY.
 
 IDLE
 ----
 
-- Issue #11718: IDLE's open module dialog couldn't find the __init__.py
-  file in a package.
+- bpo-11718: IDLE's open module dialog couldn't find the __init__.py file in
+  a package.
 
-- Issue #12590: IDLE editor window now always displays the first line
-  when opening a long file.  With Tk 8.5, the first line was hidden.
+- bpo-12590: IDLE editor window now always displays the first line when
+  opening a long file.  With Tk 8.5, the first line was hidden.
 
-- Issue #11088: don't crash when using F5 to run a script in IDLE on MacOSX
+- bpo-11088: don't crash when using F5 to run a script in IDLE on MacOSX
   with Tk 8.5.
 
-- Issue #10940: Workaround an IDLE hang on Mac OS X 10.6 when using the
-  menu accelerators for Open Module, Go to Line, and New Indent Width.
-  The accelerators still work but no longer appear in the menu items.
+- bpo-10940: Workaround an IDLE hang on Mac OS X 10.6 when using the menu
+  accelerators for Open Module, Go to Line, and New Indent Width. The
+  accelerators still work but no longer appear in the menu items.
 
-- Issue #10907: Warn OS X 10.6 IDLE users to use ActiveState Tcl/Tk 8.5, rather
+- bpo-10907: Warn OS X 10.6 IDLE users to use ActiveState Tcl/Tk 8.5, rather
   than the currently problematic Apple-supplied one, when running with the
   64-/32-bit installer variant.
 
-- Issue #11052: Correct IDLE menu accelerators on Mac OS X for Save
-  commands.
+- bpo-11052: Correct IDLE menu accelerators on Mac OS X for Save commands.
 
-- Issue #6075: IDLE on Mac OS X now works with both Carbon AquaTk and
-  Cocoa AquaTk.
+- bpo-6075: IDLE on Mac OS X now works with both Carbon AquaTk and Cocoa
+  AquaTk.
 
-- Issue #10404: Use ctl-button-1 on OSX for the context menu in Idle.
+- bpo-10404: Use ctl-button-1 on OSX for the context menu in Idle.
 
-- Issue #10107: Warn about unsaved files in IDLE on OSX.
+- bpo-10107: Warn about unsaved files in IDLE on OSX.
 
-- Issue #10406: Enable Rstrip IDLE extension on OSX (just like on other
+- bpo-10406: Enable Rstrip IDLE extension on OSX (just like on other
   platforms).
 
-- Issue #6378: Further adjust idle.bat to start associated Python
+- bpo-6378: Further adjust idle.bat to start associated Python
 
-- Issue #11896: Save on Close failed despite selecting "Yes" in dialog.
+- bpo-11896: Save on Close failed despite selecting "Yes" in dialog.
 
-- Issue #4676: <Home> toggle failing on Tk 8.5, causing IDLE exits and
-  strange selection behavior.  Improve selection extension behaviour.
+- bpo-4676: <Home> toggle failing on Tk 8.5, causing IDLE exits and strange
+  selection behavior.  Improve selection extension behaviour.
 
-- Issue #3851: <Home> toggle non-functional when NumLock set on Windows.
+- bpo-3851: <Home> toggle non-functional when NumLock set on Windows.
 
 Build
 -----
 
-- Issue #11217: For 64-bit/32-bit Mac OS X universal framework builds,
-  ensure "make install" creates symlinks in --prefix bin for the "-32"
-  files in the framework bin directory like the installer does.
+- bpo-11217: For 64-bit/32-bit Mac OS X universal framework builds, ensure
+  "make install" creates symlinks in --prefix bin for the "-32" files in the
+  framework bin directory like the installer does.
 
-- Issue #11411: Fix 'make DESTDIR=' with a relative destination.
+- bpo-11411: Fix 'make DESTDIR=' with a relative destination.
 
-- Issue #10709: Add updated AIX notes in Misc/README.AIX.
+- bpo-10709: Add updated AIX notes in Misc/README.AIX.
 
-- Issue #11184: Fix large-file support on AIX.
+- bpo-11184: Fix large-file support on AIX.
 
-- Issue #941346: Fix broken shared library build on AIX.
+- bpo-941346: Fix broken shared library build on AIX.
 
-- Issue #11268: Prevent Mac OS X Installer failure if Documentation
-  package had previously been installed.
+- bpo-11268: Prevent Mac OS X Installer failure if Documentation package had
+  previously been installed.
 
-- Issue #11079: The /Applications/Python x.x folder created by the Mac
-  OS X installers now includes a link to the installed documentation.
+- bpo-11079: The /Applications/Python x.x folder created by the Mac OS X
+  installers now includes a link to the installed documentation.
 
-- Issue #11054: Allow Mac OS X installer builds to again work on 10.5 with
-  the system-provided Python.
+- bpo-11054: Allow Mac OS X installer builds to again work on 10.5 with the
+  system- provided Python.
 
-- Issue #10843: Update third-party library versions used in OS X
-  32-bit installer builds: bzip2 1.0.6, readline 6.1.2, SQLite 3.7.4
-  (with FTS3/FTS4 and RTREE enabled), and ncursesw 5.5 (wide-char
-  support enabled).
+- bpo-10843: Update third-party library versions used in OS X 32-bit
+  installer builds: bzip2 1.0.6, readline 6.1.2, SQLite 3.7.4 (with
+  FTS3/FTS4 and RTREE enabled), and ncursesw 5.5 (wide-char support
+  enabled).
 
 - Don't run pgen twice when using make -j.
 
-- Issue #7716: Under Solaris, don't assume existence of /usr/xpg4/bin/grep in
+- bpo-7716: Under Solaris, don't assume existence of /usr/xpg4/bin/grep in
   the configure script but use $GREP instead.  Patch by Fabian Groffen.
 
-- Issue #10475: Don't hardcode compilers for LDSHARED/LDCXXSHARED on NetBSD
-  and DragonFly BSD.  Patch by Nicolas Joly.
+- bpo-10475: Don't hardcode compilers for LDSHARED/LDCXXSHARED on NetBSD and
+  DragonFly BSD.  Patch by Nicolas Joly.
 
-- Issue #10655: Fix the build on PowerPC on Linux with GCC when building with
+- bpo-10655: Fix the build on PowerPC on Linux with GCC when building with
   timestamp profiling (--with-tsc): the preprocessor test for the PowerPC
-  support now looks for "__powerpc__" as well as "__ppc__": the latter seems to
-  only be present on OS X; the former is the correct one for Linux with GCC.
+  support now looks for "__powerpc__" as well as "__ppc__": the latter seems
+  to only be present on OS X; the former is the correct one for Linux with
+  GCC.
 
-- Issue #1099: Fix the build on MacOSX when building a framework with pydebug
+- bpo-1099: Fix the build on MacOSX when building a framework with pydebug
   using GCC 4.0.
 
 Tests
 -----
 
-- Issue #11164: Remove obsolete allnodes test from minidom test.
+- bpo-11164: Remove obsolete allnodes test from minidom test.
 
-- Issue #12205: Fix test_subprocess failure due to uninstalled test data.
+- bpo-12205: Fix test_subprocess failure due to uninstalled test data.
 
-- Issue #5723: Improve json tests to be executed with and without accelerations.
+- bpo-5723: Improve json tests to be executed with and without
+  accelerations.
 
-- Issue #11910: Fix test_heapq to skip the C tests when _heapq is missing.
+- bpo-11910: Fix test_heapq to skip the C tests when _heapq is missing.
 
-- Fix test_startfile to wait for child process to terminate before finishing.
+- Fix test_startfile to wait for child process to terminate before
+  finishing.
 
-- Issue #11719: Fix message about unexpected test_msilib skip on non-Windows
+- bpo-11719: Fix message about unexpected test_msilib skip on non-Windows
   platforms. Patch by Nadeem Vawda.
 
-- Issue #7108: Fix test_commands to not fail when special attributes ('@'
-  or '.') appear in 'ls -l' output.
+- bpo-7108: Fix test_commands to not fail when special attributes ('@' or
+  '.') appear in 'ls -l' output.
 
-- Issue #11490: test_subprocess:test_leaking_fds_on_error no longer gives a
+- bpo-11490: test_subprocess:test_leaking_fds_on_error no longer gives a
   false positive if the last directory in the path is inaccessible.
 
-- Issue #10822: Fix test_posix:test_getgroups failure under Solaris.  Patch
-  by Ross Lagerwall.
+- bpo-10822: Fix test_posix:test_getgroups failure under Solaris.  Patch by
+  Ross Lagerwall.
 
-- Issue #6293: Have regrtest.py echo back sys.flags.  This is done by default
+- bpo-6293: Have regrtest.py echo back sys.flags.  This is done by default
   in whole runs and enabled selectively using ``--header`` when running an
   explicit list of tests.  Original patch by Collin Winter.
 
-- Issue #775964: test_grp now skips YP/NIS entries instead of failing when
+- bpo-775964: test_grp now skips YP/NIS entries instead of failing when
   encountering them.
 
-- Issue #7110: regrtest now sends test failure reports and single-failure
+- bpo-7110: regrtest now sends test failure reports and single-failure
   tracebacks to stderr rather than stdout.
 
 
-What's New in Python 2.7.1?
-===========================
+What's New in Python 2.7.1 final?
+=================================
 
 *Release date: 2010-11-27*
 
 Library
 -------
 
-- Issue #2236: distutils' mkpath ignored the mode parameter.
+- bpo-2236: distutils' mkpath ignored the mode parameter.
 
 - Fix typo in one sdist option (medata-check).
 
-- Issue #10323: itertools.islice() now consumes the minimum number of
-  inputs before stopping.  Formerly, the final state of the underlying
-  iterator was undefined.
+- bpo-10323: itertools.islice() now consumes the minimum number of inputs
+  before stopping.  Formerly, the final state of the underlying iterator was
+  undefined.
 
-- Issue #10565: The collections.Iterator ABC now checks for both
-  ``__iter__`` and ``next``.
+- bpo-10565: The collections.Iterator ABC now checks for both ``__iter__``
+  and ``next``.
 
-- Issue #10092: Properly reset locale in calendar.Locale*Calendar classes.
+- bpo-10092: Properly reset locale in calendar.Locale*Calendar classes.
 
-- Issue #10459: Update CJK character names to Unicode 5.2.
+- bpo-10459: Update CJK character names to Unicode 5.2.
 
-- Issue #6098: Don't claim DOM level 3 conformance in minidom.
+- bpo-6098: Don't claim DOM level 3 conformance in minidom.
 
-- Issue #10561: In pdb, clear the breakpoints by the breakpoint number.
+- bpo-10561: In pdb, clear the breakpoints by the breakpoint number.
 
-- Issue #5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty
+- bpo-5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty
   XML namespace attribute is encountered.
 
-- Issue #1710703: Write structures for an empty ZIP archive when a ZipFile is
-  created in modes 'a' or 'w' and then closed without adding any files. Raise
-  BadZipfile (rather than IOError) when opening small non-ZIP files.
+- bpo-1710703: Write structures for an empty ZIP archive when a ZipFile is
+  created in modes 'a' or 'w' and then closed without adding any files.
+  Raise BadZipfile (rather than IOError) when opening small non-ZIP files.
 
-- Issue #4493: urllib2 adds '/' in front of path components which does not
+- bpo-4493: urllib2 adds '/' in front of path components which does not
   start with '/. Common behavior exhibited by browsers and other clients.
 
-- Issue #10407: Fix one NameError in distutils.
+- bpo-10407: Fix one NameError in distutils.
 
-- Issue #10198: fix duplicate header written to wave files when writeframes()
+- bpo-10198: fix duplicate header written to wave files when writeframes()
   is called without data.
 
-- Issue #10467: Fix BytesIO.readinto() after seeking into a position after the
+- bpo-10467: Fix BytesIO.readinto() after seeking into a position after the
   end of the file.
 
-- Issue #5111: IPv6 Host in the Header is wrapped inside [ ]. Patch by Chandru.
+- bpo-5111: IPv6 Host in the Header is wrapped inside [ ]. Patch by Chandru.
 
 IDLE
 ----
 
-- Issue #6378: idle.bat now runs with the appropriate Python version rather than
-  the system default. Patch by Sridhar Ratnakumar.
+- bpo-6378: idle.bat now runs with the appropriate Python version rather
+  than the system default. Patch by Sridhar Ratnakumar.
 
 Build
 -----
 
 - Backport r83399 to allow test_distutils to pass on installed versions.
 
-- Issue #1303434: Generate ZIP file containing all PDBs.
+- bpo-1303434: Generate ZIP file containing all PDBs.
 
 Tests
 -----
 
-- Issue #9424: Replace deprecated assert* methods in the Python test suite.
+- bpo-9424: Replace deprecated assert* methods in the Python test suite.
 
 Documentation
 -------------
 
-- Issue #10299: List the built-in functions in a table in functions.rst.
+- bpo-10299: List the built-in functions in a table in functions.rst.
 
 
 What's New in Python 2.7.1 release candidate 1?
@@ -5744,552 +6177,546 @@ What's New in Python 2.7.1 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #10221: dict.pop(k) now has a key error message that includes the
+- bpo-10221: dict.pop(k) now has a key error message that includes the
   missing key (same message d[k] returns for missing keys).
 
-- Issue #10125: Don't segfault when the iterator passed to
+- bpo-10125: Don't segfault when the iterator passed to
   ``file.writelines()`` closes the file.
 
-- Issue #10186: Fix the SyntaxError caret when the offset is equal to the
+- bpo-10186: Fix the SyntaxError caret when the offset is equal to the
   length of the offending line.
 
-- Issue #9997: Don't let the name "top" have special significance in scope
+- bpo-9997: Don't let the name "top" have special significance in scope
   resolution.
 
-- Issue #9862: Compensate for broken PIPE_BUF in AIX by hard coding
-  its value as the default 512 when compiling on AIX.
+- bpo-9862: Compensate for broken PIPE_BUF in AIX by hard coding its value
+  as the default 512 when compiling on AIX.
 
-- Issue #9675: CObject use is marked as a Py3k warning, not a deprecation
+- bpo-9675: CObject use is marked as a Py3k warning, not a deprecation
   warning.
 
-- Issue #10068: Global objects which have reference cycles with their module's
+- bpo-10068: Global objects which have reference cycles with their module's
   dict are now cleared again. This causes issue #7140 to appear again.
 
-- Issue #9869: Make long() and PyNumber_Long return something of type
-  long for a class whose __long__ method returns a plain int.  This
-  fixes an interpreter crash when initializing an instance of a long
-  subclass from an object whose __long__ method returns a plain int.
+- bpo-9869: Make long() and PyNumber_Long return something of type long for
+  a class whose __long__ method returns a plain int.  This fixes an
+  interpreter crash when initializing an instance of a long subclass from an
+  object whose __long__ method returns a plain int.
 
-- Issue #10006: type.__abstractmethods__ now raises an AttributeError.
+- bpo-10006: type.__abstractmethods__ now raises an AttributeError.
 
-- Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
-  thread-local storage key.
+- bpo-9797: pystate.c wrongly assumed that zero couldn't be a valid thread-
+  local storage key.
 
-- Issue #4947: The write() method of sys.stdout and sys.stderr uses their
-  encoding and errors attributes instead of using utf-8 in strict mode, to get
-  the same behaviour than the print statement.
+- bpo-4947: The write() method of sys.stdout and sys.stderr uses their
+  encoding and errors attributes instead of using utf-8 in strict mode, to
+  get the same behaviour than the print statement.
 
-- Issue #9737: Fix a crash when trying to delete a slice or an item from
-  memoryview object.
+- bpo-9737: Fix a crash when trying to delete a slice or an item from a
+  memoryview object.
 
 - Restore GIL in nis_cat in case of error.
 
-- Issue #9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.
+- bpo-9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.
 
-- Issue #8530: Prevent stringlib fastsearch from reading beyond the front
-  of an array.
+- bpo-8530: Prevent stringlib fastsearch from reading beyond the front of an
+  array.
 
-- Issue #83755: Implicit set-to-frozenset conversion was not thread-safe.
+- bpo-83755: Implicit set-to-frozenset conversion was not thread-safe.
 
-- Issue #9416: Fix some issues with complex formatting where the
-  output with no type specifier failed to match the str output:
+- bpo-9416: Fix some issues with complex formatting where the output with no
+  type specifier failed to match the str output:
 
-    - format(complex(-0.0, 2.0), '-') omitted the real part from the output,
-    - format(complex(0.0, 2.0), '-') included a sign and parentheses.
+  - format(complex(-0.0, 2.0), '-') omitted the real part from the output,
+  - format(complex(0.0, 2.0), '-') included a sign and parentheses.
 
-- Issue #7616: Fix copying of overlapping memoryview slices with the Intel
+- bpo-7616: Fix copying of overlapping memoryview slices with the Intel
   compiler.
 
 Library
 -------
 
-- Issue #9926: Wrapped TestSuite subclass does not get __call__ executed
+- bpo-9926: Wrapped TestSuite subclass does not get __call__ executed
 
-- Issue #4471: Properly shutdown socket in IMAP.shutdown().  Patch by
-  Lorenzo M. Catucci.
+- bpo-4471: Properly shutdown socket in IMAP.shutdown().  Patch by Lorenzo
+  M. Catucci.
 
-- Issue #10126: Fix distutils' test_build when Python was built with
-  --enable-shared.
+- bpo-10126: Fix distutils' test_build when Python was built with --enable-
+  shared.
 
 - Fix typo in one sdist option (medata-check).
 
-- Issue #9199: Fix incorrect use of distutils.cmd.Command.announce.
+- bpo-9199: Fix incorrect use of distutils.cmd.Command.announce.
 
-- Issue #1718574: Fix options that were supposed to accept arguments but did
+- bpo-1718574: Fix options that were supposed to accept arguments but did
   not in build_clib.
 
-- Issue #9281: Prevent race condition with mkdir in distutils.  Patch by
+- bpo-9281: Prevent race condition with mkdir in distutils.  Patch by
   Arfrever.
 
-- Issue #10229: Fix caching error in gettext.
+- bpo-10229: Fix caching error in gettext.
 
-- Issue #10252: Close file objects in a timely manner in distutils code and
+- bpo-10252: Close file objects in a timely manner in distutils code and
   tests.  Patch by Brian Brazil, completed by Éric Araujo.
 
-- Issue #10311: The signal module now restores errno before returning from
-  its low-level signal handler.  Patch by Hallvard B Furuseth.
+- bpo-10311: The signal module now restores errno before returning from its
+  low-level signal handler.  Patch by Hallvard B Furuseth.
 
-- Issue #10038: json.loads() on str should always return unicode (regression
+- bpo-10038: json.loads() on str should always return unicode (regression
   from Python 2.6).  Patch by Walter Dörwald.
 
-- Issue #120176: Wrapped TestSuite subclass does not get __call__ executed.
+- bpo-120176: Wrapped TestSuite subclass does not get __call__ executed.
 
-- Issue #6706: asyncore accept() method no longer raises
+- bpo-6706: asyncore accept() method no longer raises
   EWOULDBLOCK/ECONNABORTED on incomplete connection attempt but returns None
   instead.
 
-- Issue #10266: uu.decode didn't close in_file explicitly when it was given
-  as a filename.  Patch by Brian Brazil.
+- bpo-10266: uu.decode didn't close in_file explicitly when it was given as
+  a filename. Patch by Brian Brazil.
 
-- Issue #10246: uu.encode didn't close file objects explicitly when filenames
+- bpo-10246: uu.encode didn't close file objects explicitly when filenames
   were given to it.  Patch by Brian Brazil.
 
-- Issue #10253: FileIO leaks a file descriptor when trying to open a file
-  for append that isn't seekable.  Patch by Brian Brazil.
+- bpo-10253: FileIO leaks a file descriptor when trying to open a file for
+  append that isn't seekable.  Patch by Brian Brazil.
 
-- Issue #6105: json.dumps now respects OrderedDict's iteration order.
+- bpo-6105: json.dumps now respects OrderedDict's iteration order.
 
-- Issue #9295: Fix a crash under Windows when calling close() on a file
-  object with custom buffering from two threads at once.
+- bpo-9295: Fix a crash under Windows when calling close() on a file object
+  with custom buffering from two threads at once.
 
-- Issue #5027: The standard ``xml`` namespace is now understood by
+- bpo-5027: The standard ``xml`` namespace is now understood by
   xml.sax.saxutils.XMLGenerator as being bound to
   http://www.w3.org/XML/1998/namespace.  Patch by Troy J. Farrell.
 
-- Issue #10163: Skip unreadable registry keys during mimetypes
-  initialization.
+- bpo-10163: Skip unreadable registry keys during mimetypes initialization.
 
-- Issue #5117: Fixed root directory related issue on posixpath.relpath() and
+- bpo-5117: Fixed root directory related issue on posixpath.relpath() and
   ntpath.relpath().
 
-- Issue #9409: Fix the regex to match all kind of filenames, for interactive
+- bpo-9409: Fix the regex to match all kind of filenames, for interactive
   debugging in doctests.
 
-- Issue #6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the
+- bpo-6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the
   current directory was deleted. Patch written by W. Trevor King.
 
-- Issue #10045: Improved performance when writing after seeking past the
-  end of the "file" in cStringIO.
+- bpo-10045: Improved performance when writing after seeking past the end of
+  the "file" in cStringIO.
 
-- Issue #9948: Fixed problem of losing filename case information.
+- bpo-9948: Fixed problem of losing filename case information.
 
-- Issue #9437: Fix building C extensions with non-default LDFLAGS.
+- bpo-9437: Fix building C extensions with non-default LDFLAGS.
 
-- Issue #9759: GzipFile now raises ValueError when an operation is attempted
+- bpo-9759: GzipFile now raises ValueError when an operation is attempted
   after the file is closed.  Patch by Jeffrey Finkelstein.
 
-- Issue #9042: Fix interaction of custom translation classes and caching in
+- bpo-9042: Fix interaction of custom translation classes and caching in
   gettext.
 
-- Issue #9065: tarfile no longer uses "root" as the default for the uname and
+- bpo-9065: tarfile no longer uses "root" as the default for the uname and
   gname field.
 
-- Issue #1050268: parseaddr now correctly quotes double quote and backslash
+- bpo-1050268: parseaddr now correctly quotes double quote and backslash
   characters that appear inside quoted strings in email addresses.
 
-- Issue #10004: quoprimime no longer generates a traceback when confronted
-  with invalid characters after '=' in a Q-encoded word.
+- bpo-10004: quoprimime no longer generates a traceback when confronted with
+  invalid characters after '=' in a Q-encoded word.
 
-- Issue #9950: Fix socket.sendall() crash or misbehaviour when a signal is
-  received.  Now sendall() properly calls signal handlers if necessary,
-  and retries sending if these returned successfully, including on sockets
-  with a timeout.
+- bpo-9950: Fix socket.sendall() crash or misbehaviour when a signal is
+  received.  Now sendall() properly calls signal handlers if necessary, and
+  retries sending if these returned successfully, including on sockets with
+  a timeout.
 
-- Issue #9947: logging: Fixed locking bug in stopListening.
+- bpo-9947: logging: Fixed locking bug in stopListening.
 
-- Issue #9945: logging: Fixed locking bugs in addHandler/removeHandler.
+- bpo-9945: logging: Fixed locking bugs in addHandler/removeHandler.
 
-- Issue #9936: Fixed executable lines' search in the trace module.
+- bpo-9936: Fixed executable lines' search in the trace module.
 
-- Issue #9928: Properly initialize the types exported by the bz2 module.
+- bpo-9928: Properly initialize the types exported by the bz2 module.
 
-- Issue #9854: The default read() implementation in io.RawIOBase now
-  handles non-blocking readinto() returning None correctly.
+- bpo-9854: The default read() implementation in io.RawIOBase now handles
+  non-blocking readinto() returning None correctly.
 
-- Issue #9729: Fix the signature of SSLSocket.recvfrom() and
-  SSLSocket.sendto() to match the corresponding socket methods.  Also,
-  fix various SSLSocket methods to raise socket.error rather than an
-  unhelpful TypeError when called on an unconnected socket.  Original patch
-  by Andrew Bennetts.
+- bpo-9729: Fix the signature of SSLSocket.recvfrom() and SSLSocket.sendto()
+  to match the corresponding socket methods.  Also, fix various SSLSocket
+  methods to raise socket.error rather than an unhelpful TypeError when
+  called on an unconnected socket.  Original patch by Andrew Bennetts.
 
-- Issue #9826: OrderedDict.__repr__ can now handle self-referential
-  values:   d['x'] = d.
+- bpo-9826: OrderedDict.__repr__ can now handle self-referential values:
+  d['x'] = d.
 
-- Issue #767645: Set os.path.supports_unicode_filenames to True on Mac OS X.
+- bpo-767645: Set os.path.supports_unicode_filenames to True on Mac OS X.
 
-- Issue #9837: The read() method of ZipExtFile objects (as returned by
+- bpo-9837: The read() method of ZipExtFile objects (as returned by
   ZipFile.open()) could return more bytes than requested.
 
-- Issue #9825: removed __del__ from the definition of collections.OrderedDict.
+- bpo-9825: removed __del__ from the definition of collections.OrderedDict.
   This prevents user-created self-referencing ordered dictionaries from
   becoming permanently uncollectable GC garbage.  The downside is that
-  removing __del__ means that the internal doubly-linked list has to wait for
-  GC collection rather than freeing memory immediately when the refcnt drops
-  to zero.
+  removing __del__ means that the internal doubly-linked list has to wait
+  for GC collection rather than freeing memory immediately when the refcnt
+  drops to zero.
 
-- Issue #9816: random.Random.jumpahead(n) did not produce a sufficiently
+- bpo-9816: random.Random.jumpahead(n) did not produce a sufficiently
   different internal state for small values of n.  Fixed by salting the
   value.
 
-- Issue #9792: In case of connection failure, socket.create_connection()
-  would swallow the exception and raise a new one, making it impossible
-  to fetch the original errno, or to filter timeout errors.  Now the
-  original error is re-raised.
+- bpo-9792: In case of connection failure, socket.create_connection() would
+  swallow the exception and raise a new one, making it impossible to fetch
+  the original errno, or to filter timeout errors.  Now the original error
+  is re-raised.
 
-- Issue #9758: When fcntl.ioctl() was called with mutable_flag set to True,
-  and the passed buffer was exactly 1024 bytes long, the buffer wouldn't
-  be updated back after the system call.  Original patch by Brian Brazil.
+- bpo-9758: When fcntl.ioctl() was called with mutable_flag set to True, and
+  the passed buffer was exactly 1024 bytes long, the buffer wouldn't be
+  updated back after the system call.  Original patch by Brian Brazil.
 
-- Issue #1100562: Fix deep-copying of objects derived from the list and
-  dict types.  Patch by Michele Orrù and Björn Lindqvist.
+- bpo-1100562: Fix deep-copying of objects derived from the list and dict
+  types.  Patch by Michele Orrù and Björn Lindqvist.
 
-- Issue #7005: Fixed output of None values for RawConfigParser.write and
+- bpo-7005: Fixed output of None values for RawConfigParser.write and
   ConfigParser.write.
 
-- Issue #808164: Fixed socket.close to avoid references to globals, to
-  avoid issues when socket.close is called from a __del__ method.
+- bpo-808164: Fixed socket.close to avoid references to globals, to avoid
+  issues when socket.close is called from a __del__ method.
 
-- Issue #2986: difflib.SequenceMatcher gets a new parameter, autojunk, which
+- bpo-2986: difflib.SequenceMatcher gets a new parameter, autojunk, which
   can be set to False to turn off the previously undocumented 'popularity'
   heuristic. Patch by Terry Reedy and Eli Bendersky
 
-- Issue #8797: urllib2 does a retry for Basic Authentication failure instead of
+- bpo-8797: urllib2 does a retry for Basic Authentication failure instead of
   falling into recursion.
 
-- Issue #1194222: email.utils.parsedate now returns RFC2822 compliant four
+- bpo-1194222: email.utils.parsedate now returns RFC2822 compliant four
   character years even if the message contains RFC822 two character years.
 
-- Issue #8750: Fixed MutableSet's methods to correctly handle
-  reflexive operations, namely x -= x and x ^= x.
+- bpo-8750: Fixed MutableSet's methods to correctly handle reflexive
+  operations, namely x -= x and x ^= x.
 
-- Issue #9129: smtpd.py is vulnerable to DoS attacks deriving from missing
+- bpo-9129: smtpd.py is vulnerable to DoS attacks deriving from missing
   error handling when accepting a new connection.
 
-- Issue #658749: asyncore's connect() method now correctly interprets winsock
+- bpo-658749: asyncore's connect() method now correctly interprets winsock
   errors.
 
-- Issue #9501: Fixed logging regressions in cleanup code.
+- bpo-9501: Fixed logging regressions in cleanup code.
 
-- Issue #9214: Set operations on KeysView or ItemsView in the collections
+- bpo-9214: Set operations on KeysView or ItemsView in the collections
   module now correctly return a set.  (Patch by Eli Bendersky.)
 
-- Issue #9617: Signals received during a low-level write operation aren't
+- bpo-9617: Signals received during a low-level write operation aren't
   ignored by the buffered IO layer anymore.
 
-- Issue #2521: Use weakrefs on for caching in the abc module, so that classes
+- bpo-2521: Use weakrefs on for caching in the abc module, so that classes
   are not held onto after they are deleted elsewhere.
 
-- Issue #9626: the view methods for collections.OrderedDict() were returning
+- bpo-9626: the view methods for collections.OrderedDict() were returning
   the unordered versions inherited from dict.  Those methods are now
   overridden to provide ordered views.
 
-- Issue #8688: MANIFEST files created by distutils now include a magic
-  comment indicating they are generated.  Manually maintained MANIFESTs
-  without this marker will not be overwritten or removed.
+- bpo-8688: MANIFEST files created by distutils now include a magic comment
+  indicating they are generated.  Manually maintained MANIFESTs without this
+  marker will not be overwritten or removed.
 
-- Issue #7467: when reading a file from a ZIP archive, its CRC is checked
-  and a BadZipfile error is raised if it doesn't match (as used to be the
-  case in Python 2.5 and earlier).
+- bpo-7467: when reading a file from a ZIP archive, its CRC is checked and a
+  BadZipfile error is raised if it doesn't match (as used to be the case in
+  Python 2.5 and earlier).
 
-- Issue #9550: a BufferedReader could issue an additional read when the
+- bpo-9550: a BufferedReader could issue an additional read when the
   original read request had been satisfied, which could block indefinitely
   when the underlying raw IO channel was e.g. a socket.  Report and original
   patch by Jason V. Miller.
 
-- Issue #9551: Don't raise TypeError when setting the value to None for
+- bpo-9551: Don't raise TypeError when setting the value to None for
   SafeConfigParser instances constructed with allow_no_value == True.
 
-- Issue #6915: Under Windows, os.listdir() didn't release the Global
+- bpo-6915: Under Windows, os.listdir() didn't release the Global
   Interpreter Lock around all system calls.  Original patch by Ryan Kelly.
 
-- Issue #3757: thread-local objects now support cyclic garbage collection.
+- bpo-3757: thread-local objects now support cyclic garbage collection.
   Thread-local objects involved in reference cycles will be deallocated
   timely by the cyclic GC, even if the underlying thread is still running.
 
-- Issue #6231: Fix xml.etree.ElementInclude to include the tail of the
-  current node.
+- bpo-6231: Fix xml.etree.ElementInclude to include the tail of the current
+  node.
 
-- Issue #6869: Fix a refcount problem in the _ctypes extension.
+- bpo-6869: Fix a refcount problem in the _ctypes extension.
 
-- Issue #5504: ctypes should now work with systems where mmap can't be
+- bpo-5504: ctypes should now work with systems where mmap can't be
   PROT_WRITE and PROT_EXEC.
 
-- Issue #8280: urllib2's Request method will remove fragements in the url.
-  This is how it is supposed to work, wget and curl do the same.  Previous
+- bpo-8280: urllib2's Request method will remove fragements in the url. This
+  is how it is supposed to work, wget and curl do the same.  Previous
   behavior was wrong.
 
-- Issue #2944: asyncore doesn't handle connection refused correctly.
+- bpo-2944: asyncore doesn't handle connection refused correctly.
 
-- Issue #3196: email header decoding is now forgiving if an RFC2047
-  encoded word encoded in base64 is lacking padding.
+- bpo-3196: email header decoding is now forgiving if an RFC2047 encoded
+  word encoded in base64 is lacking padding.
 
-- Issue #9444: Argparse now uses the first element of prefix_chars as
-  the option character for the added 'h/help' option if prefix_chars
-  does not contain a '-', instead of raising an error.
+- bpo-9444: Argparse now uses the first element of prefix_chars as the
+  option character for the added 'h/help' option if prefix_chars does not
+  contain a '-', instead of raising an error.
 
-- Issue #9354: Provide getsockopt() in asyncore's file_wrapper.
+- bpo-9354: Provide getsockopt() in asyncore's file_wrapper.
 
-- Issue #9428: Fix running scripts with the profile/cProfile modules from
-  the command line.
+- bpo-9428: Fix running scripts with the profile/cProfile modules from the
+  command line.
 
-- Issue #7781: Fix restricting stats by entry counts in the pstats
-  interactive browser.
+- bpo-7781: Fix restricting stats by entry counts in the pstats interactive
+  browser.
 
-- Issue #9209: Do not crash in the pstats interactive browser on invalid
+- bpo-9209: Do not crash in the pstats interactive browser on invalid
   regular expressions.
 
-- Issue #7372: Fix pstats regression when stripping paths from profile
-  data generated with the profile module.
+- bpo-7372: Fix pstats regression when stripping paths from profile data
+  generated with the profile module.
 
-- Issue #4108: In urllib.robotparser, if there are multiple 'User-agent: *'
+- bpo-4108: In urllib.robotparser, if there are multiple 'User-agent: *'
   entries, consider the first one.
 
-- Issue #8397: Raise an error when attempting to mix iteration and regular
+- bpo-8397: Raise an error when attempting to mix iteration and regular
   reads on a BZ2File object, rather than returning incorrect results.
 
-- Issue #5294: Fix the behavior of pdb's "continue" command when called
-  in the top-level debugged frame.
+- bpo-5294: Fix the behavior of pdb's "continue" command when called in the
+  top-level debugged frame.
 
-- Issue #5727: Restore the ability to use readline when calling into pdb
-  in doctests.
+- bpo-5727: Restore the ability to use readline when calling into pdb in
+  doctests.
 
-- Issue #6719: In pdb, do not stop somewhere in the encodings machinery
-  if the source file to be debugged is in a non-builtin encoding.
+- bpo-6719: In pdb, do not stop somewhere in the encodings machinery if the
+  source file to be debugged is in a non-builtin encoding.
 
-- Issue #8048: Prevent doctests from failing when sys.displayhook has
-  been reassigned.
+- bpo-8048: Prevent doctests from failing when sys.displayhook has been
+  reassigned.
 
-- Issue #8015: In pdb, do not crash when an empty line is entered as
-  breakpoint command.
+- bpo-8015: In pdb, do not crash when an empty line is entered as a
+  breakpoint command.
 
-- Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when
-  re-initializing a buffered IO object by calling its ``__init__`` method.
+- bpo-9448: Fix a leak of OS resources (mutexes or semaphores) when re-
+  initializing a buffered IO object by calling its ``__init__`` method.
 
-- Issue #7909: Do not touch paths with the special prefixes ``\\.\``
-  or ``\\?\`` in ntpath.normpath().
+- bpo-7909: Do not touch paths with the special prefixes ``\\.\`` or
+  ``\\?\`` in ntpath.normpath().
 
-- Issue #5146: Handle UID THREAD command correctly in imaplib.
+- bpo-5146: Handle UID THREAD command correctly in imaplib.
 
-- Issue #5147: Fix the header generated for cookie files written by
+- bpo-5147: Fix the header generated for cookie files written by
   http.cookiejar.MozillaCookieJar.
 
-- Issue #8198: In pydoc, output all help text to the correct stream
-  when sys.stdout is reassigned.
+- bpo-8198: In pydoc, output all help text to the correct stream when
+  sys.stdout is reassigned.
 
-- Issue #7395: Fix tracebacks in pstats interactive browser.
+- bpo-7395: Fix tracebacks in pstats interactive browser.
 
-- Issue #8230: Fix Lib/test/sortperf.py.
+- bpo-8230: Fix Lib/test/sortperf.py.
 
-- Issue #1713: Fix os.path.ismount(), which returned true for symbolic links
+- bpo-1713: Fix os.path.ismount(), which returned true for symbolic links
   across devices.
 
-- Issue #8826: Properly load old-style "expires" attribute in http.cookies.
+- bpo-8826: Properly load old-style "expires" attribute in http.cookies.
 
-- Issue #1690103: Fix initial namespace for code run with trace.main().
+- bpo-1690103: Fix initial namespace for code run with trace.main().
 
-- Issue #8471: In doctest, properly reset the output stream to an empty
-  string when Unicode was previously output.
+- bpo-8471: In doctest, properly reset the output stream to an empty string
+  when Unicode was previously output.
 
-- Issue #8620: when a Cmd is fed input that reaches EOF without a final
-  newline, it no longer truncates the last character of the last command line.
+- bpo-8620: when a Cmd is fed input that reaches EOF without a final
+  newline, it no longer truncates the last character of the last command
+  line.
 
-- Issue #6213: Implement getstate() and setstate() methods of utf-8-sig and
+- bpo-6213: Implement getstate() and setstate() methods of utf-8-sig and
   utf-16 incremental encoders.
 
-- Issue #7113: Speed up loading in ConfigParser. Patch by Łukasz Langa.
+- bpo-7113: Speed up loading in ConfigParser. Patch by Łukasz Langa.
 
-- Issue #3704: cookielib was not properly handling URLs with a / in the
+- bpo-3704: cookielib was not properly handling URLs with a / in the
   parameters.
 
-- Issue #9032: XML-RPC client retries the request on EPIPE error. The EPIPE
+- bpo-9032: XML-RPC client retries the request on EPIPE error. The EPIPE
   error occurs when the server closes the socket and the client sends a big
   XML-RPC request.
 
-- Issue #5542: Remove special logic that closes HTTPConnection socket on EPIPE.
-
-- Issue #4629: getopt raises an error if an argument ends with = whereas getopt
-  doesn't except a value (eg. --help= is rejected if getopt uses ['help='] long
-  options).
+- bpo-5542: Remove special logic that closes HTTPConnection socket on EPIPE.
 
-- Issue #7895: platform.mac_ver() no longer crashes after calling os.fork()
+- bpo-4629: getopt raises an error if an argument ends with = whereas getopt
+  doesn't except a value (eg. --help= is rejected if getopt uses ['help=']
+  long options).
 
-- Issue #5395: array.fromfile() would raise a spurious EOFError when an
-  I/O error occurred.  Now an IOError is raised instead.  Patch by chuck
-  (Jan Hosang).
+- bpo-7895: platform.mac_ver() no longer crashes after calling os.fork()
 
-- Issue #7646: The fnmatch pattern cache no longer grows without bound.
+- bpo-5395: array.fromfile() would raise a spurious EOFError when an I/O
+  error occurred. Now an IOError is raised instead.  Patch by chuck (Jan
+  Hosang).
 
-- Issue #9136: Fix 'dictionary changed size during iteration'
-  RuntimeError produced when profiling the decimal module.  This was
-  due to a dangerous iteration over 'locals()' in Context.__init__.
+- bpo-7646: The fnmatch pattern cache no longer grows without bound.
 
-- Fix extreme speed issue in Decimal.pow when the base is an exact
-  power of 10 and the exponent is tiny (for example,
-  Decimal(10) ** Decimal('1e-999999999')).
+- bpo-9136: Fix 'dictionary changed size during iteration' RuntimeError
+  produced when profiling the decimal module.  This was due to a dangerous
+  iteration over 'locals()' in Context.__init__.
 
-- Issue #9161: Fix regression in optparse's acceptance of unicode
-  strings in add_option calls.
+- Fix extreme speed issue in Decimal.pow when the base is an exact power of
+  10 and the exponent is tiny (for example, Decimal(10) **
+  Decimal('1e-999999999')).
 
-- Issue #9130: Fix validation of relative imports in parser module.
+- bpo-9161: Fix regression in optparse's acceptance of unicode strings in
+  add_option calls.
 
-- Issue #9128: Fix validation of class decorators in parser module.
+- bpo-9130: Fix validation of relative imports in parser module.
 
-- Issue #9164: Ensure sysconfig handles dupblice archs while building on OSX
+- bpo-9128: Fix validation of class decorators in parser module.
 
-- Issue #9315: Fix for the trace module to record correct class name
-  for tracing methods.
+- bpo-9164: Ensure sysconfig handles dupblice archs while building on OSX
 
-Extension Modules
------------------
+- bpo-9315: Fix for the trace module to record correct class name for
+  tracing methods.
 
-- Issue #9054: Fix a crash occurring when using the pyexpat module
-  with expat version 2.0.1.
+- bpo-9054: Fix a crash occurring when using the pyexpat module with expat
+  version 2.0.1.
 
-- Issue #10003: Allow handling of SIGBREAK on Windows. Fixes a regression
+- bpo-10003: Allow handling of SIGBREAK on Windows. Fixes a regression
   introduced by issue #9324.
 
-- Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
+- bpo-8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
   descriptor is provided.  Patch by Pascal Chambon.
 
-- Issue #7736: Release the GIL around calls to opendir() and closedir()
-  in the posix module.  Patch by Marcin Bachry.
+- bpo-7736: Release the GIL around calls to opendir() and closedir() in the
+  posix module.  Patch by Marcin Bachry.
 
 - As a result of issue #2521, the _weakref module is now compiled into the
   interpreter by default.
 
-- Issue #9324: Add parameter validation to signal.signal on Windows in order
-  to prevent crashes.
+- bpo-9324: Add parameter validation to signal.signal on Windows in order to
+  prevent crashes.
 
-- Issue #9526: Remove some outdated (int) casts that were preventing
-  the array module from working correctly with arrays of more than
-  2**31 elements.
+- bpo-9526: Remove some outdated (int) casts that were preventing the array
+  module from working correctly with arrays of more than 2**31 elements.
 
 - Fix memory leak in ssl._ssl._test_decode_cert.
 
-- Issue #8065: Fix memory leak in readline module (from failure to
-  free the result of history_get_history_state()).
+- bpo-8065: Fix memory leak in readline module (from failure to free the
+  result of history_get_history_state()).
 
-- Issue #9450: Fix memory leak in readline.replace_history_item and
+- bpo-9450: Fix memory leak in readline.replace_history_item and
   readline.remove_history_item for readline version >= 5.0.
 
-- Issue #8105: Validate file descriptor passed to mmap.mmap on Windows.
+- bpo-8105: Validate file descriptor passed to mmap.mmap on Windows.
 
-- Issue #1019882: Fix IndexError when loading certain hotshot stats.
+- bpo-1019882: Fix IndexError when loading certain hotshot stats.
 
-- Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
+- bpo-9422: Fix memory leak when re-initializing a struct.Struct object.
 
-- Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
-  compared to other unix systems. In particular, os.getgroups() does
-  not reflect any changes made using os.setgroups() but basically always
-  returns the same information as the id command.
+- bpo-7900: The getgroups(2) system call on MacOSX behaves rather oddly
+  compared to other unix systems. In particular, os.getgroups() does not
+  reflect any changes made using os.setgroups() but basically always returns
+  the same information as the id command.
 
   os.getgroups() can now return more than 16 groups on MacOSX.
 
-- Issue #9277: Fix bug in struct.pack for bools in standard mode
-  (e.g., struct.pack('>?')): if conversion to bool raised an exception
-  then that exception wasn't properly propagated on machines where
-  char is unsigned.
+- bpo-9277: Fix bug in struct.pack for bools in standard mode (e.g.,
+  struct.pack('>?')): if conversion to bool raised an exception then that
+  exception wasn't properly propagated on machines where char is unsigned.
 
-- Issue #7567: Don't call `setupterm' twice.
+- bpo-7567: Don't call `setupterm' twice.
 
 Tools/Demos
 -----------
 
-- Issue #7287: Demo/imputil/knee.py was removed.
+- bpo-7287: Demo/imputil/knee.py was removed.
 
-- Issue #9188: The gdb extension now handles correctly narrow (UCS2) as well
-  as wide (UCS4) unicode builds for both the host interpreter (embedded
-  inside gdb) and the interpreter under test.
+- bpo-9188: The gdb extension now handles correctly narrow (UCS2) as well as
+  wide (UCS4) unicode builds for both the host interpreter (embedded inside
+  gdb) and the interpreter under test.
 
 Build
 -----
 
-- Issue #8852: Allow the socket module to build on OpenSolaris.
+- bpo-8852: Allow the socket module to build on OpenSolaris.
 
-- Issue #10054: Some platforms provide uintptr_t in inttypes.h.  Patch by
-  Akira Kitada.
+- bpo-10054: Some platforms provide uintptr_t in inttypes.h.  Patch by Akira
+  Kitada.
 
-- Issue #10055: Make json C89-compliant in UCS4 mode.
+- bpo-10055: Make json C89-compliant in UCS4 mode.
 
-- Issue #1633863: Don't ignore $CC under AIX.
+- bpo-1633863: Don't ignore $CC under AIX.
 
-- Issue #9810: Compile bzip2 source files in python's project file
-  directly. It used to be built with bzip2's makefile.
+- bpo-9810: Compile bzip2 source files in python's project file directly. It
+  used to be built with bzip2's makefile.
 
-- Issue #941346: Improve the build process under AIX and allow Python to
-  be built as a shared library.  Patch by Sébastien Sablé.
+- bpo-941346: Improve the build process under AIX and allow Python to be
+  built as a shared library.  Patch by Sébastien Sablé.
 
-- Issue #4026: Make the fcntl extension build under AIX.  Patch by Sébastien
+- bpo-4026: Make the fcntl extension build under AIX.  Patch by Sébastien
   Sablé.
 
-- Issue #3101: Helper functions _add_one_to_index_C() and
-  _add_one_to_index_F() become _Py_add_one_to_index_C() and
-  _Py_add_one_to_index_F(), respectively.
+- bpo-3101: Helper functions _add_one_to_index_C() and _add_one_to_index_F()
+  become _Py_add_one_to_index_C() and _Py_add_one_to_index_F(),
+  respectively.
 
-- Issue #9700: define HAVE_BROKEN_POSIX_SEMAPHORES under AIX 6.x.  Patch by
+- bpo-9700: define HAVE_BROKEN_POSIX_SEMAPHORES under AIX 6.x.  Patch by
   Sébastien Sablé.
 
-- Issue #9280: Make sharedinstall depend on sharedmods.
+- bpo-9280: Make sharedinstall depend on sharedmods.
 
-- Issue #9275: The OSX installer once again installs links to binaries in
+- bpo-9275: The OSX installer once again installs links to binaries in
   ``/usr/local/bin``.
 
-- Issue #9392: A framework build on OSX will once again use a versioned name
-  of the ``2to3`` tool, that is you can use ``2to3-2.7`` to select the Python
+- bpo-9392: A framework build on OSX will once again use a versioned name of
+  the ``2to3`` tool, that is you can use ``2to3-2.7`` to select the Python
   2.7 edition of 2to3.
 
-- Issue #9701: The MacOSX installer can patch the shell profile to ensure that
-  the "bin" directory inside the framework is on the shell's search path. This
-  feature now also supports the ZSH shell.
+- bpo-9701: The MacOSX installer can patch the shell profile to ensure that
+  the "bin" directory inside the framework is on the shell's search path.
+  This feature now also supports the ZSH shell.
 
-- Issue #7473: avoid link errors when building a framework with a different
-  set of architectures than the one that is currently installed.
+- bpo-7473: avoid link errors when building a framework with a different set
+  of architectures than the one that is currently installed.
 
 Tests
 -----
 
-- Issue #9978: Wait until subprocess completes initialization. (Win32KillTests
+- bpo-9978: Wait until subprocess completes initialization. (Win32KillTests
   in test_os)
 
-- Issue #9894: Do not hardcode ENOENT in test_subprocess.
+- bpo-9894: Do not hardcode ENOENT in test_subprocess.
 
-- Issue #9323: Make test.regrtest.__file__ absolute, this was not always the
+- bpo-9323: Make test.regrtest.__file__ absolute, this was not always the
   case when running profile or trace, for example.
 
-- Issue #9315: Added tests for the trace module.  Patch by Eli Bendersky.
+- bpo-9315: Added tests for the trace module.  Patch by Eli Bendersky.
 
 - Strengthen test_unicode with explicit type checking for assertEqual tests.
 
-- Issue #8857: Provide a test case for socket.getaddrinfo.
+- bpo-8857: Provide a test case for socket.getaddrinfo.
 
-- Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
+- bpo-7564: Skip test_ioctl if another process is attached to /dev/tty.
 
-- Issue #8433: Fix test_curses failure with newer versions of ncurses.
+- bpo-8433: Fix test_curses failure with newer versions of ncurses.
 
-- Issue #9496: Provide a test suite for the rlcompleter module.  Patch by
+- bpo-9496: Provide a test suite for the rlcompleter module.  Patch by
   Michele Orrù.
 
-- Issue #8605: Skip test_gdb if Python is compiled with optimizations.
+- bpo-8605: Skip test_gdb if Python is compiled with optimizations.
 
-- Issue #9568: Fix test_urllib2_localnet on OS X 10.3.
+- bpo-9568: Fix test_urllib2_localnet on OS X 10.3.
 
 Documentation
 -------------
 
-- Issue #9817: Add expat COPYING file; add expat, libffi and expat licenses
-  to Doc/license.rst.
+- bpo-9817: Add expat COPYING file; add expat, libffi and expat licenses to
+  Doc/license.rst.
 
-- Issue #9524: Document that two CTRL* signals are meant for use only
-  with os.kill.
+- bpo-9524: Document that two CTRL* signals are meant for use only with
+  os.kill.
 
-- Issue #9255: Document that the 'test' package is for internal Python use
+- bpo-9255: Document that the 'test' package is for internal Python use
   only.
 
-- Issue #7829: Document in dis that bytecode is an implementation detail.
+- bpo-7829: Document in dis that bytecode is an implementation detail.
 
 
-What's New in Python 2.7?
-=========================
+What's New in Python 2.7 final?
+===============================
 
 *Release date: 2010-07-03*
 
@@ -6301,19 +6728,17 @@ Core and Builtins
 Library
 -------
 
-- Issue #1868: Eliminate subtle timing issues in thread-local objects by
+- bpo-1868: Eliminate subtle timing issues in thread-local objects by
   getting rid of the cached copy of thread-local attribute dictionary.
 
-- Issue #9125: Add recognition of 'except ... as ...' syntax to parser module.
+- bpo-9125: Add recognition of 'except ... as ...' syntax to parser module.
 
-Extension Modules
------------------
-
-- Issue #7673: Fix security vulnerability (CVE-2010-2089) in the audioop module,
-  ensure that the input string length is a multiple of the frame size.
+- bpo-7673: Fix security vulnerability (CVE-2010-2089) in the audioop
+  module, ensure that the input string length is a multiple of the frame
+  size.
 
-- Issue #9075: In the ssl module, remove the setting of a ``debug`` flag
-  on an OpenSSL structure.
+- bpo-9075: In the ssl module, remove the setting of a ``debug`` flag on an
+  OpenSSL structure.
 
 
 What's New in Python 2.7 release candidate 2?
@@ -6324,58 +6749,58 @@ What's New in Python 2.7 release candidate 2?
 Core and Builtins
 -----------------
 
-- Issue #9058: Remove assertions about INT_MAX in UnicodeDecodeError.
+- bpo-9058: Remove assertions about INT_MAX in UnicodeDecodeError.
 
-- Issue #8202: Previous change to ``sys.argv[0]`` handling for -m command line
-  option reverted due to unintended side effects on handling of ``sys.path``.
-  See tracker issue for details.
+- bpo-8202: Previous change to ``sys.argv[0]`` handling for -m command line
+  option reverted due to unintended side effects on handling of
+  ``sys.path``. See tracker issue for details.
 
-- Issue #8941: decoding big endian UTF-32 data in UCS-2 builds could crash
-  the interpreter with characters outside the Basic Multilingual Plane
-  (higher than 0x10000).
+- bpo-8941: decoding big endian UTF-32 data in UCS-2 builds could crash the
+  interpreter with characters outside the Basic Multilingual Plane (higher
+  than 0x10000).
 
-- In the unicode/str.format(), raise a ValueError when indexes to arguments are
-  too large.
+- In the unicode/str.format(), raise a ValueError when indexes to arguments
+  are too large.
 
 Build
 -----
 
-- Issue #8854: Fix finding Visual Studio 2008 on Windows x64.
+- bpo-8854: Fix finding Visual Studio 2008 on Windows x64.
 
 Library
 -------
 
-- Issue #6589: cleanup asyncore.socket_map in case smtpd.SMTPServer constructor
+- bpo-6589: cleanup asyncore.socket_map in case smtpd.SMTPServer constructor
   raises an exception.
 
-- Issue #8959: fix regression caused by using unmodified libffi
-  library on Windows.  ctypes does now again check the stack before
-  and after calling foreign functions.
+- bpo-8959: fix regression caused by using unmodified libffi library on
+  Windows.  ctypes does now again check the stack before and after calling
+  foreign functions.
 
-- Issue #8720: fix regression caused by fix for #4050 by making getsourcefile
+- bpo-8720: fix regression caused by fix for #4050 by making getsourcefile
   smart enough to find source files in the linecache.
 
-- Issue #8986: math.erfc was incorrectly raising OverflowError for
-  values between -27.3 and -30.0 on some platforms.
+- bpo-8986: math.erfc was incorrectly raising OverflowError for values
+  between -27.3 and -30.0 on some platforms.
 
-- Issue #8924: logging: Improved error handling for Unicode in exception text.
+- bpo-8924: logging: Improved error handling for Unicode in exception text.
 
-- Issue #8948: cleanup functions and class / module setups and teardowns are
+- bpo-8948: cleanup functions and class / module setups and teardowns are
   now honored in unittest debug methods.
 
 Documentation
 -------------
 
-- Issue #8909: Added the size of the bitmap used in the installer created by
+- bpo-8909: Added the size of the bitmap used in the installer created by
   distutils' bdist_wininst. Patch by Anatoly Techtonik.
 
-Misc
-----
+Windows
+-------
 
-- Issue #8362: Add maintainers.rst: list of module maintainers
+- bpo-8362: Add maintainers.rst: list of module maintainers
 
 
-What's New in Python 2.7 Release Candidate 1?
+What's New in Python 2.7 release candidate 1?
 =============================================
 
 *Release date: 2010-06-05*
@@ -6383,138 +6808,135 @@ What's New in Python 2.7 Release Candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #8271: during the decoding of an invalid UTF-8 byte sequence, only the
-  start byte and the continuation byte(s) are now considered invalid, instead
-  of the number of bytes specified by the start byte.
-  E.g.: '\xf1\x80AB'.decode('utf-8', 'replace') now returns u'\ufffdAB' and
-  replaces with U+FFFD only the start byte ('\xf1') and the continuation byte
-  ('\x80') even if '\xf1' is the start byte of a 4-bytes sequence.
+- bpo-8271: during the decoding of an invalid UTF-8 byte sequence, only the
+  start byte and the continuation byte(s) are now considered invalid,
+  instead of the number of bytes specified by the start byte. E.g.:
+  '\xf1\x80AB'.decode('utf-8', 'replace') now returns u'\ufffdAB' and
+  replaces with U+FFFD only the start byte ('\xf1') and the continuation
+  byte ('\x80') even if '\xf1' is the start byte of a 4-bytes sequence.
   Previous versions returned a single u'\ufffd'.
 
-- Issue #8627: Remove bogus "Overriding __cmp__ blocks inheritance of
-  __hash__ in 3.x" warning.  Also fix "XXX undetected error" that
-  arises from the "Overriding __eq__ blocks inheritance ..." warning
-  when turned into an exception: in this case the exception simply
-  gets ignored.
+- bpo-8627: Remove bogus "Overriding __cmp__ blocks inheritance of __hash__
+  in 3.x" warning.  Also fix "XXX undetected error" that arises from the
+  "Overriding __eq__ blocks inheritance ..." warning when turned into an
+  exception: in this case the exception simply gets ignored.
 
-- Issue #8748: Fix two issues with comparisons between complex and integer
+- bpo-8748: Fix two issues with comparisons between complex and integer
   objects.  (1) The comparison could incorrectly return True in some cases
-  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality.
-  (2) The comparison raised an OverflowError for large integers, leading
-  to unpredictable exceptions when combining integers and complex objects
-  in sets or dicts.
+  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality. (2)
+  The comparison raised an OverflowError for large integers, leading to
+  unpredictable exceptions when combining integers and complex objects in
+  sets or dicts.
 
-- Issue #5211: Implicit coercion for the complex type is now completely
+- bpo-5211: Implicit coercion for the complex type is now completely
   removed.  (Coercion for arithmetic operations was already removed in 2.7
   alpha 4, but coercion for rich comparisons was accidentally left in.)
 
-- Issue #3798: Write sys.exit() message to sys.stderr to use stderr encoding
+- bpo-3798: Write sys.exit() message to sys.stderr to use stderr encoding
   and error handler, instead of writing to the C stderr file in utf-8
 
-- Issue #7902: When using explicit relative import syntax, don't try implicit
+- bpo-7902: When using explicit relative import syntax, don't try implicit
   relative import semantics.
 
-- Issue #7079: Fix a possible crash when closing a file object while using it
+- bpo-7079: Fix a possible crash when closing a file object while using it
   from another thread.  Patch by Daniel Stutzbach.
 
-- Issue #8868: Fix that ensures that python scripts have access to the
-  Window Server again in a framework build on MacOSX 10.5 or earlier.
+- bpo-8868: Fix that ensures that python scripts have access to the Window
+  Server again in a framework build on MacOSX 10.5 or earlier.
 
-C-API
+C API
 -----
 
-- Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows embedders
+- bpo-5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows embedders
   of the interpreter to set sys.argv without also modifying sys.path.  This
-  helps fix `CVE-2008-5983
-  <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+  helps fix `CVE-2008-5983 <http://cve.mitre.org/cgi-
+  bin/cvename.cgi?name=CVE-2008-5983>`_.
 
 Library
 -------
 
-- Issue #8302: SkipTest in unittest.TestCase.setUpClass or setUpModule is now
+- bpo-8302: SkipTest in unittest.TestCase.setUpClass or setUpModule is now
   reported as a skip rather than an error.
 
-- Issue #8351: Excessively large diffs due to
+- bpo-8351: Excessively large diffs due to
   unittest.TestCase.assertSequenceEqual are no longer included in failure
   reports.
 
-- Issue #8899: time.struct_time now has class and attribute docstrings.
+- bpo-8899: time.struct_time now has class and attribute docstrings.
 
-- Issue #4487: email now accepts as charset aliases all codec aliases
-  accepted by the codecs module.
+- bpo-4487: email now accepts as charset aliases all codec aliases accepted
+  by the codecs module.
 
-- Issue #6470: Drop UNC prefix in FixTk.
+- bpo-6470: Drop UNC prefix in FixTk.
 
-- Issue #5610: feedparser no longer eats extra characters at the end of
-  a body part if the body part ends with a \r\n.
+- bpo-5610: feedparser no longer eats extra characters at the end of a body
+  part if the body part ends with a \r\n.
 
-- Issue #8833: tarfile created hard link entries with a size field != 0 by
+- bpo-8833: tarfile created hard link entries with a size field != 0 by
   mistake.
 
-- Issue #1368247: set_charset (and therefore MIMEText) now automatically
+- bpo-1368247: set_charset (and therefore MIMEText) now automatically
   encodes a unicode _payload to the output_charset.
 
-- Issue #7150: Raise OverflowError if the result of adding or subtracting
-  timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR range.
+- bpo-7150: Raise OverflowError if the result of adding or subtracting
+  timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR
+  range.
 
-- Issue #6662: Fix parsing of malformatted charref (&#bad;), patch written by
+- bpo-6662: Fix parsing of malformatted charref (&#bad;), patch written by
   Fredrik Håård
 
-- Issue #8016: Add the CP858 codec.
+- bpo-8016: Add the CP858 codec.
 
-- Issue #3924: Ignore cookies with invalid "version" field in cookielib.
+- bpo-3924: Ignore cookies with invalid "version" field in cookielib.
 
-- Issue #6268: Fix seek() method of codecs.open(), don't read or write the BOM
+- bpo-6268: Fix seek() method of codecs.open(), don't read or write the BOM
   twice after seek(0). Fix also reset() method of codecs, UTF-16, UTF-32 and
   StreamWriter classes.
 
-- Issue #5640: Fix Shift-JIS incremental encoder for error handlers different
+- bpo-5640: Fix Shift-JIS incremental encoder for error handlers different
   than 'strict'.
 
-- Issue #8782: Add a trailing newline in linecache.updatecache to the last line
+- bpo-8782: Add a trailing newline in linecache.updatecache to the last line
   of files without one.
 
-- Issue #8729: Return NotImplemented from ``collections.Mapping.__eq__()`` when
+- bpo-8729: Return NotImplemented from ``collections.Mapping.__eq__()`` when
   comparing to a non-mapping.
 
-- Issue #8759: Fix user paths in sysconfig for posix and os2 schemes.
+- bpo-8759: Fix user paths in sysconfig for posix and os2 schemes.
 
-- Issue #1285086: Speed up ``urllib.quote()`` and urllib.unquote for simple
+- bpo-1285086: Speed up ``urllib.quote()`` and urllib.unquote for simple
   cases.
 
-- Issue #8688: Distutils now recalculates MANIFEST every time.
+- bpo-8688: Distutils now recalculates MANIFEST every time.
 
-- Issue #5099: The ``__del__()`` method of ``subprocess.Popen`` (and the methods
-  it calls) referenced global objects, causing errors to pop up during
-  interpreter shutdown.
+- bpo-5099: The ``__del__()`` method of ``subprocess.Popen`` (and the
+  methods it calls) referenced global objects, causing errors to pop up
+  during interpreter shutdown.
 
-Extension Modules
------------------
-
-- Issue #7384: If the system readline library is linked against ncurses,
-  the curses module must be linked against ncurses as well. Otherwise it
-  is not safe to load both the readline and curses modules in an application.
+- bpo-7384: If the system readline library is linked against ncurses, the
+  curses module must be linked against ncurses as well. Otherwise it is not
+  safe to load both the readline and curses modules in an application.
 
-- Issue #2810: Fix cases where the Windows registry API returns
+- bpo-2810: Fix cases where the Windows registry API returns
   ERROR_MORE_DATA, requiring a re-try in order to get the complete result.
 
-- Issue #8674: Fixed a number of incorrect or undefined-behaviour-inducing
+- bpo-8674: Fixed a number of incorrect or undefined-behaviour-inducing
   overflow checks in the ``audioop`` module.
 
 Tests
 -----
 
-- Issue #8889: test_support.transient_internet rewritten so that the new
-  checks also work on FreeBSD, which lacks EAI_NODATA.
+- bpo-8889: test_support.transient_internet rewritten so that the new checks
+  also work on FreeBSD, which lacks EAI_NODATA.
 
-- Issue #8835: test_support.transient_internet() catches gaierror(EAI_NONAME)
+- bpo-8835: test_support.transient_internet() catches gaierror(EAI_NONAME)
   and gaierror(EAI_NODATA)
 
-- Issue #7449: Skip test_socketserver if threading support is disabled
+- bpo-7449: Skip test_socketserver if threading support is disabled
 
 - On darwin, ``test_site`` assumed that a framework build was being used,
-  leading to a failure where four directories were expected for site-packages
-  instead of two in a non-framework build.
+  leading to a failure where four directories were expected for site-
+  packages instead of two in a non-framework build.
 
 Build
 -----
@@ -6522,13 +6944,13 @@ Build
 - Display installer warning that Windows 2000 won't be supported in future
   releases.
 
-- Issues #1759169, #8864: Drop _XOPEN_SOURCE on Solaris, define it for
-  multiprocessing only.
+- bpo-1759169: Drop _XOPEN_SOURCE on Solaris, define it for multiprocessing
+  only. (See also: bpo-8864)
 
 Tools/Demos
 -----------
 
-- Issue #5464: Implement plural forms in msgfmt.py.
+- bpo-5464: Implement plural forms in msgfmt.py.
 
 
 What's New in Python 2.7 beta 2?
@@ -6541,178 +6963,179 @@ Core and Builtins
 
 - Run Clang 2.7's static analyzer for ``Objects/`` and ``Python/``.
 
-- Issue #1533: Fix inconsistency in range function argument processing: any
-  non-float non-integer argument is now converted to an integer (if possible)
-  using its __int__ method.  Previously, only small arguments were treated this
-  way; larger arguments (those whose __int__ was outside the range of a C long)
-  would produce a TypeError.
+- bpo-1533: Fix inconsistency in range function argument processing: any
+  non-float non- integer argument is now converted to an integer (if
+  possible) using its __int__ method.  Previously, only small arguments were
+  treated this way; larger arguments (those whose __int__ was outside the
+  range of a C long) would produce a TypeError.
 
-- Issue #8202: ``sys.argv[0]`` is now set to '-m' instead of '-c' when searching
-  for the module file to be executed with the -m command line option.
+- bpo-8202: ``sys.argv[0]`` is now set to '-m' instead of '-c' when
+  searching for the module file to be executed with the -m command line
+  option.
 
-- Issue #7319: When -Q is used, do not silence DeprecationWarning.
+- bpo-7319: When -Q is used, do not silence DeprecationWarning.
 
-- Issue #7332: Remove the 16KB stack-based buffer in
+- bpo-7332: Remove the 16KB stack-based buffer in
   ``PyMarshal_ReadLastObjectFromFile``, which doesn't bring any noticeable
   benefit compared to the dynamic memory allocation fallback.  Patch by
   Charles-François Natali.
 
-- Issue #8417: Raise an OverflowError when an integer larger than sys.maxsize is
-  passed to bytearray.
+- bpo-8417: Raise an OverflowError when an integer larger than sys.maxsize
+  is passed to bytearray.
 
-- Issue #7072: ``isspace(0xa0)`` is true on Mac OS X.
+- bpo-7072: ``isspace(0xa0)`` is true on Mac OS X.
 
-- Issue #8404: Fix set operations on dictionary views.
+- bpo-8404: Fix set operations on dictionary views.
 
-- Issue #8084: PEP 370 now conforms to system conventions for framework builds
+- bpo-8084: PEP 370 now conforms to system conventions for framework builds
   on MacOS X. That is, ``python setup.py install --user`` will install into
   ``~/Library/Python/2.7`` instead of ``~/.local``.
 
 Library
 -------
 
-- Issue #8681: Make the zlib module's error messages more informative when the
+- bpo-8681: Make the zlib module's error messages more informative when the
   zlib itself doesn't give any detailed explanation.
 
-- Issue #8571: Fix an internal error when compressing or decompressing a chunk
-  larger than 1GB with the zlib module's compressor and decompressor objects.
+- bpo-8571: Fix an internal error when compressing or decompressing a chunk
+  larger than 1GB with the zlib module's compressor and decompressor
+  objects.
 
-- Issue #8573: asyncore ``_strerror()`` function might throw ValueError.
+- bpo-8573: asyncore ``_strerror()`` function might throw ValueError.
 
-- Issue #8483: asyncore.dispatcher's __getattr__ method produced confusing error
-  messages when accessing undefined class attributes because of the cheap
-  inheritance with the underlying socket object.  The cheap inheritance has been
-  deprecated.
+- bpo-8483: asyncore.dispatcher's __getattr__ method produced confusing
+  error messages when accessing undefined class attributes because of the
+  cheap inheritance with the underlying socket object.  The cheap
+  inheritance has been deprecated.
 
-- Issue #4265: ``shutil.copyfile()`` was leaking file descriptors when disk
+- bpo-4265: ``shutil.copyfile()`` was leaking file descriptors when disk
   fills.  Patch by Tres Seaver.
 
-- Issue #7755: Use an unencumbered audio file for tests.
+- bpo-7755: Use an unencumbered audio file for tests.
 
-- Issue #8621: ``uuid.uuid4()`` returned the same sequence of values in the
+- bpo-8621: ``uuid.uuid4()`` returned the same sequence of values in the
   parent and any children created using ``os.fork`` on Mac OS X 10.6.
 
-- Issue #8313: ``traceback.format_exception_only()`` encodes unicode message to
+- bpo-8313: ``traceback.format_exception_only()`` encodes unicode message to
   ASCII with backslashreplace error handler if ``str(value)`` failed.
 
-- Issue #8567: Fix precedence of signals in Decimal module: when a Decimal
+- bpo-8567: Fix precedence of signals in Decimal module: when a Decimal
   operation raises multiple signals and more than one of those signals is
-  trapped, the specification determines the order in which the signals should be
-  handled.  In many cases this order wasn't being followed, leading to the wrong
-  Python exception being raised.
+  trapped, the specification determines the order in which the signals
+  should be handled. In many cases this order wasn't being followed, leading
+  to the wrong Python exception being raised.
 
-- Issue #7865: The close() method of :mod:`io` objects should not swallow
-  exceptions raised by the implicit flush().  Also ensure that calling close()
-  several times is supported.  Patch by Pascal Chambon.
+- bpo-7865: The close() method of :mod:`io` objects should not swallow
+  exceptions raised by the implicit flush().  Also ensure that calling
+  close() several times is supported.  Patch by Pascal Chambon.
 
-- Issue #8576: logging updated to remove usage of find_unused_port().
+- bpo-8576: logging updated to remove usage of find_unused_port().
 
-- Issue #4687: Fix accuracy of garbage collection runtimes displayed with
+- bpo-4687: Fix accuracy of garbage collection runtimes displayed with
   gc.DEBUG_STATS.
 
-- Issue #8354: The siginterrupt setting is now preserved for all signals, not
+- bpo-8354: The siginterrupt setting is now preserved for all signals, not
   just SIGCHLD.
 
-- Issue #7192: ``webbrowser.get("firefox")`` now works on Mac OS X, as does
+- bpo-7192: ``webbrowser.get("firefox")`` now works on Mac OS X, as does
   ``webbrowser.get("safari")``.
 
-- Issue #8577: ``distutils.sysconfig.get_python_inc()`` now makes a difference
+- bpo-8577: ``distutils.sysconfig.get_python_inc()`` now makes a difference
   between the build dir and the source dir when looking for "python.h" or
   "Include".
 
-- Issue #8464: tarfile no longer creates files with execute permissions set when
-  mode="w|" is used.
+- bpo-8464: tarfile no longer creates files with execute permissions set
+  when mode="w|" is used.
 
-- Issue #7834: Fix connect() of Bluetooth L2CAP sockets with recent versions of
+- bpo-7834: Fix connect() of Bluetooth L2CAP sockets with recent versions of
   the Linux kernel.  Patch by Yaniv Aknin.
 
-- Issue #6312: Fix http HEAD request when the transfer encoding is chunked.  It
+- bpo-6312: Fix http HEAD request when the transfer encoding is chunked.  It
   should correctly return an empty response now.
 
-- Issue #7490: To facilitate sharing of doctests between 2.x and 3.x test
-  suites, the ``IGNORE_EXCEPTION_DETAIL`` directive now also ignores the module
-  location of the raised exception.  Based on initial patch by Lennart Regebro.
+- bpo-7490: To facilitate sharing of doctests between 2.x and 3.x test
+  suites, the ``IGNORE_EXCEPTION_DETAIL`` directive now also ignores the
+  module location of the raised exception.  Based on initial patch by
+  Lennart Regebro.
 
-- Issue #8086: In :func:`ssl.DER_cert_to_PEM_cert()`, fix missing newline before
-  the certificate footer.  Patch by Kyle VanderBeek.
+- bpo-8086: In :func:`ssl.DER_cert_to_PEM_cert()`, fix missing newline
+  before the certificate footer.  Patch by Kyle VanderBeek.
 
-- Issue #8546: Reject None given as the buffering argument to ``_pyio.open()``.
+- bpo-8546: Reject None given as the buffering argument to ``_pyio.open()``.
 
-- Issue #8549: Fix compiling the _ssl extension under AIX.  Patch by Sridhar
+- bpo-8549: Fix compiling the _ssl extension under AIX.  Patch by Sridhar
   Ratnakumar.
 
-- Issue #6656: Fix locale.format_string to handle escaped percents and mappings.
+- bpo-6656: Fix locale.format_string to handle escaped percents and
+  mappings.
 
-- Issue #2302: Fix a race condition in SocketServer.BaseServer.shutdown, where
+- bpo-2302: Fix a race condition in SocketServer.BaseServer.shutdown, where
   the method could block indefinitely if called just before the event loop
   started running.  This also fixes the occasional freezes witnessed in
   test_httpservers.
 
-- Issue #5103: SSL handshake would ignore the socket timeout and block
+- bpo-5103: SSL handshake would ignore the socket timeout and block
   indefinitely if the other end didn't respond.
 
-- The do_handshake() method of SSL objects now adjusts the blocking mode of the
-  SSL structure if necessary (as other methods already do).
+- The do_handshake() method of SSL objects now adjusts the blocking mode of
+  the SSL structure if necessary (as other methods already do).
 
-- Issue #7507: Quote "!" in pipes.quote(); it is special to some shells.
+- bpo-7507: Quote "!" in pipes.quote(); it is special to some shells.
 
-- Issue #5238: Calling makefile() on an SSL object would prevent the underlying
+- bpo-5238: Calling makefile() on an SSL object would prevent the underlying
   socket from being closed until all objects get truely destroyed.
 
-- Issue #7943: Fix circular reference created when instantiating an SSL socket.
+- bpo-7943: Fix circular reference created when instantiating an SSL socket.
   Initial patch by Péter Szabó.
 
-- Issue #8451: Syslog module now uses basename(sys.argv[0]) instead of the
+- bpo-8451: Syslog module now uses basename(sys.argv[0]) instead of the
   string "python" as the *ident*.  openlog() arguments are all optional and
   keywords.
 
-- Issue #8108: Fix the unwrap() method of SSL objects when the socket has a
+- bpo-8108: Fix the unwrap() method of SSL objects when the socket has a
   non-infinite timeout.  Also make that method friendlier with applications
   wanting to continue using the socket in clear-text mode, by disabling
   OpenSSL's internal readahead.  Thanks to Darryl Miles for guidance.
 
-- Issue #8484: Load all ciphers and digest algorithms when initializing the _ssl
-  extension, such that verification of some SSL certificates doesn't fail
-  because of an "unknown algorithm".
+- bpo-8484: Load all ciphers and digest algorithms when initializing the
+  _ssl extension, such that verification of some SSL certificates doesn't
+  fail because of an "unknown algorithm".
 
-- Issue #8437: Fix test_gdb failures, patch written by Dave Malcolm
+- bpo-8437: Fix test_gdb failures, patch written by Dave Malcolm
 
-- Issue #4814: The timeout parameter is now applied also for connections
+- bpo-4814: The timeout parameter is now applied also for connections
   resulting from PORT/EPRT commands.
 
-- Issue #8463: Add missing reference to bztar in shutil's documentation.
+- bpo-8463: Add missing reference to bztar in shutil's documentation.
 
-- Issue #8438: Remove reference to the missing "surrogateescape" encoding error
+- bpo-8438: Remove reference to the missing "surrogateescape" encoding error
   handler from the new IO library.
 
-- Issue #3817: ftplib.FTP.abort() method now considers 225 a valid response code
-  as stated in RFC-959 at chapter 5.4.
+- bpo-3817: ftplib.FTP.abort() method now considers 225 a valid response
+  code as stated in RFC-959 at chapter 5.4.
 
-- Issue #8279: Fix test_gdb failures.
+- bpo-8279: Fix test_gdb failures.
 
-- Issue #8322: Add a *ciphers* argument to SSL sockets, so as to change the
+- bpo-8322: Add a *ciphers* argument to SSL sockets, so as to change the
   available cipher list.  Helps fix test_ssl with OpenSSL 1.0.0.
 
-- Issue #2987: RFC 2732 support for urlparse (IPv6 addresses).  Patch by Tony
+- bpo-2987: RFC 2732 support for urlparse (IPv6 addresses).  Patch by Tony
   Locke and Hans Ulrich Niedermann.
 
-- Issue #7585: difflib context and unified diffs now place a tab between
-  filename and date, conforming to the 'standards' they were originally designed
-  to follow.  This improves compatibility with patch tools.
+- bpo-7585: difflib context and unified diffs now place a tab between
+  filename and date, conforming to the 'standards' they were originally
+  designed to follow.  This improves compatibility with patch tools.
 
-- Issue #7472: Fixed typo in email.encoders module; messages using ISO-2022
-  character sets will now consistently use a Content-Transfer-Encoding of 7bit
-  rather than sometimes being marked as 8bit.
+- bpo-7472: Fixed typo in email.encoders module; messages using ISO-2022
+  character sets will now consistently use a Content-Transfer-Encoding of
+  7bit rather than sometimes being marked as 8bit.
 
-- Issue #8330: Fix expected output in test_gdb.
+- bpo-8330: Fix expected output in test_gdb.
 
-- Issue #8374: Update the internal alias table in the :mod:`locale` module to
+- bpo-8374: Update the internal alias table in the :mod:`locale` module to
   cover recent locale changes and additions.
 
-Extension Modules
------------------
-
-- Issue #8644: Improved accuracy of ``timedelta.total_seconds()``.
+- bpo-8644: Improved accuracy of ``timedelta.total_seconds()``.
 
 - Use Clang 2.7's static analyzer to find places to clean up some code.
 
@@ -6724,39 +7147,40 @@ Extension Modules
 Tests
 -----
 
-- Issue #8672: Add a zlib test ensuring that an incomplete stream can be handled
-  by a decompressor object without errors (it returns incomplete uncompressed
-  data).
+- bpo-8672: Add a zlib test ensuring that an incomplete stream can be
+  handled by a decompressor object without errors (it returns incomplete
+  uncompressed data).
 
-- Issue #8490: asyncore now has a more solid test suite which actually tests its
-  API.
+- bpo-8490: asyncore now has a more solid test suite which actually tests
+  its API.
 
-- Issue #8576: Remove use of find_unused_port() in test_smtplib and
-  test_multiprocessing.  Patch by Paul Moore.
+- bpo-8576: Remove use of find_unused_port() in test_smtplib and
+  test_multiprocessing. Patch by Paul Moore.
 
-- Issue #7449: Fix many tests to support Python compiled without thread support.
-  Patches written by Jerry Seutter.
+- bpo-7449: Fix many tests to support Python compiled without thread
+  support. Patches written by Jerry Seutter.
 
-- Issue #8108: test_ftplib's non-blocking SSL server now has proper handling of
+- bpo-8108: test_ftplib's non-blocking SSL server now has proper handling of
   SSL shutdowns.
 
 Build
 -----
 
-- Issue #8625: Turn off optimization in ``--with-pydebug`` builds with gcc.
-  (Optimization was unintentionally turned on in gcc --with-pydebug builds in
-  2.7 beta1 as a result of the issue #1628484 fix, combined with autoconf's
-  strange choice of default CFLAGS produced by AC_PROG_CC for gcc.)
+- bpo-8625: Turn off optimization in ``--with-pydebug`` builds with gcc.
+  (Optimization was unintentionally turned on in gcc --with-pydebug builds
+  in 2.7 beta1 as a result of the issue #1628484 fix, combined with
+  autoconf's strange choice of default CFLAGS produced by AC_PROG_CC for
+  gcc.)
 
-- Issue #8509: Fix quoting in help strings and code snippets in configure.in.
+- bpo-8509: Fix quoting in help strings and code snippets in configure.in.
 
-- Issue #3646: It is now easily possible to install a Python framework into your
-  home directory on Mac OS X, see Mac/README for more information.
+- bpo-3646: It is now easily possible to install a Python framework into
+  your home directory on Mac OS X, see Mac/README for more information.
 
-- Issue #8510: Update to autoconf 2.65.
+- bpo-8510: Update to autoconf 2.65.
 
-Misc
-----
+Windows
+-------
 
 - Update the Vim syntax highlight file.
 
@@ -6769,43 +7193,43 @@ What's New in Python 2.7 beta 1?
 Core and Builtins
 -----------------
 
-- Issue #7301: Add environment variable $PYTHONWARNINGS.
+- bpo-7301: Add environment variable $PYTHONWARNINGS.
 
-- Issue #8329: Don't return the same lists from select.select when no fds are
+- bpo-8329: Don't return the same lists from select.select when no fds are
   changed.
 
-- Issue #8259: ``1L << (2**31)`` no longer produces an 'outrageous shift error'
+- bpo-8259: ``1L << (2**31)`` no longer produces an 'outrageous shift error'
   on 64-bit machines.  The shift count for either left or right shift is
   permitted to be up to sys.maxsize.
 
 - Ensure that tokenization of identifiers is not affected by locale.
 
-- Issue #1222585: Added LDCXXSHARED for C++ support.  Patch by Arfrever.
+- bpo-1222585: Added LDCXXSHARED for C++ support.  Patch by Arfrever.
 
 - Raise a TypeError when trying to delete a T_STRING_INPLACE struct member.
 
-- Issue #7994: Issue a PendingDeprecationWarning if object.__format__ is called
-  with a non-empty format string. This is an effort to future-proof user
+- bpo-7994: Issue a PendingDeprecationWarning if object.__format__ is called
+  with a non- empty format string. This is an effort to future-proof user
   code. If a derived class does not currently implement __format__ but later
   adds its own __format__, it would most likely break user code that had
   supplied a format string. This will be changed to a DeprecationWarning in
   Python 3.3 and it will be an error in Python 3.4.
 
-- Issue #8268: Old-style classes (not just instances) now support weak
+- bpo-8268: Old-style classes (not just instances) now support weak
   references.
 
-- Issue #8211: Save/restore CFLAGS around AC_PROG_CC in configure.in, in case it
-  is set.
+- bpo-8211: Save/restore CFLAGS around AC_PROG_CC in configure.in, in case
+  it is set.
 
-- Issue #1583863: A unicode subclass can now override the __unicode__ method
+- bpo-1583863: A unicode subclass can now override the __unicode__ method
 
-- Issue #6474: Make error message from passing an inadequate number of keyword
+- bpo-6474: Make error message from passing an inadequate number of keyword
   arguments to a function correct.
 
-- Issue #8164: Don't allow lambda functions to have a docstring.
+- bpo-8164: Don't allow lambda functions to have a docstring.
 
-- Issue #3137: Don't ignore errors at startup, especially a keyboard interrupt
-  (SIGINT).  If an error occurs while importing the site module, the error is
+- bpo-3137: Don't ignore errors at startup, especially a keyboard interrupt
+  (SIGINT). If an error occurs while importing the site module, the error is
   printed and Python exits.  Initialize the GIL before importing the site
   module.
 
@@ -6814,172 +7238,171 @@ Core and Builtins
 Library
 -------
 
-- Issue #5277: Fix quote counting when parsing RFC 2231 encoded parameters.
+- bpo-5277: Fix quote counting when parsing RFC 2231 encoded parameters.
 
-- Issue #8321: Give access to OpenSSL version numbers from the `ssl` module,
-  using the new attributes `ssl.OPENSSL_VERSION`, `ssl.OPENSSL_VERSION_INFO` and
-  `ssl.OPENSSL_VERSION_NUMBER`.
+- bpo-8321: Give access to OpenSSL version numbers from the `ssl` module,
+  using the new attributes `ssl.OPENSSL_VERSION`, `ssl.OPENSSL_VERSION_INFO`
+  and `ssl.OPENSSL_VERSION_NUMBER`.
 
-- Issue #8310: Allow dis to examine new style classes.
+- bpo-8310: Allow dis to examine new style classes.
 
-- Issue #8257: The Decimal construct now accepts a float instance directly,
+- bpo-8257: The Decimal construct now accepts a float instance directly,
   converting that float to a Decimal of equal value:
 
-     >>> Decimal(1.1)
-     Decimal('1.100000000000000088817841970012523233890533447265625')
+  >>> Decimal(1.1)
+  Decimal('1.100000000000000088817841970012523233890533447265625')
 
 - collections.Counter() now supports a subtract() method.
 
-- The functools module now has a total_ordering() class decorator to simplify
-  the specification of rich comparisons.
+- The functools module now has a total_ordering() class decorator to
+  simplify the specification of rich comparisons.
 
-- The functools module also adds cmp_to_key() as a tool to transition old-style
-  comparison functions to new-style key-functions.
+- The functools module also adds cmp_to_key() as a tool to transition old-
+  style comparison functions to new-style key-functions.
 
-- Issue #8294: The Fraction constructor now accepts Decimal and float instances
+- bpo-8294: The Fraction constructor now accepts Decimal and float instances
   directly.
 
-- Issue #7279: Comparisons involving a Decimal signaling NaN now signal
-  InvalidOperation instead of returning False.  (Comparisons involving a quiet
-  NaN are unchanged.)  Also, Decimal quiet NaNs are now hashable; Decimal
-  signaling NaNs remain unhashable.
+- bpo-7279: Comparisons involving a Decimal signaling NaN now signal
+  InvalidOperation instead of returning False.  (Comparisons involving a
+  quiet NaN are unchanged.)  Also, Decimal quiet NaNs are now hashable;
+  Decimal signaling NaNs remain unhashable.
 
-- Issue #2531: Comparison operations between floats and Decimal instances now
-  return a result based on the numeric values of the operands; previously they
-  returned an arbitrary result based on the relative ordering of id(float) and
-  id(Decimal).
+- bpo-2531: Comparison operations between floats and Decimal instances now
+  return a result based on the numeric values of the operands; previously
+  they returned an arbitrary result based on the relative ordering of
+  id(float) and id(Decimal).
 
-- Issue #8233: When run as a script, py_compile.py optionally takes a single
-  argument `-` which tells it to read files to compile from stdin.  Each line is
-  read on demand and the named file is compiled immediately.  (Original patch by
-  Piotr Ożarowski).
+- bpo-8233: When run as a script, py_compile.py optionally takes a single
+  argument `-` which tells it to read files to compile from stdin.  Each
+  line is read on demand and the named file is compiled immediately.
+  (Original patch by Piotr Ożarowski).
 
-- Issue #3135: Add ``inspect.getcallargs()``, which binds arguments to a
+- bpo-3135: Add ``inspect.getcallargs()``, which binds arguments to a
   function like a normal call.
 
-- Backwards incompatible change: Unicode codepoints line tabulation (0x0B) and
-  form feed (0x0C) are now considered linebreaks, as specified in Unicode
-  Standard Annex #14.  See issue #7643.  http://www.unicode.org/reports/tr14/
+- Backwards incompatible change: Unicode codepoints line tabulation (0x0B)
+  and form feed (0x0C) are now considered linebreaks, as specified in
+  Unicode Standard Annex #14.  See issue #7643.
+  http://www.unicode.org/reports/tr14/
 
 - Comparisons using one of <, <=, >, >= between a complex instance and a
-  Fractions instance now raise TypeError instead of returning True/False.  This
-  makes Fraction <=> complex comparisons consistent with int <=> complex, float
-  <=> complex, and complex <=> complex comparisons.
+  Fractions instance now raise TypeError instead of returning True/False.
+  This makes Fraction <=> complex comparisons consistent with int <=>
+  complex, float <=> complex, and complex <=> complex comparisons.
 
 - Addition of ``WeakSet`` to the ``weakref`` module.
 
 - logging: Added LOG_FTP to SysLogHandler and updated documentation.
 
-- Issue #8205: Remove the "Modules" directory from sys.path when Python is
+- bpo-8205: Remove the "Modules" directory from sys.path when Python is
   running from the build directory (POSIX only).
 
-- Issue #7667: Fix doctest failures with non-ASCII paths.
+- bpo-7667: Fix doctest failures with non-ASCII paths.
 
-- Issue #7512: shutil.copystat() could raise an OSError when the filesystem
-  didn't support chflags() (for example ZFS under FreeBSD).  The error is now
-  silenced.
+- bpo-7512: shutil.copystat() could raise an OSError when the filesystem
+  didn't support chflags() (for example ZFS under FreeBSD).  The error is
+  now silenced.
 
-- Issue #7703: ctypes supports both buffer() and memoryview().  The former is
+- bpo-7703: ctypes supports both buffer() and memoryview().  The former is
   deprecated.
 
-- Issue #7860: platform.uname now reports the correct 'machine' type when Python
-  is running in WOW64 mode on 64 bit Windows.
+- bpo-7860: platform.uname now reports the correct 'machine' type when
+  Python is running in WOW64 mode on 64 bit Windows.
 
-- logging: Added getChild utility method to Logger and added isEnabledFor method
-  to LoggerAdapter.
+- logging: Added getChild utility method to Logger and added isEnabledFor
+  method to LoggerAdapter.
 
-- Issue #8201: logging: Handle situation of non-ASCII and Unicode logger names
+- bpo-8201: logging: Handle situation of non-ASCII and Unicode logger names
   existing at the same time, causing a Unicode error when configuration code
   attempted to sort the existing loggers.
 
-- Issue #8200: logging: Handle errors when multiprocessing is not fully loaded
+- bpo-8200: logging: Handle errors when multiprocessing is not fully loaded
   when logging occurs.
 
-- Issue #3890, #8222: Fix recv() and recv_into() on non-blocking SSL sockets.
-  Also, enable the SSL_MODE_AUTO_RETRY flag on SSL sockets, so that blocking
-  reads and writes are always retried by OpenSSL itself.
+- bpo-3890: Fix recv() and recv_into() on non-blocking SSL sockets. Also,
+  enable the SSL_MODE_AUTO_RETRY flag on SSL sockets, so that blocking reads
+  and writes are always retried by OpenSSL itself. (See also: bpo-8222)
 
-- Issue #8179: Fix macpath.realpath() on a non-existing path.
+- bpo-8179: Fix macpath.realpath() on a non-existing path.
 
-- Issue #8024: Update the Unicode database to 5.2.
+- bpo-8024: Update the Unicode database to 5.2.
 
-- Issue #8104: socket.recv_into() and socket.recvfrom_into() now support writing
-  into objects supporting the new buffer API, for example bytearrays or
-  memoryviews.
+- bpo-8104: socket.recv_into() and socket.recvfrom_into() now support
+  writing into objects supporting the new buffer API, for example bytearrays
+  or memoryviews.
 
-- Issue #4961: Inconsistent/wrong result of askyesno function in tkMessageBox
+- bpo-4961: Inconsistent/wrong result of askyesno function in tkMessageBox
   with Tcl/Tk-8.5.
 
-- Issue #8140: Extend compileall to compile single files.  Add -i option.
+- bpo-8140: Extend compileall to compile single files.  Add -i option.
 
-- Issue #7774: Set sys.executable to an empty string if ``argv[0]`` has been set
-  to a non existent program name and Python is unable to retrieve the real
-  program name.
+- bpo-7774: Set sys.executable to an empty string if ``argv[0]`` has been
+  set to a non existent program name and Python is unable to retrieve the
+  real program name.
 
-- Issue #8117: logging: Improved algorithm for computing initial rollover time
-  for ``TimedRotatingFileHandler`` by using the modification time of an existing
-  log file to compute the next rollover time.  If the log file does not exist,
-  the current time is used as the basis for the computation.
+- bpo-8117: logging: Improved algorithm for computing initial rollover time
+  for ``TimedRotatingFileHandler`` by using the modification time of an
+  existing log file to compute the next rollover time.  If the log file does
+  not exist, the current time is used as the basis for the computation.
 
-- Issue #6472: The ``xml.etree`` package is updated to ElementTree 1.3.  The
+- bpo-6472: The ``xml.etree`` package is updated to ElementTree 1.3.  The
   cElementTree module is updated too.
 
-- Issue #7880: Fix sysconfig when the python executable is a symbolic link.
+- bpo-7880: Fix sysconfig when the python executable is a symbolic link.
 
-- Issue #7624: Fix ``isinstance(foo(), collections.Callable)`` for old-style
+- bpo-7624: Fix ``isinstance(foo(), collections.Callable)`` for old-style
   classes.
 
-- Issue #7143: email: ``get_payload()`` used to strip any trailing newline from
+- bpo-7143: email: ``get_payload()`` used to strip any trailing newline from
   a base64 transfer-encoded payload *after* decoding it; it no longer does.
-  This is a behavior change, so email's minor version number is now bumped, to
-  version 4.0.2, for the 2.7 release.
+  This is a behavior change, so email's minor version number is now bumped,
+  to version 4.0.2, for the 2.7 release.
 
-- Issue #8235: _socket: Add the constant ``SO_SETFIB``.  SO_SETFIB is
-  a socket option available on FreeBSD 7.1 and newer.
+- bpo-8235: _socket: Add the constant ``SO_SETFIB``.  SO_SETFIB is a socket
+  option available on FreeBSD 7.1 and newer.
 
-- Issue #8038: unittest.TestCase.assertNotRegexpMatches
+- bpo-8038: unittest.TestCase.assertNotRegexpMatches
 
-- Addition of -b command line option to unittest for buffering stdout / stderr
-  during test runs.
+- Addition of -b command line option to unittest for buffering stdout /
+  stderr during test runs.
 
-- Issue #1220212: Added os.kill support for Windows, including support for
+- bpo-1220212: Added os.kill support for Windows, including support for
   sending CTRL+C and CTRL+BREAK events to console subprocesses.
 
-Extension Modules
------------------
+- bpo-8314: Fix unsigned long long bug in libffi on Sparc v8.
 
-- Issue #8314: Fix unsigned long long bug in libffi on Sparc v8.
+- bpo-1039: Fix os.execlp() crash with missing 2nd argument. (See also:
+  bpo-8154)
 
-- Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument.
+- bpo-8156: bsddb module updated to version 4.8.4.
+  http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.8.4.  This update
+  drops support for Berkeley DB 4.0, and adds support for 4.8.
 
-- Issue #8156: bsddb module updated to version 4.8.4.
-  http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.8.4.  This update drops
-  support for Berkeley DB 4.0, and adds support for 4.8.
+- bpo-3928: os.mknod() now available in Solaris, also.
 
-- Issue #3928: os.mknod() now available in Solaris, also.
+- bpo-8142: Update libffi to the 3.0.9 release.
 
-- Issue #8142: Update libffi to the 3.0.9 release.
-
-- Issue #8300: When passing a non-integer argument to struct.pack with any
+- bpo-8300: When passing a non-integer argument to struct.pack with any
   integer format code, struct.pack first attempts to convert the non-integer
   using its __index__ method.  If that method is non-existent or raises
   TypeError it goes on to try the __int__ method, as described below.
 
-- Issue #1530559: When passing a non-integer argument to struct.pack with *any*
+- bpo-1530559: When passing a non-integer argument to struct.pack with *any*
   integer format code (one of 'bBhHiIlLqQ'), struct.pack attempts to use the
-  argument's __int__ method to convert to an integer before packing.  It also
-  produces a DeprecationWarning in this case.  (In Python 2.6, the behaviour was
-  inconsistent: __int__ was used for some integer codes but not for others, and
-  the set of integer codes for which it was used differed between native packing
-  and standard packing.)
+  argument's __int__ method to convert to an integer before packing.  It
+  also produces a DeprecationWarning in this case.  (In Python 2.6, the
+  behaviour was inconsistent: __int__ was used for some integer codes but
+  not for others, and the set of integer codes for which it was used
+  differed between native packing and standard packing.)
 
-- Issue #7347: _winreg: Add CreateKeyEx and DeleteKeyEx, as well as fix a bug in
-  the return value of QueryReflectionKey.
+- bpo-7347: _winreg: Add CreateKeyEx and DeleteKeyEx, as well as fix a bug
+  in the return value of QueryReflectionKey.
 
 Tools/Demos
 -----------
 
-- Issue #7993: Add a test of IO packet processing bandwidth to ccbench.  It
+- bpo-7993: Add a test of IO packet processing bandwidth to ccbench.  It
   measures the number of UDP packets processed per second depending on the
   number of background CPU-bound Python threads.
 
@@ -6988,56 +7411,56 @@ Tools/Demos
 Build
 -----
 
-- Issue #8032: For gdb7, a python-gdb.py file is added to the build, allowing to
-  use advanced gdb features when debugging Python.
+- bpo-8032: For gdb7, a python-gdb.py file is added to the build, allowing
+  to use advanced gdb features when debugging Python.
 
-- Issue #1628484: The Makefile doesn't ignore the CFLAGS environment variable
-  anymore.  It also forwards the LDFLAGS settings to the linker when building a
-  shared library.
+- bpo-1628484: The Makefile doesn't ignore the CFLAGS environment variable
+  anymore.  It also forwards the LDFLAGS settings to the linker when
+  building a shared library.
 
-- Issue #6716: Quote -x arguments of compileall in MSI installer.
+- bpo-6716: Quote -x arguments of compileall in MSI installer.
 
-- Issue #7705: Fix linking on FreeBSD.
+- bpo-7705: Fix linking on FreeBSD.
 
 - Make sure that the FreeBSD build of the included libffi uses the proper
   assembly file.
 
-C-API
+C API
 -----
 
-- Issue #8276: PyEval_CallObject() is now only available in macro form.  The
-  function declaration, which was kept for backwards compatibility reasons, is
-  now removed (the macro was introduced in 1997!).
+- bpo-8276: PyEval_CallObject() is now only available in macro form.  The
+  function declaration, which was kept for backwards compatibility reasons,
+  is now removed (the macro was introduced in 1997!).
 
-- Issue #7992: A replacement PyCObject API, PyCapsule, has been backported from
-  Python 3.1.  All existing Python CObjects in the main distribution have been
-  converted to capsules.  To address backwards-compatibility concerns,
+- bpo-7992: A replacement PyCObject API, PyCapsule, has been backported from
+  Python 3.1. All existing Python CObjects in the main distribution have
+  been converted to capsules.  To address backwards-compatibility concerns,
   PyCObject_AsVoidPtr() was changed to understand capsules.
 
 Tests
 -----
 
-- Issue #3864: Skip three test_signal tests on freebsd6 because they fail if any
-  thread was previously started, most likely due to a platform bug.
+- bpo-3864: Skip three test_signal tests on freebsd6 because they fail if
+  any thread was previously started, most likely due to a platform bug.
 
-- Issue #8348: Fix test ftp url in test_urllib2net.
+- bpo-8348: Fix test ftp url in test_urllib2net.
 
-- Issue #8204: Fix test_ttk notebook test by forcing focus.
+- bpo-8204: Fix test_ttk notebook test by forcing focus.
 
-- Issue #8344: Fix test_ttk bug on FreeBSD.
+- bpo-8344: Fix test_ttk bug on FreeBSD.
 
-- Issue #8193: Fix test_zlib failure with zlib 1.2.4.
+- bpo-8193: Fix test_zlib failure with zlib 1.2.4.
 
-- Issue #8248: Add some tests for the bool type.  Patch by Gregory Nofi.
+- bpo-8248: Add some tests for the bool type.  Patch by Gregory Nofi.
 
-- Issue #8263: Now regrtest.py will report a failure if it receives a
+- bpo-8263: Now regrtest.py will report a failure if it receives a
   KeyboardInterrupt (SIGINT).
 
-- Issue #8180 and #8207: Fix test_pep277 on OS X and add more tests for special
-  Unicode normalization cases.
+- bpo-8180: Fix test_pep277 on OS X and add more tests for special Unicode
+  normalization cases. (See also: bpo-8207)
 
-- Issue #7783: test.test_support.open_urlresource invalidates the outdated files
-  from the local cache.
+- bpo-7783: test.test_support.open_urlresource invalidates the outdated
+  files from the local cache.
 
 
 What's New in Python 2.7 alpha 4?
@@ -7048,128 +7471,126 @@ What's New in Python 2.7 alpha 4?
 Core and Builtins
 -----------------
 
-- Issue #7544: Preallocate thread memory before creating the thread to avoid a
+- bpo-7544: Preallocate thread memory before creating the thread to avoid a
   fatal error in low memory condition.
 
-- Issue #7820: The parser tokenizer restores all bytes in the right if the BOM
+- bpo-7820: The parser tokenizer restores all bytes in the right if the BOM
   check fails.
 
-- Issue #7309: Fix unchecked attribute access when converting
-  UnicodeEncodeError, UnicodeDecodeError, and UnicodeTranslateError to strings.
+- bpo-7309: Fix unchecked attribute access when converting
+  UnicodeEncodeError, UnicodeDecodeError, and UnicodeTranslateError to
+  strings.
 
-- Issue #7649: "u'%c' % char" now behaves like "u'%s' % char" and raises a
-  UnicodeDecodeError if 'char' is a byte string that can't be decoded using the
-  default encoding.
+- bpo-7649: "u'%c' % char" now behaves like "u'%s' % char" and raises a
+  UnicodeDecodeError if 'char' is a byte string that can't be decoded using
+  the default encoding.
 
-- Issue #6902: Fix problem with built-in types format incorrectly with 0
+- bpo-6902: Fix problem with built-in types format incorrectly with 0
   padding.
 
-- Issue #2560: Remove an unnecessary 'for' loop from ``my_fgets()`` in
+- bpo-2560: Remove an unnecessary 'for' loop from ``my_fgets()`` in
   Parser/myreadline.c.
 
-- Issue #7988: Fix default alignment to be right aligned for
+- bpo-7988: Fix default alignment to be right aligned for
   ``complex.__format__``.  Now it matches other numeric types.
 
-- Issue #5211: The complex type no longer uses implicit coercion in mixed-type
+- bpo-5211: The complex type no longer uses implicit coercion in mixed-type
   binary arithmetic operations.
 
 Library
 -------
 
-- Issue #7904: Changes to urllib.parse.urlsplit to handle schemes as defined by
+- bpo-7904: Changes to urllib.parse.urlsplit to handle schemes as defined by
   RFC3986. Anything before :// is considered a scheme and is followed by an
   authority (or netloc) and by '/' led path, which is optional.
 
-- Issue #1555570: email no longer inserts extra blank lines when a \r\n
-  combo crosses an 8192 byte boundary.
+- bpo-1555570: email no longer inserts extra blank lines when a \r\n combo
+  crosses an 8192 byte boundary.
 
-- Issue #6906: Tk should not set Unicode environment variables on Windows.
+- bpo-6906: Tk should not set Unicode environment variables on Windows.
 
-- Issue #1054943: Fix ``unicodedata.normalize('NFC', text)`` for the Public
+- bpo-1054943: Fix ``unicodedata.normalize('NFC', text)`` for the Public
   Review Issue #29 (http://unicode.org/review/pr-29.html).
 
-- Issue #7494: Fix a crash in ``_lsprof`` (cProfile) after clearing the profiler,
-  reset also the pointer to the current pointer context.
+- bpo-7494: Fix a crash in ``_lsprof`` (cProfile) after clearing the
+  profiler, reset also the pointer to the current pointer context.
 
-- Issue #7232: Add support for the context management protocol to the
+- bpo-7232: Add support for the context management protocol to the
   ``tarfile.TarFile`` class.
 
-- Issue #7250: Fix info leak of os.environ across multi-run uses of
+- bpo-7250: Fix info leak of os.environ across multi-run uses of
   ``wsgiref.handlers.CGIHandler``.
 
-- Issue #1729305: Fix doctest to handle encode error with "backslashreplace".
+- bpo-1729305: Fix doctest to handle encode error with "backslashreplace".
 
-- Issue #691291: ``codecs.open()`` should not convert end of lines on reading
+- bpo-691291: ``codecs.open()`` should not convert end of lines on reading
   and writing.
 
-- Issue #7975: Correct regression in dict methods supported by bsddb.dbshelve.
+- bpo-7975: Correct regression in dict methods supported by bsddb.dbshelve.
 
-- Issue #7959: ctypes callback functions are now registered correctly with the
+- bpo-7959: ctypes callback functions are now registered correctly with the
   cycle garbage collector.
 
-- Issue #7970: ``email.Generator.flatten`` now correctly flattens
+- bpo-7970: ``email.Generator.flatten`` now correctly flattens
   message/rfc822 messages parsed by ``email.Parser.HeaderParser``.
 
-- Issue #3426: ``os.path.abspath`` now returns unicode when its arg is unicode.
+- bpo-3426: ``os.path.abspath`` now returns unicode when its arg is unicode.
 
-- Issue #7633: In the decimal module, ``Context`` class methods (with the
-  exception of canonical and is_canonical) now accept instances of int and long
-  wherever a Decimal instance is accepted, and implicitly convert that argument
-  to Decimal.  Previously only some arguments were converted.
+- bpo-7633: In the decimal module, ``Context`` class methods (with the
+  exception of canonical and is_canonical) now accept instances of int and
+  long wherever a Decimal instance is accepted, and implicitly convert that
+  argument to Decimal.  Previously only some arguments were converted.
 
-- Issue #6003: Add an argument to ``zipfile.Zipfile.writestr`` to specify the
+- bpo-6003: Add an argument to ``zipfile.Zipfile.writestr`` to specify the
   compression type.
 
-- Issue #7893: ``unittest.TextTestResult`` is made public and a ``resultclass``
-  argument added to the TextTestRunner constructor allowing a different result
-  class to be used without having to subclass.
+- bpo-7893: ``unittest.TextTestResult`` is made public and a ``resultclass``
+  argument added to the TextTestRunner constructor allowing a different
+  result class to be used without having to subclass.
 
-- Issue #7588: ``unittest.TextTestResult.getDescription`` now includes the test
+- bpo-7588: ``unittest.TextTestResult.getDescription`` now includes the test
   name in failure reports even if the test has a docstring.
 
-- Issue #5801: Remove spurious empty lines in wsgiref.
+- bpo-5801: Remove spurious empty lines in wsgiref.
 
-- Issue #1537721: Add a ``writeheader()`` method to ``csv.DictWriter``.
+- bpo-1537721: Add a ``writeheader()`` method to ``csv.DictWriter``.
 
-- Issue #7427: Improve the representation of httplib.BadStatusLine exceptions.
+- bpo-7427: Improve the representation of httplib.BadStatusLine exceptions.
 
-- Issue #7481: When a ``threading.Thread`` failed to start it would leave the
+- bpo-7481: When a ``threading.Thread`` failed to start it would leave the
   instance stuck in initial state and present in ``threading.enumerate()``.
 
-- Issue #1068268: The subprocess module now handles EINTR in internal
+- bpo-1068268: The subprocess module now handles EINTR in internal
   ``os.waitpid()`` and ``os.read()`` system calls where appropriate.
 
-- Issue #6729: Add ``ctypes.c_ssize_t`` to represent ssize_t.
+- bpo-6729: Add ``ctypes.c_ssize_t`` to represent ssize_t.
 
-- Issue #6247: The argparse module has been added to the standard library.
-
-Extension Modules
------------------
+- bpo-6247: The argparse module has been added to the standard library.
 
-- The sqlite3 module was updated to pysqlite 2.6.0.  This fixes several obscure
-  bugs and allows loading SQLite extensions from shared libraries.
+- The sqlite3 module was updated to pysqlite 2.6.0.  This fixes several
+  obscure bugs and allows loading SQLite extensions from shared libraries.
 
-- Issue #7808: Fix reference leaks in _bsddb and related tests.
+- bpo-7808: Fix reference leaks in _bsddb and related tests.
 
-- Issue #6544: Fix a reference leak in the kqueue implementation's error
+- bpo-6544: Fix a reference leak in the kqueue implementation's error
   handling.
 
-- Stop providing crtassem.h symbols when compiling with Visual Studio 2010, as
-  msvcr100.dll is not a platform assembly anymore.
+- Stop providing crtassem.h symbols when compiling with Visual Studio 2010,
+  as msvcr100.dll is not a platform assembly anymore.
 
-- Issue #7242: On Solaris 9 and earlier calling ``os.fork()`` from within a
+- bpo-7242: On Solaris 9 and earlier calling ``os.fork()`` from within a
   thread could raise an incorrect RuntimeError about not holding the import
   lock.  The import lock is now reinitialized after fork.
 
-- Issue #7999: ``os.setreuid()`` and ``os.setregid()`` would refuse to accept a
+- bpo-7999: ``os.setreuid()`` and ``os.setregid()`` would refuse to accept a
   -1 parameter on some platforms such as OS X.
 
 Tests
 -----
 
-- Issue #7849: The utility ``test.test_support.check_warnings()`` verifies if
-  warnings are effectively raised.  A new utility ``check_py3k_warnings()`` is
-  available.
+- bpo-7849: The utility ``test.test_support.check_warnings()`` verifies if
+  warnings are effectively raised.  A new utility ``check_py3k_warnings()``
+  is available.
 
 - The four path modules (genericpath, macpath, ntpath, posixpath) share a
   common TestCase for some tests: test_genericpath.CommonTest.
@@ -7177,21 +7598,22 @@ Tests
 - Print platform information when running the whole test suite, or using the
   ``--verbose`` flag.
 
-- Issue #767675: Enable test_pep277 on POSIX platforms with Unicode-friendly
+- bpo-767675: Enable test_pep277 on POSIX platforms with Unicode-friendly
   filesystem encoding.
 
-- Issue #6292: For the moment at least, the test suite runs cleanly if python
+- bpo-6292: For the moment at least, the test suite runs cleanly if python
   is run with the -OO flag.  Tests requiring docstrings are skipped.
 
-- Issue #7712: test_support gained a new ``temp_cwd`` context manager which is
-  now also used by regrtest to run all the tests in a temporary directory.  The
-  original CWD is saved in ``test.test_support.SAVEDCWD``.  Thanks to Florent
-  Xicluna who helped with the patch.
+- bpo-7712: test_support gained a new ``temp_cwd`` context manager which is
+  now also used by regrtest to run all the tests in a temporary directory.
+  The original CWD is saved in ``test.test_support.SAVEDCWD``.  Thanks to
+  Florent Xicluna who helped with the patch.
 
 Build
 -----
 
-- Issue #3920, #7903: Define _BSD_SOURCE on OpenBSD 4.4 through 4.9.
+- bpo-3920: Define _BSD_SOURCE on OpenBSD 4.4 through 4.9. (See also:
+  bpo-7903)
 
 
 What's New in Python 2.7 alpha 3?
@@ -7202,132 +7624,130 @@ What's New in Python 2.7 alpha 3?
 Core and Builtins
 -----------------
 
-- Issue #5677: Explicitly forbid write operations on read-only file objects,
+- bpo-5677: Explicitly forbid write operations on read-only file objects,
   and read operations on write-only file objects.  On Windows, the system C
-  library would return a bogus result; on Solaris, it was possible to crash the
-  interpreter.  Patch by Stefan Krah.
+  library would return a bogus result; on Solaris, it was possible to crash
+  the interpreter.  Patch by Stefan Krah.
 
-- Issue #7853: Normalize exceptions before they are passed to a context
+- bpo-7853: Normalize exceptions before they are passed to a context
   manager's ``__exit__()`` method.
 
-- Issue #7385: Fix a crash in ``PyMemoryView_FromObject()`` when
+- bpo-7385: Fix a crash in ``PyMemoryView_FromObject()`` when
   ``PyObject_GetBuffer()`` fails.  Patch by Florent Xicluna.
 
-- Issue #7819: Check ``sys.call_tracing()`` arguments types.
+- bpo-7819: Check ``sys.call_tracing()`` arguments types.
 
-- Issue #7788: Fix an interpreter crash produced by deleting a list slice with
+- bpo-7788: Fix an interpreter crash produced by deleting a list slice with
   very large step value.
 
-- Issue #7766: Change ``sys.getwindowsversion()`` return value to a named tuple
-  and add the additional members returned in an OSVERSIONINFOEX structure.  The
-  new members are service_pack_major, service_pack_minor, suite_mask, and
-  product_type.
+- bpo-7766: Change ``sys.getwindowsversion()`` return value to a named tuple
+  and add the additional members returned in an OSVERSIONINFOEX structure.
+  The new members are service_pack_major, service_pack_minor, suite_mask,
+  and product_type.
 
-- Issue #7561: Operations on empty bytearrays (such as ``int(bytearray())``)
-  could crash in many places because of the ``PyByteArray_AS_STRING()`` macro
-  returning NULL.  The macro now returns a statically allocated empty string
-  instead.
+- bpo-7561: Operations on empty bytearrays (such as ``int(bytearray())``)
+  could crash in many places because of the ``PyByteArray_AS_STRING()``
+  macro returning NULL. The macro now returns a statically allocated empty
+  string instead.
 
-- Issue #7622: Improve the split(), rsplit(), splitlines() and replace()
+- bpo-7622: Improve the split(), rsplit(), splitlines() and replace()
   methods of bytes, bytearray and unicode objects by using a common
-  implementation based on stringlib's fast search.  Patch by Florent Xicluna.
+  implementation based on stringlib's fast search.  Patch by Florent
+  Xicluna.
 
-- Issue #7632: Fix various str -> float conversion bugs present in 2.7 alpha 2,
+- bpo-7632: Fix various str -> float conversion bugs present in 2.7 alpha 2,
   including:
 
-  (1) a serious 'wrong output' bug that could occur for long (> 40 digit) input
-      strings,
-  (2) a crash in dtoa.c that occurred in debug builds when parsing certain long
-      numeric strings corresponding to subnormal values,
-  (3) a memory leak for some values large enough to cause overflow, and
-  (4) a number of flaws that could lead to incorrectly rounded results.
+  (1) a serious 'wrong output' bug that could occur for long (> 40 digit)
+  input     strings, (2) a crash in dtoa.c that occurred in debug builds
+  when parsing certain long     numeric strings corresponding to subnormal
+  values, (3) a memory leak for some values large enough to cause overflow,
+  and (4) a number of flaws that could lead to incorrectly rounded results.
 
-- Issue #7319, #7770: Silence ``DeprecationWarning`` by default when the -3
-  option is not used.
+- bpo-7319: Silence ``DeprecationWarning`` by default when the -3 option is
+  not used. (See also: bpo-7770)
 
-- Issue #2335: Backport set literals syntax from Python 3.x.
+- bpo-2335: Backport set literals syntax from Python 3.x.
 
-- Issue #2333: Backport set and dict comprehensions syntax from Python 3.x.
+- bpo-2333: Backport set and dict comprehensions syntax from Python 3.x.
 
-- Issue #1967: Backport dictionary views from Python 3.x.
+- bpo-1967: Backport dictionary views from Python 3.x.
 
 Library
 -------
 
-- Issue #9137: Fix issue in MutableMapping.update, which incorrectly
-  treated keyword arguments called 'self' or 'other' specially.
+- bpo-9137: Fix issue in MutableMapping.update, which incorrectly treated
+  keyword arguments called 'self' or 'other' specially.
 
-- Issue #7835: shelve should no longer produce mysterious warnings during
+- bpo-7835: shelve should no longer produce mysterious warnings during
   interpreter shutdown.
 
-- Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">") in
-  XML processing instructions and comments.  These raw characters are allowed
-  by the XML specification, and are necessary when outputting e.g.  PHP code in
-  a processing instruction.  Patch by Neil Muller.
+- bpo-2746: Don't escape ampersands and angle brackets ("&", "<", ">") in
+  XML processing instructions and comments.  These raw characters are
+  allowed by the XML specification, and are necessary when outputting e.g.
+  PHP code in a processing instruction.  Patch by Neil Muller.
 
-- Issue #7869: logging: Improved diagnostic for format-time errors.
+- bpo-7869: logging: Improved diagnostic for format-time errors.
 
-- Issue #7868: logging: Added loggerClass attribute to Manager.
+- bpo-7868: logging: Added loggerClass attribute to Manager.
 
-- Issue #7851: logging: Clarification on logging configuration files.
+- bpo-7851: logging: Clarification on logging configuration files.
 
-- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is
-  specified, rather than fall through to AF_PACKET (in the ``socket`` module).
-  Also, raise ValueError rather than TypeError when an unknown TIPC address
-  type is specified.  Patch by Brian Curtin.
+- bpo-4772: Raise a ValueError when an unknown Bluetooth protocol is
+  specified, rather than fall through to AF_PACKET (in the ``socket``
+  module). Also, raise ValueError rather than TypeError when an unknown TIPC
+  address type is specified.  Patch by Brian Curtin.
 
 - logging: Implemented PEP 391.
 
-- Issue #6939: Fix file I/O objects in the `io` module to keep the original
-  file position when calling `truncate()`.  It would previously change the file
-  position to the given argument, which goes against the tradition of
+- bpo-6939: Fix file I/O objects in the `io` module to keep the original
+  file position when calling `truncate()`.  It would previously change the
+  file position to the given argument, which goes against the tradition of
   ftruncate() and other truncation APIs.  Patch by Pascal Chambon.
 
-- Issue #7610: Reworked implementation of the internal ``zipfile.ZipExtFile``
+- bpo-7610: Reworked implementation of the internal ``zipfile.ZipExtFile``
   class used to represent files stored inside an archive.  The new
   implementation is significantly faster and can be wrapped in an
   ``io.BufferedReader`` object for more speedups.  It also solves an issue
-  where interleaved calls to ``read()`` and ``readline()`` give wrong results.
-  Patch by Nir Aides.
+  where interleaved calls to ``read()`` and ``readline()`` give wrong
+  results. Patch by Nir Aides.
 
-- Issue #7792: Registering non-classes to ABCs raised an obscure error.
+- bpo-7792: Registering non-classes to ABCs raised an obscure error.
 
 - Removed the deprecated functions ``verify()`` and ``vereq()`` from
   Lib/test/test_support.py.
 
-- Issue #7773: Fix an UnboundLocalError in ``platform.linux_distribution()``
+- bpo-7773: Fix an UnboundLocalError in ``platform.linux_distribution()``
   when the release file is empty.
 
-- Issue #7748: Since unicode values are supported for some metadata options in
+- bpo-7748: Since unicode values are supported for some metadata options in
   Distutils, the DistributionMetadata get_* methods will now return a utf-8
-  encoded string for them.  This ensures that the upload and register commands
-  send the correct values to PyPI without any error.
+  encoded string for them.  This ensures that the upload and register
+  commands send the correct values to PyPI without any error.
 
-- Issue #1670765: Prevent ``email.generator.Generator`` from re-wrapping
+- bpo-1670765: Prevent ``email.generator.Generator`` from re-wrapping
   headers in multipart/signed MIME parts, which fixes one of the sources of
   invalid modifications to such parts by Generator.
 
-- Issue #7701: Fix crash in ``binascii.b2a_uu()`` in debug mode when given a
+- bpo-7701: Fix crash in ``binascii.b2a_uu()`` in debug mode when given a
   1-byte argument.  Patch by Victor Stinner.
 
-- Issue #3299: Fix possible crash in the _sre module when given bad argument
+- bpo-3299: Fix possible crash in the _sre module when given bad argument
   values in debug mode.  Patch by Victor Stinner.
 
-- Issue #7703: Add support for the new buffer API to functions of the binascii
-  module.  Backported from py3k by Florent Xicluna, with some additional tests.
+- bpo-7703: Add support for the new buffer API to functions of the binascii
+  module. Backported from py3k by Florent Xicluna, with some additional
+  tests.
 
-- Issue #2846: Add support for gzip.GzipFile reading zero-padded files.  Patch
+- bpo-2846: Add support for gzip.GzipFile reading zero-padded files.  Patch
   by Brian Curtin.
 
-- Issue #5827: Make sure that normpath preserves unicode.  Initial patch by
+- bpo-5827: Make sure that normpath preserves unicode.  Initial patch by
   Matt Giuca.
 
-- Issue #5372: Drop the reuse of .o files in Distutils' ccompiler (since
-  Extension extra options may change the output without changing the .c file).
-  Initial patch by Collin Winter.
-
-Extension Modules
------------------
+- bpo-5372: Drop the reuse of .o files in Distutils' ccompiler (since
+  Extension extra options may change the output without changing the .c
+  file). Initial patch by Collin Winter.
 
 - Expat: Fix DoS via XML document with malformed UTF-8 sequences
   (CVE_2009_3560).
@@ -7335,17 +7755,16 @@ Extension Modules
 Build
 -----
 
-- Issue #7632: When Py_USING_MEMORY_DEBUGGER is defined, disable the private
+- bpo-7632: When Py_USING_MEMORY_DEBUGGER is defined, disable the private
   memory allocation scheme in dtoa.c and use PyMem_Malloc and PyMem_Free
-  instead.  Also disable caching of powers of 5.
+  instead. Also disable caching of powers of 5.
 
-- Issue #7658: Ensure that the new pythonw executable works on OSX 10.4
+- bpo-7658: Ensure that the new pythonw executable works on OSX 10.4
 
-- Issue #7714: Use ``gcc -dumpversion`` to detect the version of GCC on
-  MacOSX.
+- bpo-7714: Use ``gcc -dumpversion`` to detect the version of GCC on MacOSX.
 
-- Issue #7661: Allow ctypes to be built from a non-ASCII directory path.
-  Patch by Florent Xicluna.
+- bpo-7661: Allow ctypes to be built from a non-ASCII directory path. Patch
+  by Florent Xicluna.
 
 Tools/Demos
 -----------
@@ -7357,14 +7776,14 @@ Tools/Demos
 Tests
 -----
 
-- Issue #7728: test_timeout was changed to use ``test_support.bind_port()``
+- bpo-7728: test_timeout was changed to use ``test_support.bind_port()``
   instead of a hard coded port.
 
 Documentation
 -------------
 
-- Updated "Using Python" documentation to include description of CPython's -J,
-  -U and -X options.
+- Updated "Using Python" documentation to include description of CPython's
+  -J, -U and -X options.
 
 - Updated Python manual page (options -B, -O0, -s, environment variables
   PYTHONDONTWRITEBYTECODE, PYTHONNOUSERSITE).
@@ -7381,184 +7800,187 @@ Core and Builtins
 - The ``__complex__()`` method is now looked up on the class of instances to
   make it consistent with other special methods.
 
-- Issue #7462: Implement the stringlib fast search algorithm for the `rfind`,
+- bpo-7462: Implement the stringlib fast search algorithm for the `rfind`,
   `rindex`, `rsplit` and `rpartition` methods.  Patch by Florent Xicluna.
 
-- Issue #5080: A number of functions and methods previously produced a
-  DeprecationWarning when passed a float argument where an integer was expected.
-  These functions and methods now raise TypeError instead.  The majority of the
-  effects of this change are in the extension modules, but some core functions
-  and methods are affected: notably the 'chr', 'range' and 'xrange' builtins,
-  and many unicode/str methods.
+- bpo-5080: A number of functions and methods previously produced a
+  DeprecationWarning when passed a float argument where an integer was
+  expected. These functions and methods now raise TypeError instead.  The
+  majority of the effects of this change are in the extension modules, but
+  some core functions and methods are affected: notably the 'chr', 'range'
+  and 'xrange' builtins, and many unicode/str methods.
 
-- Issue #7604: Deleting an unset slotted attribute did not raise an
+- bpo-7604: Deleting an unset slotted attribute did not raise an
   AttributeError.
 
-- Issue #7534: Fix handling of IEEE specials (infinities, nans, negative zero)
-  in ** operator.  The behaviour now conforms to that described in C99 Annex F.
+- bpo-7534: Fix handling of IEEE specials (infinities, nans, negative zero)
+  in ** operator.  The behaviour now conforms to that described in C99 Annex
+  F.
 
-- Issue #7579: The msvcrt module now has docstrings for all its functions.
+- bpo-7579: The msvcrt module now has docstrings for all its functions.
 
-- Issue #7413: Passing '\0' as the separator to datetime.datetime.isoformat()
+- bpo-7413: Passing '\0' as the separator to datetime.datetime.isoformat()
   used to drop the time part of the result.
 
-- Issue #1811: Improve accuracy and cross-platform consistency for true division
-  of integers: the result of a/b is now correctly rounded for ints a and b (at
-  least on IEEE 754 platforms), and in particular does not depend on the
-  internal representation of a long.
+- bpo-1811: Improve accuracy and cross-platform consistency for true
+  division of integers: the result of a/b is now correctly rounded for ints
+  a and b (at least on IEEE 754 platforms), and in particular does not
+  depend on the internal representation of a long.
 
-- Issue #6108: ``unicode(exception)`` and ``str(exception)`` should return the
-  same message when only ``__str__()`` (and not ``__unicode__()``) is overridden
-  in the subclass.
+- bpo-6108: ``unicode(exception)`` and ``str(exception)`` should return the
+  same message when only ``__str__()`` (and not ``__unicode__()``) is
+  overridden in the subclass.
 
-- Issue #6834: Replace the implementation for the 'python' and 'pythonw'
+- bpo-6834: Replace the implementation for the 'python' and 'pythonw'
   executables on OSX.
 
   These executables now work properly with the arch(1) command: ``arch -ppc
-  python`` will start a universal binary version of python in PPC mode (unlike
-  previous releases).
+  python`` will start a universal binary version of python in PPC mode
+  (unlike previous releases).
 
-- Issue #1680159: Unicode coercion during an 'in' operation no longer masks the
+- bpo-1680159: Unicode coercion during an 'in' operation no longer masks the
   underlying error when the coercion fails for the left hand operand.
 
-- Issue #7491: Metaclass's __cmp__ method was ignored.
+- bpo-7491: Metaclass's __cmp__ method was ignored.
 
-- Issue #7466: Segmentation fault when the garbage collector is called in the
+- bpo-7466: Segmentation fault when the garbage collector is called in the
   middle of populating a tuple.  Patch by Florent Xicluna.
 
 Library
 -------
 
-- Issue #6963: Added "maxtasksperchild" argument to ``multiprocessing.Pool``,
-  allowing for a maximum number of tasks within the pool to be completed by the
-  worker before that worker is terminated, and a new one created to replace it.
+- bpo-6963: Added "maxtasksperchild" argument to ``multiprocessing.Pool``,
+  allowing for a maximum number of tasks within the pool to be completed by
+  the worker before that worker is terminated, and a new one created to
+  replace it.
 
-- Issue #7617: Make sure distutils.unixccompiler.UnixCCompiler recognizes gcc
+- bpo-7617: Make sure distutils.unixccompiler.UnixCCompiler recognizes gcc
   when it has a fully qualified configuration prefix.  Initial patch by
   Arfrever.
 
-- Issue #7092: Remove py3k warning when importing cPickle.  2to3 handles
-  renaming of `cPickle` to `pickle`.  The warning was annoying since there's no
-  alternative to cPickle if you care about performance.  Patch by Florent
+- bpo-7092: Remove py3k warning when importing cPickle.  2to3 handles
+  renaming of `cPickle` to `pickle`.  The warning was annoying since there's
+  no alternative to cPickle if you care about performance.  Patch by Florent
   Xicluna.
 
-- Issue #7455: Fix possible crash in cPickle on invalid input.  Patch by Victor
+- bpo-7455: Fix possible crash in cPickle on invalid input.  Patch by Victor
   Stinner.
 
-- Issue #7092: Fix the DeprecationWarnings emitted by the standard library when
+- bpo-7092: Fix the DeprecationWarnings emitted by the standard library when
   using the -3 flag.  Patch by Florent Xicluna.
 
-- Issue #7471: Improve the performance of GzipFile's buffering mechanism, and
-  make it implement the ``io.BufferedIOBase`` ABC to allow for further speedups
-  by wrapping it in an ``io.BufferedReader``.  Patch by Nir Aides.
+- bpo-7471: Improve the performance of GzipFile's buffering mechanism, and
+  make it implement the ``io.BufferedIOBase`` ABC to allow for further
+  speedups by wrapping it in an ``io.BufferedReader``.  Patch by Nir Aides.
 
-- Issue #3972: ``httplib.HTTPConnection`` now accepts an optional source_address
-  parameter to allow specifying where your connections come from.
+- bpo-3972: ``httplib.HTTPConnection`` now accepts an optional
+  source_address parameter to allow specifying where your connections come
+  from.
 
 - ``socket.create_connection()`` now accepts an optional source_address
   parameter.
 
-- Issue #5511: ``zipfile.ZipFile`` can now be used as a context manager.
+- bpo-5511: ``zipfile.ZipFile`` can now be used as a context manager.
   Initial patch by Brian Curtin.
 
 - Distutils now correctly identifies the build architecture as "x86_64" when
   building on OSX 10.6 without "-arch" flags.
 
-- Issue #7556: Distutils' msvc9compiler now opens the MSVC Manifest file in text
-  mode.
+- bpo-7556: Distutils' msvc9compiler now opens the MSVC Manifest file in
+  text mode.
 
-- Issue #7552: Removed line feed in the base64 Authorization header in the
-  Distutils upload command to avoid an error when PyPI reads it.  This occurs on
-  long passwords.  Initial patch by JP St. Pierre.
+- bpo-7552: Removed line feed in the base64 Authorization header in the
+  Distutils upload command to avoid an error when PyPI reads it.  This
+  occurs on long passwords.  Initial patch by JP St. Pierre.
 
-- Issue #7231: urllib2 cannot handle https with proxy requiring auth.  Patch by
+- bpo-7231: urllib2 cannot handle https with proxy requiring auth.  Patch by
   Tatsuhiro Tsujikawa.
 
-- Issue #7349: Make methods of file objects in the io module accept None as an
-  argument where file-like objects (ie StringIO and BytesIO) accept them to mean
-  the same as passing no argument.
+- bpo-7349: Make methods of file objects in the io module accept None as an
+  argument where file-like objects (ie StringIO and BytesIO) accept them to
+  mean the same as passing no argument.
 
-- Issue #7348: ``StringIO.StringIO.readline(-1)`` now acts as if it got no
+- bpo-7348: ``StringIO.StringIO.readline(-1)`` now acts as if it got no
   argument like other file objects.
 
-- Issue #7357: tarfile no longer suppresses fatal extraction errors by default.
+- bpo-7357: tarfile no longer suppresses fatal extraction errors by default.
 
-- Issue #7470: logging: Fix bug in Unicode encoding fallback.
+- bpo-7470: logging: Fix bug in Unicode encoding fallback.
 
-- Issue #5949: Fixed IMAP4_SSL hang when the IMAP server response is missing
-  proper end-of-line termination.
+- bpo-5949: Fixed IMAP4_SSL hang when the IMAP server response is missing
+  proper end-of- line termination.
 
-- Issue #7457: Added a read_pkg_file method to
+- bpo-7457: Added a read_pkg_file method to
   ``distutils.dist.DistributionMetadata``.
 
-- Issue #3745: Undo the 2.7a1 change to have hashlib to reject unicode and non
+- bpo-3745: Undo the 2.7a1 change to have hashlib to reject unicode and non
   buffer API supporting objects as input.  That behavior is for 3.x only.
 
-C-API
+C API
 -----
 
-- Issue #7767: New function ``PyLong_AsLongLongAndOverflow()`` added, analogous
+- bpo-7767: New function ``PyLong_AsLongLongAndOverflow()`` added, analogous
   to ``PyLong_AsLongAndOverflow()``.
 
-- Issue #5080: The argument parsing functions ``PyArg_ParseTuple()``,
+- bpo-5080: The argument parsing functions ``PyArg_ParseTuple()``,
   ``PyArg_ParseTupleAndKeywords()``, ``PyArg_VaParse()``,
   ``PyArg_VaParseTupleAndKeywords()`` and ``PyArg_Parse()`` no longer accept
   float arguments for integer format codes (other than 'L'): previously an
   attempt to pass a float resulted in a DeprecationWarning; now it gives a
-  TypeError.  For the 'L' format code (which previously had no warning) there is
-  now a DeprecationWarning.
+  TypeError.  For the 'L' format code (which previously had no warning)
+  there is now a DeprecationWarning.
 
-- Issue #7033: Function ``PyErr_NewExceptionWithDoc()`` added.
+- bpo-7033: Function ``PyErr_NewExceptionWithDoc()`` added.
 
 Build
 -----
 
-- Issue #6491: Allow --with-dbmliborder to specify that no dbms will be built.
+- bpo-6491: Allow --with-dbmliborder to specify that no dbms will be built.
 
-- Issue #6943: Use pkg-config to find the libffi headers when the
-  ``--with-system-ffi`` flag is used.
+- bpo-6943: Use pkg-config to find the libffi headers when the ``--with-
+  system-ffi`` flag is used.
 
-- Issue #7609: Add a ``--with-system-expat`` option that causes the system's
-  expat library to be used for the pyexpat module instead of the one included
-  with Python.
+- bpo-7609: Add a ``--with-system-expat`` option that causes the system's
+  expat library to be used for the pyexpat module instead of the one
+  included with Python.
 
-- Issue #7589: Only build the nis module when the correct header files are
+- bpo-7589: Only build the nis module when the correct header files are
   found.
 
 - Switch to OpenSSL 0.9.8l and sqlite 3.6.21 on Windows.
 
-- Issue #7541: when using ``python-config`` with a framework install the
+- bpo-7541: when using ``python-config`` with a framework install the
   compiler might use the wrong library.
 
 Tests
 -----
 
-- Issue #7376: Instead of running a self-test (which was failing) when called
+- bpo-7376: Instead of running a self-test (which was failing) when called
   with no arguments, doctest.py now gives a usage message.
 
-- Issue #7396: Fix regrtest -s, which was broken by the -j enhancement.
+- bpo-7396: Fix regrtest -s, which was broken by the -j enhancement.
 
-- Issue #7498: test_multiprocessing now uses test_support.find_unused_port
+- bpo-7498: test_multiprocessing now uses test_support.find_unused_port
   instead of a hardcoded port number in test_rapid_restart.
 
 
-What's New in Python 2.7 alpha 1
-================================
+What's New in Python 2.7 alpha 1?
+=================================
 
 *Release date: 2009-12-05*
 
 Core and Builtins
 -----------------
 
-- Issue #7419: ``locale.setlocale()`` could crash the interpreter on Windows
+- bpo-7419: ``locale.setlocale()`` could crash the interpreter on Windows
   when called with invalid values.
 
-- Issue #3382: 'F' formatting for float and complex now convert the result to
-  upper case.  This only affects 'inf' and 'nan', since 'f' no longer converts
-  to 'g' for large values.
+- bpo-3382: 'F' formatting for float and complex now convert the result to
+  upper case. This only affects 'inf' and 'nan', since 'f' no longer
+  converts to 'g' for large values.
 
-- Remove switch from "%f" formatting to "%g" formatting for floats larger than
-  1e50 in absolute value.
+- Remove switch from "%f" formatting to "%g" formatting for floats larger
+  than 1e50 in absolute value.
 
 - Remove restrictions on precision when formatting floats.  E.g., "%.120g" %
   1e-100 used to raise OverflowError, but now gives the requested 120
@@ -7566,461 +7988,470 @@ Core and Builtins
 
 - Add Py3k warnings for parameter names in parentheses.
 
-- Issue #7362: Give a proper error message for ``def f((x)=3): pass``.
+- bpo-7362: Give a proper error message for ``def f((x)=3): pass``.
 
-- Issue #7085: Fix crash when importing some extensions in a thread on MacOSX
+- bpo-7085: Fix crash when importing some extensions in a thread on MacOSX
   10.6.
 
-- Issue #7117: ``repr(x)`` for a float x returns a result based on the shortest
+- bpo-7117: ``repr(x)`` for a float x returns a result based on the shortest
   decimal string that's guaranteed to round back to x under correct rounding
-  (with round-half-to-even rounding mode).  Previously it gave a string based on
-  rounding x to 17 decimal digits.  repr(x) for a complex number behaves
-  similarly.  On platforms where the correctly-rounded strtod and dtoa code is
-  not supported (see below), repr is unchanged.
-
-- Issue #7117: On almost all platforms: float-to-string and string-to-float
-  conversions within Python are now correctly rounded.  Places these conversions
-  occur include: str for floats and complex numbers; the float and complex
-  constructors; old-style and new-style numeric formatting; serialization and
-  deserialization of floats and complex numbers using marshal, pickle and json;
-  parsing of float and imaginary literals in Python code; Decimal-to-float
-  conversion.
-
-  The conversions use a Python-adapted version of David Gay's well-known dtoa.c,
-  providing correctly-rounded strtod and dtoa C functions.  This code is
-  supported on Windows, and on Unix-like platforms using gcc, icc or suncc as
-  the C compiler.  There may be a small number of platforms on which correct
-  operation of this code cannot be guaranteed, so the code is not used: notably,
-  this applies to platforms where the C double format is not IEEE 754 binary64,
-  and to platforms on x86 hardware where the x87 FPU is set to 64-bit precision
-  and Python's configure script is unable to determine how to change the FPU
-  precision.  On these platforms conversions use the platform strtod and dtoa,
-  as before.
-
-- Issue #7117: Backport round implementation from Python 3.x.  ``round()`` now
-  uses the correctly-rounded string <-> float conversions described above (when
-  available), and so produces correctly rounded results that will display nicely
-  under the float repr.  There are two related small changes: (1) round now
-  accepts any class with an ``__index__()`` method for its second argument (but
-  no longer accepts floats for the second argument), and (2) an excessively
-  large second integer argument (e.g., ``round(1.234, 10**100)``) no longer
-  raises an exception.
-
-- Issue #1757126: Fix the cyrillic-asian alias for the ptcp154 encoding.
-
-- Fix several issues with ``compile()``.  The input can now contain Windows and
-  Mac newlines and is no longer required to end in a newline.
+  (with round-half-to-even rounding mode).  Previously it gave a string
+  based on rounding x to 17 decimal digits.  repr(x) for a complex number
+  behaves similarly.  On platforms where the correctly-rounded strtod and
+  dtoa code is not supported (see below), repr is unchanged.
+
+- bpo-7117: On almost all platforms: float-to-string and string-to-float
+  conversions within Python are now correctly rounded.  Places these
+  conversions occur include: str for floats and complex numbers; the float
+  and complex constructors; old-style and new-style numeric formatting;
+  serialization and deserialization of floats and complex numbers using
+  marshal, pickle and json; parsing of float and imaginary literals in
+  Python code; Decimal-to- float conversion.
+
+  The conversions use a Python-adapted version of David Gay's well-known
+  dtoa.c, providing correctly-rounded strtod and dtoa C functions.  This
+  code is supported on Windows, and on Unix-like platforms using gcc, icc or
+  suncc as the C compiler.  There may be a small number of platforms on
+  which correct operation of this code cannot be guaranteed, so the code is
+  not used: notably, this applies to platforms where the C double format is
+  not IEEE 754 binary64, and to platforms on x86 hardware where the x87 FPU
+  is set to 64-bit precision and Python's configure script is unable to
+  determine how to change the FPU precision.  On these platforms conversions
+  use the platform strtod and dtoa, as before.
+
+- bpo-7117: Backport round implementation from Python 3.x.  ``round()`` now
+  uses the correctly-rounded string <-> float conversions described above
+  (when available), and so produces correctly rounded results that will
+  display nicely under the float repr.  There are two related small changes:
+  (1) round now accepts any class with an ``__index__()`` method for its
+  second argument (but no longer accepts floats for the second argument),
+  and (2) an excessively large second integer argument (e.g., ``round(1.234,
+  10**100)``) no longer raises an exception.
+
+- bpo-1757126: Fix the cyrillic-asian alias for the ptcp154 encoding.
+
+- Fix several issues with ``compile()``.  The input can now contain Windows
+  and Mac newlines and is no longer required to end in a newline.
 
 - Remove length limitation when constructing a complex number from a unicode
   string.
 
-- Issue #7244: ``itertools.izip_longest()`` no longer ignores exceptions raised
+- bpo-7244: ``itertools.izip_longest()`` no longer ignores exceptions raised
   during the formation of an output tuple.
 
-- Issue #1087418: Boost performance of bitwise operations for longs.
+- bpo-1087418: Boost performance of bitwise operations for longs.
 
-- Issue #1722344: ``threading._shutdown()`` is now called in ``Py_Finalize()``,
-  which fixes the problem of some exceptions being thrown at shutdown when the
-  interpreter is killed.  Patch by Adam Olsen.
+- bpo-1722344: ``threading._shutdown()`` is now called in ``Py_Finalize()``,
+  which fixes the problem of some exceptions being thrown at shutdown when
+  the interpreter is killed.  Patch by Adam Olsen.
 
-- Issue #7168: Document ``PyFloat_AsString()`` and ``PyFloat_AsReprString()``,
+- bpo-7168: Document ``PyFloat_AsString()`` and ``PyFloat_AsReprString()``,
   and note that they are unsafe and deprecated.
 
-- Issue #7120: logging: Remove import of multiprocessing which is causing crash
+- bpo-7120: logging: Remove import of multiprocessing which is causing crash
   in GAE.
 
-- Issue #7140: The ``__dict__`` of a module should not be cleared unless the
+- bpo-7140: The ``__dict__`` of a module should not be cleared unless the
   module is the only object holding a reference to it.
 
-- Issue #1754094: Improve the stack depth calculation in the compiler.  There
+- bpo-1754094: Improve the stack depth calculation in the compiler.  There
   should be no other effect than a small decrease in memory use.  Patch by
   Christopher Tur Lesniewski-Laas.
 
-- Issue #7084: Fix a (very unlikely) crash when printing a list from one thread,
-  and mutating it from another one.  Patch by Scott Dial.
+- bpo-7084: Fix a (very unlikely) crash when printing a list from one
+  thread, and mutating it from another one.  Patch by Scott Dial.
 
-- Issue #1571184: The Unicode database contains properties for more characters.
-  The tables for code points representing numeric values, white spaces or line
-  breaks are now generated from the official Unicode Character Database files,
-  and include information from the Unihan.txt file.
+- bpo-1571184: The Unicode database contains properties for more characters.
+  The tables for code points representing numeric values, white spaces or
+  line breaks are now generated from the official Unicode Character Database
+  files, and include information from the Unihan.txt file.
 
-- Issue #7050: Fix a SystemError when trying to use unpacking and augmented
+- bpo-7050: Fix a SystemError when trying to use unpacking and augmented
   assignment.
 
-- Issue #5329: Fix ``os.popen*`` regression from 2.5 with commands as a sequence
-  running through the shell.  Patch by Jean-Paul Calderone and Jani Hakala.
+- bpo-5329: Fix ``os.popen*`` regression from 2.5 with commands as a
+  sequence running through the shell.  Patch by Jean-Paul Calderone and Jani
+  Hakala.
 
-- Issue #7019: Raise ValueError when unmarshalling bad long data, instead of
+- bpo-7019: Raise ValueError when unmarshalling bad long data, instead of
   producing internally inconsistent Python longs.
 
-- Issue #6990: Fix ``threading.local`` subclasses leaving old state around after
-  a reference cycle GC which could be recycled by new locals.
+- bpo-6990: Fix ``threading.local`` subclasses leaving old state around
+  after a reference cycle GC which could be recycled by new locals.
 
-- Issue #6300: unicode.encode, unicode.decode, str.decode, and str.encode now
+- bpo-6300: unicode.encode, unicode.decode, str.decode, and str.encode now
   take keyword arguments.
 
-- Issue #6922: Fix an infinite loop when trying to decode an invalid UTF-32
+- bpo-6922: Fix an infinite loop when trying to decode an invalid UTF-32
   stream with a non-raising error handler like "replace" or "ignore".
 
-- Issue #6713: Improve performance of base 10 int -> string and long -> string
+- bpo-6713: Improve performance of base 10 int -> string and long -> string
   conversions.
 
-- Issue #1590864: Fix potential deadlock when mixing threads and fork().
+- bpo-1590864: Fix potential deadlock when mixing threads and fork().
 
-- Issue #6844: Do not emit DeprecationWarnings when accessing a "message"
+- bpo-6844: Do not emit DeprecationWarnings when accessing a "message"
   attribute on exceptions that was set explicitly.
 
-- Issue #6846: Fix bug where bytearray.pop() returns negative integers.
+- bpo-6846: Fix bug where bytearray.pop() returns negative integers.
 
 - ``classmethod()`` no longer checks if its argument is callable.
 
-- Issue #6750: A text file opened with ``io.open()`` could duplicate its output
+- bpo-6750: A text file opened with ``io.open()`` could duplicate its output
   when writing from multiple threads at the same time.
 
-- Issue #6704: Improve the col_offset in AST for "for" statements with a target
+- bpo-6704: Improve the col_offset in AST for "for" statements with a target
   of tuple unpacking.
 
-- Issue #6707: ``dir()`` on an uninitialized module caused a crash.
+- bpo-6707: ``dir()`` on an uninitialized module caused a crash.
 
-- Issue #6540: Fixed crash for ``bytearray.translate()`` with invalid parameters.
+- bpo-6540: Fixed crash for ``bytearray.translate()`` with invalid
+  parameters.
 
-- Issue #6573: ``set.union()`` stopped processing inputs if an instance of self
+- bpo-6573: ``set.union()`` stopped processing inputs if an instance of self
   occurred in the argument chain.
 
-- Issue #1616979: Added the cp720 (Arabic DOS) encoding.
+- bpo-1616979: Added the cp720 (Arabic DOS) encoding.
 
-- Issue #6070: On posix platforms import no longer copies the execute bit from
+- bpo-6070: On posix platforms import no longer copies the execute bit from
   the .py file to the .pyc file if it is set.  Patch by Marco N.
 
-- Issue #4618: When unicode arguments are passed to ``print()``, the default
+- bpo-4618: When unicode arguments are passed to ``print()``, the default
   separator and end should be unicode also.
 
-- Issue #6119: Fixed an incorrect Py3k warning about order comparisons of
+- bpo-6119: Fixed an incorrect Py3k warning about order comparisons of
   built-in functions and methods.
 
-- Issue #6347: Include inttypes.h as well as stdint.h in pyport.h.  This fixes a
-  build failure on HP-UX: int32_t and uint32_t are defined in inttypes.h instead
-  of stdint.h on that platform.
+- bpo-6347: Include inttypes.h as well as stdint.h in pyport.h.  This fixes
+  a build failure on HP-UX: int32_t and uint32_t are defined in inttypes.h
+  instead of stdint.h on that platform.
 
-- Issue #4856: Remove checks for win NT.
+- bpo-4856: Remove checks for win NT.
 
-- Issue #2016: Fixed a crash in a corner case where the dictionary of keyword
+- bpo-2016: Fixed a crash in a corner case where the dictionary of keyword
   arguments could be modified during the function call setup.
 
 - Removed the ipaddr module.
 
-- Issue #6329: Fixed iteration for memoryview objects (it was being blocked
+- bpo-6329: Fixed iteration for memoryview objects (it was being blocked
   because it wasn't recognized as a sequence).
 
-- Issue #6289: Encoding errors from ``compile()`` were being masked.
+- bpo-6289: Encoding errors from ``compile()`` were being masked.
 
 - When no module is given in a relative import, the module field of the
   ImportFrom AST node is now None instead of an empty string.
 
 - Assignment to None using import statements now raises a SyntaxError.
 
-- Issue #4547: When debugging a very large function, it was not always possible
+- bpo-4547: When debugging a very large function, it was not always possible
   to update the lineno attribute of the current frame.
 
-- Issue #5330: C functions called with keyword arguments were not reported by
-  the various profiling modules (profile, cProfile).  Patch by Hagen Fürstenau.
+- bpo-5330: C functions called with keyword arguments were not reported by
+  the various profiling modules (profile, cProfile).  Patch by Hagen
+  Fürstenau.
 
-- Issue #5982: staticmethod and classmethod now expose the wrapped function with
-  ``__func__``.
+- bpo-5982: staticmethod and classmethod now expose the wrapped function
+  with ``__func__``.
 
 - Added support for multiple context managers in the same with-statement.
   Deprecated ``contextlib.nested()`` which is no longer needed.
 
-- Issue #6101: A new opcode, SETUP_WITH, has been added to speed up the with
+- bpo-6101: A new opcode, SETUP_WITH, has been added to speed up the with
   statement and correctly lookup the __enter__ and __exit__ special methods.
 
-- Issue #5829: complex("1e500") no longer raises OverflowError.  This makes it
+- bpo-5829: complex("1e500") no longer raises OverflowError.  This makes it
   consistent with float("1e500") and interpretation of real and imaginary
   literals.
 
-- Issue #3527: Removed Py_WIN_WIDE_FILENAMES which is not used any more.
+- bpo-3527: Removed Py_WIN_WIDE_FILENAMES which is not used any more.
 
-- ``__instancecheck__()`` and ``__subclasscheck__()`` are now completely ignored
-  on classic classes and instances.
+- ``__instancecheck__()`` and ``__subclasscheck__()`` are now completely
+  ignored on classic classes and instances.
 
-- Issue #5994: The marshal module now has docstrings.
+- bpo-5994: The marshal module now has docstrings.
 
-- Issue #5981: Fix three minor inf/nan issues in float.fromhex:
+- bpo-5981: Fix three minor inf/nan issues in float.fromhex:
 
-  (1) inf and nan strings with trailing whitespace were incorrectly rejected;
-  (2) parsing of strings representing infinities and nans was locale aware; and
-  (3) the interpretation of fromhex('-nan') didn't match that of float('-nan').
+  (1) inf and nan strings with trailing whitespace were incorrectly
+  rejected; (2) parsing of strings representing infinities and nans was
+  locale aware; and (3) the interpretation of fromhex('-nan') didn't match
+  that of float('-nan').
 
-- Issue #5920: For ``float.__format__()``, change the behavior with the empty
-  presentation type (that is, not one of 'e', 'f', 'g', or 'n') to be like 'g'
-  but with at least one decimal point and with a default precision
-  of 12. Previously, the behavior the same but with a default precision of 6.
+- bpo-5920: For ``float.__format__()``, change the behavior with the empty
+  presentation type (that is, not one of 'e', 'f', 'g', or 'n') to be like
+  'g' but with at least one decimal point and with a default precision of
+  12. Previously, the behavior the same but with a default precision of 6.
   This more closely matches ``str()``, and reduces surprises when adding
   alignment flags to the empty presentation type. This also affects the new
   complex.__format__ in the same way.
 
-- Issue #5890: In subclasses of 'property' the __doc__ attribute was shadowed by
-  classtype's, even if it was None.  property now inserts the __doc__ into the
-  subclass instance __dict__.
+- bpo-5890: In subclasses of 'property' the __doc__ attribute was shadowed
+  by classtype's, even if it was None.  property now inserts the __doc__
+  into the subclass instance __dict__.
 
-- Issue #4426: The UTF-7 decoder was too strict and didn't accept some legal
-  sequences.  Patch by Nick Barnes and Victor Stinner.
+- bpo-4426: The UTF-7 decoder was too strict and didn't accept some legal
+  sequences. Patch by Nick Barnes and Victor Stinner.
 
-- Issue #1588: Add complex.__format__. For example, ``format(complex(1, 2./3),
+- bpo-1588: Add complex.__format__. For example, ``format(complex(1, 2./3),
   '.5')`` now produces a sensible result.
 
-- Issue #5864: Fix empty format code formatting for floats so that it never
+- bpo-5864: Fix empty format code formatting for floats so that it never
   gives more than the requested number of significant digits.
 
-- Issue #5793: Rationalize isdigit / isalpha / tolower, etc. Includes new
+- bpo-5793: Rationalize isdigit / isalpha / tolower, etc. Includes new
   Py_ISDIGIT / Py_ISALPHA / Py_TOLOWER, etc. in pctypes.h.
 
-- Issue #4971: Fix titlecase for characters that are their own titlecase, but
+- bpo-4971: Fix titlecase for characters that are their own titlecase, but
   not their own uppercase.
 
-- Issue #5835: Deprecate PyOS_ascii_formatd and replace it with
+- bpo-5835: Deprecate PyOS_ascii_formatd and replace it with
   _PyOS_double_to_string or PyOS_double_to_string.
 
-- Issue #5283: Setting __class__ in __del__ caused a segfault.
+- bpo-5283: Setting __class__ in __del__ caused a segfault.
 
-- Issue #5816: ``complex(repr(z))`` now recovers z exactly, even when z involves
-  nans, infs or negative zeros.
+- bpo-5816: ``complex(repr(z))`` now recovers z exactly, even when z
+  involves nans, infs or negative zeros.
 
-- Implement PEP 378, Format Specifier for Thousands Separator, for floats, ints,
-  and longs.
+- Implement PEP 378, Format Specifier for Thousands Separator, for floats,
+  ints, and longs.
 
-- Issue #5515: 'n' formatting for ints, longs, and floats handles leading zero
+- bpo-5515: 'n' formatting for ints, longs, and floats handles leading zero
   formatting poorly.
 
-- Issue #5772: For float.__format__, don't add a trailing ".0" if we're using no
-  type code and we have an exponent.
+- bpo-5772: For float.__format__, don't add a trailing ".0" if we're using
+  no type code and we have an exponent.
 
-- Issue #3166: Make long -> float (and int -> float) conversions correctly
+- bpo-3166: Make long -> float (and int -> float) conversions correctly
   rounded.
 
-- Issue #5787: ``object.__getattribute__(some_type, "__bases__")`` segfaulted on
-  some built-in types.
+- bpo-5787: ``object.__getattribute__(some_type, "__bases__")`` segfaulted
+  on some built-in types.
 
-- Issue #1869: Fix a couple of minor round() issues.  ``round(5e15+1)`` was
+- bpo-1869: Fix a couple of minor round() issues.  ``round(5e15+1)`` was
   giving 5e15+2; ``round(-0.0)`` was losing the sign of the zero.
 
-- Issue #5759: float() didn't call __float__ on str subclasses.
+- bpo-5759: float() didn't call __float__ on str subclasses.
 
-- Issue #5704: The "-3" command-line option now implies "-t".
+- bpo-5704: The "-3" command-line option now implies "-t".
 
-- Issue #2170: Refactored ``xml.dom.minidom.normalize``, increasing both its
+- bpo-2170: Refactored ``xml.dom.minidom.normalize``, increasing both its
   clarity and its speed.
 
-- Issue #2396: The memoryview object was backported from Python 3.1.
+- bpo-2396: The memoryview object was backported from Python 3.1.
 
-- Fix a problem in PyErr_NormalizeException that leads to "undetected errors"
-  when hitting the recursion limit under certain circumstances.
+- Fix a problem in PyErr_NormalizeException that leads to "undetected
+  errors" when hitting the recursion limit under certain circumstances.
 
-- Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
+- bpo-1665206: Remove the last eager import in _warnings.c and make it lazy.
 
-- Issue #4865: On MacOSX /Library/Python/2.7/site-packages is added to the end
+- bpo-4865: On MacOSX /Library/Python/2.7/site-packages is added to the end
   sys.path, for compatibility with the system install of Python.
 
-- Issue #4688: Add a heuristic so that tuples and dicts containing only
-  untrackable objects are not tracked by the garbage collector. This can reduce
-  the size of collections and therefore the garbage collection overhead on
-  long-running programs, depending on their particular use of datatypes.
+- bpo-4688: Add a heuristic so that tuples and dicts containing only
+  untrackable objects are not tracked by the garbage collector. This can
+  reduce the size of collections and therefore the garbage collection
+  overhead on long-running programs, depending on their particular use of
+  datatypes.
 
-- Issue #5512: Rewrite PyLong long division algorithm (x_divrem) to improve its
-  performance.  Long divisions and remainder operations are now between 50% and
-  150% faster.
+- bpo-5512: Rewrite PyLong long division algorithm (x_divrem) to improve its
+  performance.  Long divisions and remainder operations are now between 50%
+  and 150% faster.
 
-- Issue #4258: Make it possible to use base 2**30 instead of base 2**15 for the
-  internal representation of integers, for performance reasons.  Base 2**30 is
-  enabled by default on 64-bit machines.  Add --enable-big-digits option to
-  configure, which overrides the default.  Add sys.long_info structseq to
+- bpo-4258: Make it possible to use base 2**30 instead of base 2**15 for the
+  internal representation of integers, for performance reasons.  Base 2**30
+  is enabled by default on 64-bit machines.  Add --enable-big-digits option
+  to configure, which overrides the default.  Add sys.long_info structseq to
   provide information about the internal format.
 
-- Issue #4034: Fix weird attribute error messages of the traceback object. (As a
-  result traceback.__members__ no longer exists.)
+- bpo-4034: Fix weird attribute error messages of the traceback object. (As
+  result traceback.__members__ no longer exists.)
 
-- Issue #4474: PyUnicode_FromWideChar now converts characters outside the BMP to
-  surrogate pairs, on systems with sizeof(wchar_t) == 4 and sizeof(Py_UNICODE)
-  == 2.
+- bpo-4474: PyUnicode_FromWideChar now converts characters outside the BMP
+  to surrogate pairs, on systems with sizeof(wchar_t) == 4 and
+  sizeof(Py_UNICODE) == 2.
 
-- Issue #5237: Allow auto-numbered fields in str.format(). For example: ``'{}
+- bpo-5237: Allow auto-numbered fields in str.format(). For example: ``'{}
   {}'.format(1, 2) == '1 2'``.
 
-- Issue #3652: Make the 'line' argument for ``warnings.showwarning()`` a
-  requirement.  Means the DeprecationWarning from Python 2.6 can go away.
+- bpo-3652: Make the 'line' argument for ``warnings.showwarning()`` a
+  requirement. Means the DeprecationWarning from Python 2.6 can go away.
 
-- Issue #5247: Improve error message when unknown format codes are used when
+- bpo-5247: Improve error message when unknown format codes are used when
   using ``str.format()`` with str, unicode, long, int, and float arguments.
 
-- Running Python with the -3 option now also warns about classic division for
-  ints and longs.
+- Running Python with the -3 option now also warns about classic division
+  for ints and longs.
 
-- Issue #5260: Long integers now consume less memory: average saving is 2 bytes
+- bpo-5260: Long integers now consume less memory: average saving is 2 bytes
   per long on a 32-bit system and 6 bytes per long on a 64-bit system.
 
-- Issue #5186: Reduce hash collisions for objects with no __hash__ method by
+- bpo-5186: Reduce hash collisions for objects with no __hash__ method by
   rotating the object pointer by 4 bits to the right.
 
-- Issue #4575: Fix Py_IS_INFINITY macro to work correctly on x87 FPUs: it now
+- bpo-4575: Fix Py_IS_INFINITY macro to work correctly on x87 FPUs: it now
   forces its argument to double before testing for infinity.
 
-- Issue #4978: Passing keyword arguments as unicode strings is now allowed.
+- bpo-4978: Passing keyword arguments as unicode strings is now allowed.
 
-- Issue #1242657: the __len__() and __length_hint__() calls in several tools
+- bpo-1242657: the __len__() and __length_hint__() calls in several tools
   were suppressing all exceptions.  These include list(), filter(), map(),
   zip(), and bytearray().
 
-- os.ftruncate raises OSErrors instead of IOErrors for consistency with other os
-  functions.
+- os.ftruncate raises OSErrors instead of IOErrors for consistency with
+  other os functions.
 
-- Issue #4991: Passing invalid file descriptors to io.FileIO now raises an
+- bpo-4991: Passing invalid file descriptors to io.FileIO now raises an
   OSError.
 
-- Issue #4807: Port the _winreg module to Windows CE.
+- bpo-4807: Port the _winreg module to Windows CE.
 
-- Issue #4935: The overflow checking code in the expandtabs() method common to
-  str, bytes and bytearray could be optimized away by the compiler, letting the
-  interpreter segfault instead of raising an error.
+- bpo-4935: The overflow checking code in the expandtabs() method common to
+  str, bytes and bytearray could be optimized away by the compiler, letting
+  the interpreter segfault instead of raising an error.
 
-- Issue #3720: Fix a crash when an iterator modifies its class and removes its
+- bpo-3720: Fix a crash when an iterator modifies its class and removes its
   __next__ method.
 
-- Issue #4893: Use NT threading on CE.
+- bpo-4893: Use NT threading on CE.
 
-- Issue #4915: Port sysmodule to Windows CE.
+- bpo-4915: Port sysmodule to Windows CE.
 
-- Issue #4074: Change the criteria for doing a full garbage collection (i.e.
-  collecting the oldest generation) so that allocating lots of objects without
-  destroying them does not show quadratic performance. Based on a proposal by
-  Martin von Löwis at
-  http://mail.python.org/pipermail/python-dev/2008-June/080579.html.
+- bpo-4074: Change the criteria for doing a full garbage collection (i.e.
+  collecting the oldest generation) so that allocating lots of objects
+  without destroying them does not show quadratic performance. Based on a
+  proposal by Martin von Löwis at http://mail.python.org/pipermail/python-
+  dev/2008-June/080579.html.
 
-- Issue #4850: Change COUNT_ALLOCS variables to Py_ssize_t.
+- bpo-4850: Change COUNT_ALLOCS variables to Py_ssize_t.
 
-- Issue #1180193: When importing a module from a .pyc (or .pyo) file with an
+- bpo-1180193: When importing a module from a .pyc (or .pyo) file with an
   existing .py counterpart, override the co_filename attributes of all code
-  objects if the original filename is obsolete (which can happen if the file has
-  been renamed, moved, or if it is accessed through different paths).  Patch by
-  Ziga Seilnacht and Jean-Paul Calderone.
+  objects if the original filename is obsolete (which can happen if the file
+  has been renamed, moved, or if it is accessed through different paths).
+  Patch by Ziga Seilnacht and Jean-Paul Calderone.
 
-- Issue #4075: Use ``OutputDebugStringW()`` in Py_FatalError.
+- bpo-4075: Use ``OutputDebugStringW()`` in Py_FatalError.
 
-- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
+- bpo-4797: IOError.filename was not set when _fileio.FileIO failed to open
   file with `str' filename on Windows.
 
-- Issue #3680: Reference cycles created through a dict, set or deque iterator
+- bpo-3680: Reference cycles created through a dict, set or deque iterator
   did not get collected.
 
-- Issue #4701: PyObject_Hash now implicitly calls PyType_Ready on types where
+- bpo-4701: PyObject_Hash now implicitly calls PyType_Ready on types where
   the tp_hash and tp_dict slots are both NULL.
 
-- Issue #4764: With io.open, IOError.filename is set when trying to open a
+- bpo-4764: With io.open, IOError.filename is set when trying to open a
   directory on POSIX systems.
 
-- Issue #4764: IOError.filename is set when trying to open a directory on POSIX
+- bpo-4764: IOError.filename is set when trying to open a directory on POSIX
   systems.
 
-- Issue #4759: None is now allowed as the first argument of
-  ``bytearray.translate()``.  It was always allowed for ``bytes.translate()``.
+- bpo-4759: None is now allowed as the first argument of
+  ``bytearray.translate()``.  It was always allowed for
+  ``bytes.translate()``.
 
 - Added test case to ensure attempts to read from a file opened for writing
   fail.
 
-- Issue #2467: gc.DEBUG_STATS reported invalid elapsed times. Also, always print
-  elapsed times, not only when some objects are uncollectable/unreachable.
-  Original patch by Neil Schemenauer.
+- bpo-2467: gc.DEBUG_STATS reported invalid elapsed times. Also, always
+  print elapsed times, not only when some objects are
+  uncollectable/unreachable. Original patch by Neil Schemenauer.
 
-- Issue #3439: Add a bit_length method to int and long.
+- bpo-3439: Add a bit_length method to int and long.
 
-- Issue #2183: Simplify and optimize bytecode for list comprehensions.  Original
-  patch by Neal Norwitz.
+- bpo-2183: Simplify and optimize bytecode for list comprehensions.
+  Original patch by Neal Norwitz.
 
-- Issue #4597: Fixed exception handling when the __exit__ function of a context
+- bpo-4597: Fixed exception handling when the __exit__ function of a context
   manager returns a value that cannot be converted to a bool.
 
-- Issue #4597: Fixed several opcodes that weren't always propagating exceptions.
+- bpo-4597: Fixed several opcodes that weren't always propagating
+  exceptions.
 
-- Issue #4445: Replace ``sizeof(PyStringObject)`` with
+- bpo-4445: Replace ``sizeof(PyStringObject)`` with
   ``offsetof(PyStringObject, ob_sval) + 1`` when allocating memory for str
-  instances.  On a typical machine this saves 3 bytes of memory (on average) per
-  string allocation.
+  instances.  On a typical machine this saves 3 bytes of memory (on average)
+  per string allocation.
 
-- Issue #3996: On Windows, the PyOS_CheckStack function would cause the
+- bpo-3996: On Windows, the PyOS_CheckStack function would cause the
   interpreter to abort ("Fatal Python error: Could not reset the stack!")
   instead of throwing a MemoryError.
 
-- Issue #3689: The list reversed iterator now supports __length_hint__ instead
-  of __len__.  Behavior now matches other reversed iterators.
+- bpo-3689: The list reversed iterator now supports __length_hint__ instead
+  of __len__. Behavior now matches other reversed iterators.
 
-- Issue #4367: Python would segfault during compiling when the unicodedata
+- bpo-4367: Python would segfault during compiling when the unicodedata
   module couldn't be imported and \N escapes were present.
 
-- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()`` method on
-  file objects with closefd=False. The file descriptor is still kept open but
-  the file object behaves like a closed file. The ``FileIO`` object also got a
-  new readonly attribute ``closefd``.
+- bpo-4233: Changed semantic of ``_fileio.FileIO``'s ``close()`` method on
+  file objects with closefd=False. The file descriptor is still kept open
+  but the file object behaves like a closed file. The ``FileIO`` object also
+  got a new readonly attribute ``closefd``.
 
-- Issue #4348: Some bytearray methods returned that didn't cause any change to
+- bpo-4348: Some bytearray methods returned that didn't cause any change to
   the bytearray, returned the same bytearray instead of a copy.
 
-- Issue #4317: Fixed a crash in the ``imageop.rgb2rgb8()`` function.
+- bpo-4317: Fixed a crash in the ``imageop.rgb2rgb8()`` function.
 
-- Issue #4230: If ``__getattr__`` is a descriptor, it now functions correctly.
+- bpo-4230: If ``__getattr__`` is a descriptor, it now functions correctly.
 
-- Issue #4048: The parser module now correctly validates relative imports.
+- bpo-4048: The parser module now correctly validates relative imports.
 
-- Issue #4225: ``from __future__ import unicode_literals`` didn't work in an
+- bpo-4225: ``from __future__ import unicode_literals`` didn't work in an
   exec statement.
 
-- Issue #4176: Fixed a crash when pickling an object which ``__reduce__`` method
-  does not return iterators for the 4th and 5th items.
+- bpo-4176: Fixed a crash when pickling an object which ``__reduce__``
+  method does not return iterators for the 4th and 5th items.
 
-- Issue #4209: Enabling unicode_literals and the print_function in the same
+- bpo-4209: Enabling unicode_literals and the print_function in the same
   __future__ import didn't work.
 
 - Using ``nonlocal`` as a variable name will now raise a Py3k SyntaxWarning
   because it is a reserved word in 3.x.
 
 - On windows, ``os.chdir()`` given unicode was not working if
-  GetCurrentDirectoryW returned a path longer than MAX_PATH. (But It's doubtful
-  this code path is really executed because I cannot move to such directory on
-  win2k)
+  GetCurrentDirectoryW returned a path longer than MAX_PATH. (But It's
+  doubtful this code path is really executed because I cannot move to such
+  directory on win2k)
 
-- Issue #4069: When ``set.remove(element)`` is used with a set element, the
+- bpo-4069: When ``set.remove(element)`` is used with a set element, the
   element is temporarily replaced with an equivalent frozenset.  But the
-  eventual KeyError would always report the empty ``frozenset()`` as the missing
-  key.  Now it correctly refers to the initial element.
+  eventual KeyError would always report the empty ``frozenset()`` as the
+  missing key. Now it correctly refers to the initial element.
 
-- Issue #4509: Various issues surrounding resize of bytearray objects to which
+- bpo-4509: Various issues surrounding resize of bytearray objects to which
   there are buffer exports.
 
-- Issue #4748: Lambda generators no longer return a value.
+- bpo-4748: Lambda generators no longer return a value.
 
-- Issue #3582: Use native TLS functions on Windows
+- bpo-3582: Use native TLS functions on Windows
 
-- The re.sub(), re.subn() and re.split() functions now accept a flags parameter.
+- The re.sub(), re.subn() and re.split() functions now accept a flags
+  parameter.
 
-- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with short
-  file names.
+- bpo-3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
+  short file names.
 
-- Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
+- bpo-1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
   to avoid compiler warnings.
 
-- Issue #5705: os.setuid() would not accept values > 2**31-1 but pwd.getpwnam()
+- bpo-5705: os.setuid() would not accept values > 2**31-1 but pwd.getpwnam()
   returned them on 64bit platforms.
 
-- Issue #5108: Handle %s like %S and %R in PyUnicode_FromFormatV(): Call
+- bpo-5108: Handle %s like %S and %R in PyUnicode_FromFormatV(): Call
   PyUnicode_DecodeUTF8() once, remember the result and output it in a second
-  step. This avoids problems with counting UTF-8 bytes that ignores the effect
-  of using the replace error handler in PyUnicode_DecodeUTF8().
+  step. This avoids problems with counting UTF-8 bytes that ignores the
+  effect of using the replace error handler in PyUnicode_DecodeUTF8().
 
-- Issue #3739: The unicode-internal encoder now reports the number of characters
-  consumed like any other encoder (instead of the number of bytes).
+- bpo-3739: The unicode-internal encoder now reports the number of
+  characters consumed like any other encoder (instead of the number of
+  bytes).
 
-- Issue #2422: When compiled with the ``--with-valgrind`` option, the pymalloc
-  allocator will be automatically disabled when running under Valgrind.  This
-  gives improved memory leak detection when running under Valgrind, while taking
-  advantage of pymalloc at other times.
+- bpo-2422: When compiled with the ``--with-valgrind`` option, the pymalloc
+  allocator will be automatically disabled when running under Valgrind.
+  This gives improved memory leak detection when running under Valgrind,
+  while taking advantage of pymalloc at other times.
 
 Library
 -------
@@ -8029,646 +8460,656 @@ Library
 
 - Fix variations of extending deques:  d.extend(d)  d.extendleft(d)  d+=d
 
-- Issue #6986: Fix crash in the JSON C accelerator when called with the wrong
+- bpo-6986: Fix crash in the JSON C accelerator when called with the wrong
   parameter types.  Patch by Victor Stinner.
 
-- logging: Added optional "secure" parameter to SMTPHandler, to enable use of
-  TLS with authentication credentials.
+- logging: Added optional "secure" parameter to SMTPHandler, to enable use
+  of TLS with authentication credentials.
 
-- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is generated
-  in Distutils. Patch by Stephen Emslie.
+- bpo-1923: Fixed the removal of meaningful spaces when PKG-INFO is
+  generated in Distutils. Patch by Stephen Emslie.
 
-- Issue #4120: Drop reference to CRT from manifest when building extensions with
-  msvc9compiler.
+- bpo-4120: Drop reference to CRT from manifest when building extensions
+  with msvc9compiler.
 
-- Issue #7333: The ``posix`` module gains an ``initgroups()`` function providing
-  access to the initgroups(3) C library call on Unix systems which implement it.
-  Patch by Jean-Paul Calderone.
+- bpo-7333: The ``posix`` module gains an ``initgroups()`` function
+  providing access to the initgroups(3) C library call on Unix systems which
+  implement it. Patch by Jean-Paul Calderone.
 
-- Issue #7408: Fixed distutils.tests.sdist so it doesn't check for group
+- bpo-7408: Fixed distutils.tests.sdist so it doesn't check for group
   ownership when the group is not forced, because the group may be different
   from the user's group and inherit from its container when the test is run.
 
-- Issue #1515: Enable use of deepcopy() with instance methods.  Patch by Robert
+- bpo-1515: Enable use of deepcopy() with instance methods.  Patch by Robert
   Collins.
 
-- Issue #7403: logging: Fixed possible race condition in lock creation.
+- bpo-7403: logging: Fixed possible race condition in lock creation.
 
-- Issue #6845: Add restart support for binary upload in ftplib.  The
-  ``storbinary()`` method of FTP and FTP_TLS objects gains an optional "rest"
-  argument.  Patch by Pablo Mouzo.
+- bpo-6845: Add restart support for binary upload in ftplib.  The
+  ``storbinary()`` method of FTP and FTP_TLS objects gains an optional
+  "rest" argument.  Patch by Pablo Mouzo.
 
-- Issue #5788: ``datetime.timedelta`` objects get a new ``total_seconds()``
-  method returning the total number of seconds in the duration.  Patch by Brian
-  Quinlan.
+- bpo-5788: ``datetime.timedelta`` objects get a new ``total_seconds()``
+  method returning the total number of seconds in the duration.  Patch by
+  Brian Quinlan.
 
-- Issue #6615: logging: Used weakrefs in internal handler list.
+- bpo-6615: logging: Used weakrefs in internal handler list.
 
-- Issue #1488943: ``difflib.Differ`` doesn't always add hints for tab
+- bpo-1488943: ``difflib.Differ`` doesn't always add hints for tab
   characters.
 
-- Issue #6123: tarfile now opens empty archives correctly and consistently
+- bpo-6123: tarfile now opens empty archives correctly and consistently
   raises ReadError on empty files.
 
-- Issue #7354: distutils.tests.test_msvc9compiler - dragfullwindows can be 2.
+- bpo-7354: distutils.tests.test_msvc9compiler - dragfullwindows can be 2.
 
-- Issue #5037: Proxy the __unicode__ special method to __unicode__ instead of
+- bpo-5037: Proxy the __unicode__ special method to __unicode__ instead of
   __str__.
 
-- Issue #7341: Close the internal file object in the TarFile constructor in case
-  of an error.
+- bpo-7341: Close the internal file object in the TarFile constructor in
+  case of an error.
 
-- Issue #7293: ``distutils.test_msvc9compiler`` is fixed to work on any fresh
-  Windows box.  Help provided by David Bolen.
+- bpo-7293: ``distutils.test_msvc9compiler`` is fixed to work on any fresh
+  Windows box. Help provided by David Bolen.
 
-- Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch.
+- bpo-7328: pydoc no longer corrupts sys.path when run with the '-m' switch.
 
-- Issue #2054: ftplib now provides an FTP_TLS class to do secure FTP using TLS
-  or SSL.  Patch by Giampaolo Rodola'.
+- bpo-2054: ftplib now provides an FTP_TLS class to do secure FTP using TLS
+  or SSL. Patch by Giampaolo Rodola'.
 
-- Issue #4969: The mimetypes module now reads the MIME database from the
+- bpo-4969: The mimetypes module now reads the MIME database from the
   registry under Windows.  Patch by Gabriel Genellina.
 
-- Issue #6816: runpy now provides a run_path function that allows Python code to
-  execute file paths that refer to source or compiled Python files as well as
-  zipfiles, directories and other valid sys.path entries that contain a
-  __main__.py file. This allows applications that run other Python scripts to
-  support the same flexibility as the CPython command line itself.
+- bpo-6816: runpy now provides a run_path function that allows Python code
+  to execute file paths that refer to source or compiled Python files as
+  well as zipfiles, directories and other valid sys.path entries that
+  contain a __main__.py file. This allows applications that run other Python
+  scripts to support the same flexibility as the CPython command line
+  itself.
 
-- Issue #7318: multiprocessing now uses a timeout when it fails to establish a
-  connection with another process, rather than looping endlessly. The default
-  timeout is 20 seconds, which should be amply sufficient for local connections.
+- bpo-7318: multiprocessing now uses a timeout when it fails to establish a
+  connection with another process, rather than looping endlessly. The
+  default timeout is 20 seconds, which should be amply sufficient for local
+  connections.
 
-- Issue #7197: Allow unittest.TextTestRunner objects to be pickled and
+- bpo-7197: Allow unittest.TextTestRunner objects to be pickled and
   unpickled.  This fixes crashes under Windows when trying to run
   test_multiprocessing in verbose mode.
 
-- Issue #7282: Fix a memory leak when an RLock was used in a thread other than
+- bpo-7282: Fix a memory leak when an RLock was used in a thread other than
   those started through ``threading.Thread`` (for example, using
   ``thread.start_new_thread()``.
 
-- Issue #7264: Fix a possible deadlock when deallocating thread-local objects
+- bpo-7264: Fix a possible deadlock when deallocating thread-local objects
   which are part of a reference cycle.
 
-- Issue #7211: Allow 64-bit values for the ``ident`` and ``data`` fields of
+- bpo-7211: Allow 64-bit values for the ``ident`` and ``data`` fields of
   kevent objects on 64-bit systems.  Patch by Michael Broghton.
 
-- Issue #6896: ``mailbox.Maildir`` now invalidates its internal cache each time
+- bpo-6896: ``mailbox.Maildir`` now invalidates its internal cache each time
   a modification is done through it.  This fixes inconsistencies and test
   failures on systems with slightly bogus mtime behaviour.
 
-- Issue #7246 & Issue #7208: getpass now properly flushes input before reading
-  from stdin so that existing input does not confuse it and lead to incorrect
-  entry or an IOError.  It also properly flushes it afterwards to avoid the
-  terminal echoing the input afterwards on OSes such as Solaris.
+- bpo-7246: getpass now properly flushes input before reading from stdin so
+  that existing input does not confuse it and lead to incorrect entry or an
+  IOError.  It also properly flushes it afterwards to avoid the terminal
+  echoing the input afterwards on OSes such as Solaris. (See also: bpo-7208)
 
-- Issue #7233: Fix a number of two-argument Decimal methods to make sure that
-  they accept an int or long as the second argument.  Also fix buggy handling of
-  large arguments (those with coefficient longer than the current precision) in
-  shift and rotate.
+- bpo-7233: Fix a number of two-argument Decimal methods to make sure that
+  they accept an int or long as the second argument.  Also fix buggy
+  handling of large arguments (those with coefficient longer than the
+  current precision) in shift and rotate.
 
-- Issue #4750: Store the basename of the original filename in the gzip FNAME
+- bpo-4750: Store the basename of the original filename in the gzip FNAME
   header as required by RFC 1952.
 
-- Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in
+- bpo-1180: Added a new global option to ignore ~/.pydistutils.cfg in
   Distutils.
 
-- Issue #7218: Fix test_site for win32, the directory comparison was done with
+- bpo-7218: Fix test_site for win32, the directory comparison was done with
   an uppercase.
 
-- Issue #7205: Fix a possible deadlock when using a BZ2File object from several
+- bpo-7205: Fix a possible deadlock when using a BZ2File object from several
   threads at once.
 
-- Issue #7071: byte-compilation in Distutils is now done with respect to
+- bpo-7071: byte-compilation in Distutils is now done with respect to
   sys.dont_write_bytecode.
 
-- Issue #7066: archive_util.make_archive now restores the cwd if an error is
+- bpo-7066: archive_util.make_archive now restores the cwd if an error is
   raised. Initial patch by Ezio Melotti.
 
-- Issue #6218: io.StringIO and io.BytesIO instances are now picklable with
+- bpo-6218: io.StringIO and io.BytesIO instances are now picklable with
   protocol 2.
 
-- Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
+- bpo-7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
 
-- Issue #7099: Decimal.is_normal now returns True for numbers with exponent
+- bpo-7099: Decimal.is_normal now returns True for numbers with exponent
   larger than emax.
 
-- Issue #5833: Fix extra space character in readline completion with the GNU
+- bpo-5833: Fix extra space character in readline completion with the GNU
   readline library version 6.0.
 
-- Issue #7133: SSL objects now support the new buffer API.
+- bpo-7133: SSL objects now support the new buffer API.
 
-- Issue #7149: urllib fails on OSX in the proxy detection code.
+- bpo-7149: urllib fails on OSX in the proxy detection code.
 
-- Issue #7069: Make inspect.isabstract() return a boolean.
+- bpo-7069: Make inspect.isabstract() return a boolean.
 
 - Add support to the ``ihooks`` module for relative imports.
 
-- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment.
+- bpo-6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment.
 
-- Issue #7086: Added TCP support to SysLogHandler, and tidied up some
+- bpo-7086: Added TCP support to SysLogHandler, and tidied up some
   anachronisms in the code which were a relic of 1.5.2 compatibility.
 
-- Issue #7082: When falling back to the MIME 'name' parameter, the correct place
-  to look for it is the Content-Type header.
+- bpo-7082: When falling back to the MIME 'name' parameter, the correct
+  place to look for it is the Content-Type header.
 
-- Issue #7048: Force Decimal.logb to round its result when that result is too
+- bpo-7048: Force Decimal.logb to round its result when that result is too
   large to fit in the current precision.
 
-- Issue #6516: Added owner/group support when creating tar archives in
+- bpo-6516: Added owner/group support when creating tar archives in
   Distutils.
 
-- Issue #7031: Add ``TestCase.assert(Not)IsInstance()`` methods.
+- bpo-7031: Add ``TestCase.assert(Not)IsInstance()`` methods.
 
-- Issue #6790: Make it possible again to pass an ``array.array`` to
+- bpo-6790: Make it possible again to pass an ``array.array`` to
   ``httplib.HTTPConnection.send``.  Patch by Kirk McDonald.
 
-- Issue #6236, #6348: Fix various failures in the `io` module under AIX and
-  other platforms, when using a non-gcc compiler.  Patch by egreen.
+- bpo-6236: Fix various failures in the `io` module under AIX and other
+  platforms, when using a non-gcc compiler.  Patch by egreen. (See also:
+  bpo-6348)
 
-- Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
+- bpo-6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
 
-- Issue #6851: Fix urllib.urlopen crash on secondairy threads on OSX 10.6
+- bpo-6851: Fix urllib.urlopen crash on secondairy threads on OSX 10.6
 
-- Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...) does now
+- bpo-4606: Passing 'None' if ctypes argtype is set to POINTER(...) does now
   always result in NULL.
 
-- Issue #5042: ctypes Structure sub-subclass does now initialize correctly with
+- bpo-5042: ctypes Structure sub-subclass does now initialize correctly with
   base class positional arguments.
 
-- Issue #6938: Fix a TypeError in string formatting of a multiprocessing debug
+- bpo-6938: Fix a TypeError in string formatting of a multiprocessing debug
   message.
 
-- Issue #6635: Fix profiler printing usage message.
+- bpo-6635: Fix profiler printing usage message.
 
-- Issue #6856: Add a filter keyword argument to TarFile.add().
+- bpo-6856: Add a filter keyword argument to TarFile.add().
 
-- Issue #6163: Fixed HP-UX runtime library dir options in
+- bpo-6163: Fixed HP-UX runtime library dir options in
   distutils.unixcompiler.  Initial patch by Sridhar Ratnakumar and Michael
   Haubenwallner.
 
-- Issue #6857: Default format() alignment should be '>' for Decimal instances.
+- bpo-6857: Default format() alignment should be '>' for Decimal instances.
 
-- Issue #6795: int(Decimal('nan')) now raises ValueError instead of returning
+- bpo-6795: int(Decimal('nan')) now raises ValueError instead of returning
   NaN or raising InvalidContext.  Also, fix infinite recursion in
   long(Decimal('nan')).
 
-- Issue #6850: Fix bug in Decimal._parse_format_specifier for formats with no
+- bpo-6850: Fix bug in Decimal._parse_format_specifier for formats with no
   type specifier.
 
-- Issue #4937: plat-mac/bundlebuilder refers to non-existing version.plist.
+- bpo-4937: plat-mac/bundlebuilder refers to non-existing version.plist.
 
-- Issue #6838: Use a list to accumulate the value instead of repeatedly
+- bpo-6838: Use a list to accumulate the value instead of repeatedly
   concatenating strings in httplib's HTTPResponse._read_chunked providing a
   significant speed increase when downloading large files servend with a
   Transfer-Encoding of 'chunked'.
 
-- Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments
+- bpo-5275: In Cookie's Cookie.load(), properly handle non-string arguments
   as documented.
 
-- Issue #2666: Handle BROWSER environment variable properly for unknown browser
+- bpo-2666: Handle BROWSER environment variable properly for unknown browser
   names in the webbrowser module.
 
-- Issue #6054: Do not normalize stored pathnames in tarfile.
+- bpo-6054: Do not normalize stored pathnames in tarfile.
 
-- Issue #6794: Fix Decimal.compare_total and Decimal.compare_total_mag: NaN
+- bpo-6794: Fix Decimal.compare_total and Decimal.compare_total_mag: NaN
   payloads are now ordered by integer value rather than lexicographically.
 
-- Issue #6693: New functions in site.py to get user/global site packages paths.
+- bpo-6693: New functions in site.py to get user/global site packages paths.
 
 - The thread.lock type now supports weak references.
 
-- Issue #1356969: Add missing info methods in Tix.HList.
+- bpo-1356969: Add missing info methods in Tix.HList.
 
-- Issue #1522587: New constants and methods for the Tix.Grid widget.
+- bpo-1522587: New constants and methods for the Tix.Grid widget.
 
-- Issue #1250469: Fix the return value of Tix.PanedWindow.panes.
+- bpo-1250469: Fix the return value of Tix.PanedWindow.panes.
 
-- Issue #1119673: Do not override Tkinter.Text methods when creating a
+- bpo-1119673: Do not override Tkinter.Text methods when creating a
   ScrolledText.
 
-- Issue #6665: Fix fnmatch to properly match filenames with newlines in them.
+- bpo-6665: Fix fnmatch to properly match filenames with newlines in them.
 
-- Issue #1135: Add the XView and YView mix-ins to avoid duplicating the xview*
+- bpo-1135: Add the XView and YView mix-ins to avoid duplicating the xview*
   and yview* methods.
 
-- Issue #6629: Fix a data corruption issue in the new `io` package, which could
-  occur when writing to a BufferedRandom object (e.g. a file opened in "rb+" or
-  "wb+" mode) after having buffered a certain amount of data for reading. This
-  bug was not present in the pure Python implementation.
+- bpo-6629: Fix a data corruption issue in the new `io` package, which could
+  occur when writing to a BufferedRandom object (e.g. a file opened in "rb+"
+  or "wb+" mode) after having buffered a certain amount of data for reading.
+  This bug was not present in the pure Python implementation.
 
-- Issue #4660: If a multiprocessing.JoinableQueue.put() was preempted, it was
+- bpo-4660: If a multiprocessing.JoinableQueue.put() was preempted, it was
   possible to get a spurious 'task_done() called too many times' error.
 
-- Issue #1628205: Socket file objects returned by socket.socket.makefile() now
-  properly handles EINTR within the read, readline, write & flush methods.  The
-  socket.sendall() method now properly handles interrupted system calls.
+- bpo-1628205: Socket file objects returned by socket.socket.makefile() now
+  properly handles EINTR within the read, readline, write & flush methods.
+  The socket.sendall() method now properly handles interrupted system calls.
 
-- Issue #6595: The Decimal constructor now allows arbitrary Unicode decimal
-  digits in input, as recommended by the standard.  Previously it was restricted
-  to accepting [0-9].
+- bpo-6595: The Decimal constructor now allows arbitrary Unicode decimal
+  digits in input, as recommended by the standard.  Previously it was
+  restricted to accepting [0-9].
 
-- Issue #6511: ZipFile now raises BadZipfile (instead of an IOError) when
+- bpo-6511: ZipFile now raises BadZipfile (instead of an IOError) when
   opening an empty or very small file.
 
-- Issue #6553: Fixed a crash in cPickle.load(), when given a file-like object
+- bpo-6553: Fixed a crash in cPickle.load(), when given a file-like object
   containing incomplete data.
 
-- Issue #6545: Removed assert statements in distutils.Extension, so the behavior
-  is similar when used with -O.
+- bpo-6545: Removed assert statements in distutils.Extension, so the
+  behavior is similar when used with -O.
 
-- unittest has been split up into a package.  All old names should still work.
+- unittest has been split up into a package.  All old names should still
+  work.
 
-- Issue #6431: Make Fraction type return NotImplemented when it doesn't know how
-  to handle a comparison without loss of precision.  Also add correct handling
-  of infinities and nans for comparisons with float.
+- bpo-6431: Make Fraction type return NotImplemented when it doesn't know
+  how to handle a comparison without loss of precision.  Also add correct
+  handling of infinities and nans for comparisons with float.
 
-- Issue #6415: Fixed warnings.warn segfault on bad formatted string.
+- bpo-6415: Fixed warnings.warn segfault on bad formatted string.
 
-- Issue #6466: Now distutils.cygwinccompiler and distutils.emxccompiler uses the
-  same refactored function to get gcc/ld/dllwrap versions numbers.  It's
-  ``distutils.util.get_compiler_versions()``.  Added deprecation warnings for
-  the obsolete get_versions() functions.
+- bpo-6466: Now distutils.cygwinccompiler and distutils.emxccompiler uses
+  the same refactored function to get gcc/ld/dllwrap versions numbers.  It's
+  ``distutils.util.get_compiler_versions()``.  Added deprecation warnings
+  for the obsolete get_versions() functions.
 
-- Issue #6433: Fixed issues with multiprocessing.pool.map hanging on empty list.
+- bpo-6433: Fixed issues with multiprocessing.pool.map hanging on empty
+  list.
 
-- Issue #6314: logging: Extra checks on the "level" argument in more places.
+- bpo-6314: logging: Extra checks on the "level" argument in more places.
 
-- Issue #2622: Fixed an ImportError when importing email.messsage from a
+- bpo-2622: Fixed an ImportError when importing email.messsage from a
   standalone application built with py2exe or py2app.
 
-- Issue #6455: Fixed test_build_ext under win32.
+- bpo-6455: Fixed test_build_ext under win32.
 
-- Issue #6377: Enabled the compiler option, and deprecate its usage as an
+- bpo-6377: Enabled the compiler option, and deprecate its usage as an
   attribute.
 
-- Issue #6413: Fixed the log level in distutils.dist for announce.
+- bpo-6413: Fixed the log level in distutils.dist for announce.
 
-- Issue #3392: The subprocess communicate() method no longer fails in select()
-  when file descriptors are large; communicate() now uses poll() when possible.
+- bpo-3392: The subprocess communicate() method no longer fails in select()
+  when file descriptors are large; communicate() now uses poll() when
+  possible.
 
-- Issue #6403: Fixed package path usage in build_ext.
+- bpo-6403: Fixed package path usage in build_ext.
 
-- Issues #5155, #5313, #5331: multiprocessing.Process._bootstrap was
-  unconditionally calling "os.close(sys.stdin.fileno())" resulting in file
-  descriptor errors.
+- bpo-5155: multiprocessing.Process._bootstrap was unconditionally calling
+  "os.close(sys.stdin.fileno())" resulting in file descriptor errors. (See
+  also: bpo-5313, bpo-5331)
 
-- Issue #6365: Distutils build_ext inplace mode was copying the compiled
+- bpo-6365: Distutils build_ext inplace mode was copying the compiled
   extension in a subdirectory if the extension name had dots.
 
-- Issue #6344: Fixed a crash of mmap.read() when passed a negative argument.
+- bpo-6344: Fixed a crash of mmap.read() when passed a negative argument.
 
-- Issue #5230: pydoc would report no documentation found if a module generated a
-  'not found' import error when loaded; it now reports the import errors.
+- bpo-5230: pydoc would report no documentation found if a module generated
+  'not found' import error when loaded; it now reports the import errors.
   Thanks to Lucas Prado Melo for initial fix and collaboration on the tests.
 
-- Issue #6314: ``logging.basicConfig()`` performs extra checks on the "level"
+- bpo-6314: ``logging.basicConfig()`` performs extra checks on the "level"
   argument.
 
-- Issue #6164: Added an AIX specific linker argument in Distutils unixcompiler.
+- bpo-6164: Added an AIX specific linker argument in Distutils unixcompiler.
   Original patch by Sridhar Ratnakumar.
 
-- Issue #6274: Fixed possible file descriptors leak in subprocess.py.
+- bpo-6274: Fixed possible file descriptors leak in subprocess.py.
 
-- Issue #6189: Restored compatibility of subprocess.py with Python 2.2.
+- bpo-6189: Restored compatibility of subprocess.py with Python 2.2.
 
-- Issue #6287: Added the license field in Distutils documentation.
+- bpo-6287: Added the license field in Distutils documentation.
 
-- Issue #6286: Now Distutils upload command is based on urllib2 instead of
+- bpo-6286: Now Distutils upload command is based on urllib2 instead of
   httplib, allowing the usage of http_proxy.
 
-- Issue #6271: mmap tried to close invalid file handle (-1) for anonymous maps
+- bpo-6271: mmap tried to close invalid file handle (-1) for anonymous maps
   on Unix.
 
-- Issue #6215: All bug fixes and enhancements from the Python 3.1 io library
+- bpo-6215: All bug fixes and enhancements from the Python 3.1 io library
   (including the fast C implementation) have been backported to the standard
   ``io`` module.
 
-- Issue #6258: Support AMD64 in bdist_msi.
+- bpo-6258: Support AMD64 in bdist_msi.
 
-- Issue #6252: Fixed bug in next rollover time computation in
+- bpo-6252: Fixed bug in next rollover time computation in
   TimedRotatingFileHandler.
 
-- Issue #6263: Fixed syntax error in distutils.cygwincompiler.
+- bpo-6263: Fixed syntax error in distutils.cygwincompiler.
 
-- Issue #5201: distutils.sysconfig.parse_makefile() now understands ``$$`` in
-  Makefiles.  This prevents compile errors when using syntax like:
+- bpo-5201: distutils.sysconfig.parse_makefile() now understands ``$$`` in
+  Makefiles. This prevents compile errors when using syntax like:
   ``LDFLAGS='-rpath=\$$LIB:/some/other/path'``.  Patch by Floris Bruynooghe.
 
-- Issue #5767: Removed sgmlop support from xmlrpclib.
+- bpo-5767: Removed sgmlop support from xmlrpclib.
 
-- Issue #6131: test_modulefinder leaked when run after test_distutils.  Patch by
-  Hirokazu Yamamoto.
+- bpo-6131: test_modulefinder leaked when run after test_distutils.  Patch
+  by Hirokazu Yamamoto.
 
-- Issue #6048: Now Distutils uses the tarfile module in archive_util.
+- bpo-6048: Now Distutils uses the tarfile module in archive_util.
 
-- Issue #6121: pydoc now ignores leading and trailing spaces in the argument to
+- bpo-6121: pydoc now ignores leading and trailing spaces in the argument to
   the 'help' function.
 
 - In unittest, using a skipping decorator on a class is now equivalent to
-  skipping every test on the class.  The ClassTestSuite class has been removed.
+  skipping every test on the class.  The ClassTestSuite class has been
+  removed.
 
-- Issue #6050: Don't fail extracting a directory from a zipfile if the directory
-  already exists.
+- bpo-6050: Don't fail extracting a directory from a zipfile if the
+  directory already exists.
 
-- Issue #5311: bdist_msi can now build packages that do not depend on a specific
-  Python version.
+- bpo-5311: bdist_msi can now build packages that do not depend on a
+  specific Python version.
 
-- Issue #1309352: fcntl now converts its third arguments to a C `long` rather
+- bpo-1309352: fcntl now converts its third arguments to a C `long` rather
   than an int, which makes some operations possible under 64-bit Linux (e.g.
   DN_MULTISHOT with F_NOTIFY).
 
-- Issue #1424152: Fix for httplib, urllib2 to support SSL while working through
+- bpo-1424152: Fix for httplib, urllib2 to support SSL while working through
   proxy. Original patch by Christopher Li, changes made by Senthil Kumaran.
 
-- Issue #1983: Fix functions taking or returning a process identifier to use the
-  dedicated C type ``pid_t`` instead of a C ``int``.  Some platforms have a
-  process identifier type wider than the standard C integer type.
+- bpo-1983: Fix functions taking or returning a process identifier to use
+  the dedicated C type ``pid_t`` instead of a C ``int``.  Some platforms
+  have a process identifier type wider than the standard C integer type.
 
-- Issue #4066: smtplib.SMTP_SSL._get_socket now correctly returns the socket.
+- bpo-4066: smtplib.SMTP_SSL._get_socket now correctly returns the socket.
   Patch by Farhan Ahmad, test by Marcin Bachry.
 
-- Issue #6062: In distutils, fixed the package option of build_ext.  Feedback
+- bpo-6062: In distutils, fixed the package option of build_ext.  Feedback
   and tests on pywin32 by Tim Golden.
 
-- Issue #6053: Fixed distutils tests on win32.  Patch by Hirokazu Yamamoto.
+- bpo-6053: Fixed distutils tests on win32.  Patch by Hirokazu Yamamoto.
 
-- Issue #6046: Fixed the library extension when distutils build_ext is used in
-  place.  Initial patch by Roumen Petrov.
+- bpo-6046: Fixed the library extension when distutils build_ext is used in
+  place. Initial patch by Roumen Petrov.
 
-- Issue #6041: Now distutils `sdist` and `register` commands use `check` as a
+- bpo-6041: Now distutils `sdist` and `register` commands use `check` as a
   subcommand.
 
-- Issue #2116: Weak references and weak dictionaries now support copy()ing and
+- bpo-2116: Weak references and weak dictionaries now support copy()ing and
   deepcopy()ing.
 
-- Issue #1655: Make imaplib IPv6-capable.  Patch by Derek Morr.
+- bpo-1655: Make imaplib IPv6-capable.  Patch by Derek Morr.
 
-- Issue #5918: Fix a crash in the parser module.
+- bpo-5918: Fix a crash in the parser module.
 
-- Issue #1664: Make nntplib IPv6-capable.  Patch by Derek Morr.
+- bpo-1664: Make nntplib IPv6-capable.  Patch by Derek Morr.
 
-- Issue #6022: A test file was created in the current working directory by
+- bpo-6022: A test file was created in the current working directory by
   test_get_outputs in Distutils.
 
-- Issue #4050: inspect.findsource/getsource now raise an IOError if the 'source'
-  file is a binary.  Patch by Brodie Rao, tests by Daniel Diniz.
+- bpo-4050: inspect.findsource/getsource now raise an IOError if the
+  'source' file is a binary.  Patch by Brodie Rao, tests by Daniel Diniz.
 
-- Issue #5977: distutils build_ext.get_outputs was not taking into account the
+- bpo-5977: distutils build_ext.get_outputs was not taking into account the
   inplace option.  Initial patch by kxroberto.
 
-- Issue #5984: distutils.command.build_ext.check_extensions_list checks were
+- bpo-5984: distutils.command.build_ext.check_extensions_list checks were
   broken for old-style extensions.
 
-- Issue #5971: StreamHandler.handleError now swallows IOErrors which occur when
+- bpo-5971: StreamHandler.handleError now swallows IOErrors which occur when
   trying to print a traceback.
 
-- Issue #5976: Fixed Distutils test_check_environ.
+- bpo-5976: Fixed Distutils test_check_environ.
 
-- Issue #5900: Ensure RUNPATH is added to extension modules with RPATH if GNU ld
-  is used.  Original patch by Floris Bruynooghe.
+- bpo-5900: Ensure RUNPATH is added to extension modules with RPATH if GNU
+  ld is used. Original patch by Floris Bruynooghe.
 
-- Issue #5941: Distutils build_clib command was not working anymore because of
+- bpo-5941: Distutils build_clib command was not working anymore because of
   an incomplete customization of the archiver command.  Added ARFLAGS in the
   Makefile besides AR and make Distutils use it.  Original patch by David
   Cournapeau.
 
-- Issue #5955: aifc's close method did not close the file it wrapped, now it
+- bpo-5955: aifc's close method did not close the file it wrapped, now it
   does.  This also means getfp method now returns the real fp.
 
-- Issue #4875: On win32, ctypes.util.find_library does no longer return
+- bpo-4875: On win32, ctypes.util.find_library does no longer return
   directories.
 
-- Issue #5142: Add the ability to skip modules while stepping to pdb.
+- bpo-5142: Add the ability to skip modules while stepping to pdb.
 
-- Issue #1309567: Fix linecache behavior of stripping subdirectories when
+- bpo-1309567: Fix linecache behavior of stripping subdirectories when
   looking for files given by a relative filename.
 
-- Issue #5692: In ``zipfile.Zipfile``, fix wrong path calculation when
+- bpo-5692: In ``zipfile.Zipfile``, fix wrong path calculation when
   extracting a file to the root directory.
 
-- Issue #5913: ``os.listdir()`` should fail for empty path on windows.
+- bpo-5913: ``os.listdir()`` should fail for empty path on windows.
 
-- Issue #5084: Unpickling now interns the attribute names of pickled objects,
-  saving memory and avoiding growth in size of subsequent pickles.  Proposal and
-  original patch by Jake McGuire.
+- bpo-5084: Unpickling now interns the attribute names of pickled objects,
+  saving memory and avoiding growth in size of subsequent pickles.  Proposal
+  and original patch by Jake McGuire.
 
-- Issue #3002: ``shutil.copyfile()`` and ``shutil.copytree()`` now raise an
+- bpo-3002: ``shutil.copyfile()`` and ``shutil.copytree()`` now raise an
   error when a named pipe is encountered, rather than blocking infinitely.
 
-- Issue #3959: The ipaddr module has been added to the standard library.
+- bpo-3959: The ipaddr module has been added to the standard library.
   Contributed by Google.
 
-- Issue #2245: aifc now skips chunk types it doesn't recognize, per spec.
+- bpo-2245: aifc now skips chunk types it doesn't recognize, per spec.
 
-- Issue #5874: distutils.tests.test_config_cmd is not locale-sensitive anymore.
+- bpo-5874: distutils.tests.test_config_cmd is not locale-sensitive anymore.
 
-- Issue #4305: ctypes should now build again on mipsel-linux-gnu
+- bpo-4305: ctypes should now build again on mipsel-linux-gnu
 
-- Issue #1734234: Massively speedup ``unicodedata.normalize()`` when the string
+- bpo-1734234: Massively speedup ``unicodedata.normalize()`` when the string
   is already in normalized form, by performing a quick check beforehand.
   Original patch by Rauli Ruohonen.
 
-- Issue #5853: Calling a function of the mimetypes module from several threads
-  at once could hit the recursion limit if the mimetypes database hadn't been
-  initialized before.
+- bpo-5853: Calling a function of the mimetypes module from several threads
+  at once could hit the recursion limit if the mimetypes database hadn't
+  been initialized before.
 
-- Issue #5854: Updated __all__ to include some missing names and remove some
+- bpo-5854: Updated __all__ to include some missing names and remove some
   names which should not be exported.
 
-- Issue #5810: Fixed Distutils test_build_scripts so it uses
+- bpo-5810: Fixed Distutils test_build_scripts so it uses
   ``sysconfig.get_config_vars()``.
 
-- Issue #4951: Fixed failure in test_httpservers.
+- bpo-4951: Fixed failure in test_httpservers.
 
-- Issue #3102: All global symbols that the _ctypes extension defines are now
+- bpo-3102: All global symbols that the _ctypes extension defines are now
   prefixed with 'Py' or '_ctypes'.
 
-- Issue #5041: ctypes does now allow pickling wide character.
+- bpo-5041: ctypes does now allow pickling wide character.
 
-- Issue #5812: For the two-argument form of the Fraction constructor,
-  ``Fraction(m, n)``, m and n are permitted to be arbitrary Rational instances.
+- bpo-5812: For the two-argument form of the Fraction constructor,
+  ``Fraction(m, n)``, m and n are permitted to be arbitrary Rational
+  instances.
 
-- Issue #5812: Fraction('1e6') is valid: more generally, any string that's valid
-  for float() is now valid for Fraction(), with the exception of strings
-  representing NaNs and infinities.
+- bpo-5812: Fraction('1e6') is valid: more generally, any string that's
+  valid for float() is now valid for Fraction(), with the exception of
+  strings representing NaNs and infinities.
 
-- Issue #5795: Fixed test_distutils failure on Debian ppc.
+- bpo-5795: Fixed test_distutils failure on Debian ppc.
 
-- Issue #5768: Fixed bug in Unicode output logic and test case for same.
+- bpo-5768: Fixed bug in Unicode output logic and test case for same.
 
-- Issue #1161031: Fix readwrite select flag handling: POLLPRI now results in a
-  handle_expt_event call, not handle_read_event, and POLLERR and POLLNVAL now
-  call handle_close, not handle_expt_event.  Also, dispatcher now has an
+- bpo-1161031: Fix readwrite select flag handling: POLLPRI now results in a
+  handle_expt_event call, not handle_read_event, and POLLERR and POLLNVAL
+  now call handle_close, not handle_expt_event.  Also, dispatcher now has an
   'ignore_log_types' attribute for suppressing log messages, which is set to
   'warning' by default.
 
-- Issue #5607: Fixed Distutils test_get_platform for Mac OS X fat binaries.
+- bpo-5607: Fixed Distutils test_get_platform for Mac OS X fat binaries.
 
-- Issue #5741: Don't disallow "%%" (which is an escape for "%") when setting a
+- bpo-5741: Don't disallow "%%" (which is an escape for "%") when setting a
   value in SafeConfigParser.
 
-- Issue #5732: Added a new command in Distutils: check.
+- bpo-5732: Added a new command in Distutils: check.
 
-- Issue #5731: Distutils bdist_wininst no longer worked on non-Windows
+- bpo-5731: Distutils bdist_wininst no longer worked on non-Windows
   platforms.  Initial patch by Paul Moore.
 
-- Issue #2254: Fix CGIHTTPServer information disclosure.  Relative paths are now
-  collapsed within the url properly before looking in cgi_directories.
+- bpo-2254: Fix CGIHTTPServer information disclosure.  Relative paths are
+  now collapsed within the url properly before looking in cgi_directories.
 
-- Issue #5095: Added bdist_msi to the list of bdist supported formats.  Initial
+- bpo-5095: Added bdist_msi to the list of bdist supported formats.  Initial
   fix by Steven Bethard.
 
-- Issue #1491431: Fixed distutils.filelist.glob_to_re for edge cases.  Initial
+- bpo-1491431: Fixed distutils.filelist.glob_to_re for edge cases.  Initial
   fix by Wayne Davison.
 
-- Issue #5693: TestSuite.__iter__ can now be consistently overridden in
+- bpo-5693: TestSuite.__iter__ can now be consistently overridden in
   subclasses.
 
-- Issue #5694: Removed spurious test output in Distutils (test_clean).
+- bpo-5694: Removed spurious test output in Distutils (test_clean).
 
-- Issue #5471: Fix os.path.expanduser() for $HOME set to '/'.
+- bpo-5471: Fix os.path.expanduser() for $HOME set to '/'.
 
-- Issue #1326077: Fix the formatting of SyntaxErrors by the traceback module.
+- bpo-1326077: Fix the formatting of SyntaxErrors by the traceback module.
 
-- Issue #1726172: Fix IndexError in the case of and empty response in ftplib.
+- bpo-1726172: Fix IndexError in the case of and empty response in ftplib.
 
-- Issue #2625: Added missing iteritems() call to the for loop in
+- bpo-2625: Added missing iteritems() call to the for loop in
   mailbox.MH.get_message().
 
-- Issue #5585: Add the ability to call an initializer to
+- bpo-5585: Add the ability to call an initializer to
   multiprocessing.manager so that users can install custom handlers/etc.
 
-- Issue #3551: Patch multiprocessing to raise a proper exception if the size of
-  the object when writefile is called causes an ERROR_NO_SYSTEM_RESOURCES.  Added
-  docs to note the limitation.
+- bpo-3551: Patch multiprocessing to raise a proper exception if the size of
+  the object when writefile is called causes an ERROR_NO_SYSTEM_RESOURCES.
+  Added docs to note the limitation.
 
-- unittest.assertNotEqual() now uses the inequality operator (!=) instead of the
-  equality operator.
+- unittest.assertNotEqual() now uses the inequality operator (!=) instead of
+  the equality operator.
 
-- Issue #6001: Test discovery for unittest. Implemented in
+- bpo-6001: Test discovery for unittest. Implemented in
   unittest.TestLoader.discover and from the command line.
 
-- Issue #5679: The methods unittest.TestCase.addCleanup and doCleanups were
-  added.  addCleanup allows you to add cleanup functions that will be called
-  unconditionally (after setUp if setUp fails, otherwise after tearDown). This
-  allows for much simpler resource allocation and deallocation during tests.
+- bpo-5679: The methods unittest.TestCase.addCleanup and doCleanups were
+  added. addCleanup allows you to add cleanup functions that will be called
+  unconditionally (after setUp if setUp fails, otherwise after tearDown).
+  This allows for much simpler resource allocation and deallocation during
+  tests.
 
-- Issue #3379: unittest.main now takes an optional exit argument. If False main
-  doesn't call sys.exit allowing it to be used from the interactive interpreter.
+- bpo-3379: unittest.main now takes an optional exit argument. If False main
+  doesn't call sys.exit allowing it to be used from the interactive
+  interpreter.
 
-- Issue #5995: unittest.main now takes an optional verbosity argument allowing
+- bpo-5995: unittest.main now takes an optional verbosity argument allowing
   test modules to be run with a higher than default verbosity.
 
-- Issue #5995: A fix to allow you to run "python -m unittest test_module" or
+- bpo-5995: A fix to allow you to run "python -m unittest test_module" or
   "python -m unittest test_module.TestClass" from the command line.
 
-- Issue #5728: unittest.TestResult has new startTestRun and stopTestRun methods;
-  called immediately before and after a test run.
+- bpo-5728: unittest.TestResult has new startTestRun and stopTestRun
+  methods; called immediately before and after a test run.
 
-- Issue #5663: Better failure messages for unittest asserts. Default assertTrue
-  and assertFalse messages are now useful. TestCase has a longMessage attribute.
-  This defaults to False, but if set to True useful error messages are shown in
-  addition to explicit messages passed to assert methods.
+- bpo-5663: Better failure messages for unittest asserts. Default assertTrue
+  and assertFalse messages are now useful. TestCase has a longMessage
+  attribute. This defaults to False, but if set to True useful error
+  messages are shown in addition to explicit messages passed to assert
+  methods.
 
-- Issue #3110: Add additional protect around SEM_VALUE_MAX for multiprocessing.
+- bpo-3110: Add additional protect around SEM_VALUE_MAX for multiprocessing.
 
 - In Pdb, prevent the reassignment of __builtin__._ by sys.displayhook on
   printing out values.
 
-- Issue #4572: Added SEEK_* symbolic constants to io module.
+- bpo-4572: Added SEEK_* symbolic constants to io module.
 
-- Issue #1665206 (partially): Move imports in cgitb to the top of the module
-  instead of performing them in functions. Helps prevent import deadlocking in
-  threads.
+- bpo-1665206: Move imports in cgitb to the top of the module instead of
+  performing them in functions. Helps prevent import deadlocking in threads.
 
-- Issue #5647: MutableSet.__iand__() no longer mutates self during iteration.
+- bpo-5647: MutableSet.__iand__() no longer mutates self during iteration.
 
 - Actually make the SimpleXMLRPCServer CGI handler work.
 
-- Issue #2522: locale.format() now checks its first argument to ensure it has
+- bpo-2522: locale.format() now checks its first argument to ensure it has
   been passed only one pattern, avoiding mysterious errors where it appeared
   that it was failing to do localization.
 
-- Issue #5583: Added optional extensions in Distutils.  Initial patch by Georg
+- bpo-5583: Added optional extensions in Distutils.  Initial patch by Georg
   Brandl.
 
-- Issue #5619: Multiprocessing children disobey the debug flag and causes popups
-  on windows buildbots.  Patch applied to work around this issue.
+- bpo-5619: Multiprocessing children disobey the debug flag and causes
+  popups on windows buildbots.  Patch applied to work around this issue.
 
-- Issue #5632: Thread.ident was None for the main thread and threads not created
-  with the threading module.
+- bpo-5632: Thread.ident was None for the main thread and threads not
+  created with the threading module.
 
-- Issue #5400: Added patch for multiprocessing on netbsd compilation/support.
+- bpo-5400: Added patch for multiprocessing on netbsd compilation/support.
 
-- Issue #5387: Fixed mmap.move crash by integer overflow.
+- bpo-5387: Fixed mmap.move crash by integer overflow.
 
-- Issue #5261: Patch multiprocessing's semaphore.c to support context manager
+- bpo-5261: Patch multiprocessing's semaphore.c to support context manager
   use: "with multiprocessing.Lock()" works now.
 
-- Issue #5177: Multiprocessing's SocketListener class now uses
+- bpo-5177: Multiprocessing's SocketListener class now uses
   socket.SO_REUSEADDR on all connections so that the user no longer needs to
   wait 120 seconds for the socket to expire.
 
-- Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined
-  (part of issue #5035).
+- Adjusted _tkinter to compile without warnings when WITH_THREAD is not
+  defined (part of issue #5035).
 
-- Issue #5561: Removed the sys.version_info shortcuts from platform's
+- bpo-5561: Removed the sys.version_info shortcuts from platform's
   python_version() and python_version_tuple() since they produced different
   output compared to previous Python versions.
 
-- Issue #1034053: unittest now supports skipping tests and expected failures.
+- bpo-1034053: unittest now supports skipping tests and expected failures.
 
-- The unittest.TestCase.assertRaises() method now returns a context manager when
-  not given a callable so that code to be tested can be written inline using a
-  with statement.
+- The unittest.TestCase.assertRaises() method now returns a context manager
+  when not given a callable so that code to be tested can be written inline
+  using a with statement.
 
-- Issue #2578: The unittest.TestCase.assertEqual() now displays the differences
+- bpo-2578: The unittest.TestCase.assertEqual() now displays the differences
   in lists, tuples, dicts and sets on failure.  Many new handy type and
   comparison specific assert* methods have been added that fail with error
   messages actually useful for debugging.  Contributed in part by Google.
 
-- Issue #5068: Fixed the tarfile._BZ2Proxy.read() method that would loop forever
-  on incomplete input.  That caused tarfile.open() to hang when used with mode
-  'r' or 'r:bz2' and a fileobj argument that contained no data or partial bzip2
-  compressed data.
+- bpo-5068: Fixed the tarfile._BZ2Proxy.read() method that would loop
+  forever on incomplete input.  That caused tarfile.open() to hang when used
+  with mode 'r' or 'r:bz2' and a fileobj argument that contained no data or
+  partial bzip2 compressed data.
 
-- Issue #5536: urllib.urlretrieve makes sure to close the file it's writing to
+- bpo-5536: urllib.urlretrieve makes sure to close the file it's writing to
   even if an exception occurs.
 
-- Issue #5381: Added object_pairs_hook to the json module.  This allows
+- bpo-5381: Added object_pairs_hook to the json module.  This allows
   OrderedDicts to be built by the decoder.
 
-- Issue #2110: Add support for thousands separator and 'n' type specifier to
+- bpo-2110: Add support for thousands separator and 'n' type specifier to
   ``Decimal.__format__()``.
 
 - Fix Decimal.__format__ bug that swapped the meanings of the '<' and '>'
   alignment characters.
 
-- Issue #1222: ``locale.format()`` bug when the thousands separator is a space
+- bpo-1222: ``locale.format()`` bug when the thousands separator is a space
   character.
 
-- Issue #5472: Fixed distutils.test_util tear down. Original patch by Tim
+- bpo-5472: Fixed distutils.test_util tear down. Original patch by Tim
   Golden.
 
 - collections.deque objects now have a read-only attribute called maxlen.
 
-- Issue #2638: Show a window constructed with tkSimpleDialog.Dialog only after
-  it is has been populated and properly configured in order to prevent window
-  flashing.
+- bpo-2638: Show a window constructed with tkSimpleDialog.Dialog only after
+  it is has been populated and properly configured in order to prevent
+  window flashing.
 
-- Issue #4792: Prevent a segfault in _tkinter by using the guaranteed to be safe
-  interp argument given to the PythonCmd in place of the Tcl interpreter taken
-  from a PythonCmd_ClientData.
+- bpo-4792: Prevent a segfault in _tkinter by using the guaranteed to be
+  safe interp argument given to the PythonCmd in place of the Tcl
+  interpreter taken from a PythonCmd_ClientData.
 
-- Issue #5193: Guarantee that Tkinter.Text.search returns a string.
+- bpo-5193: Guarantee that Tkinter.Text.search returns a string.
 
-- Issue #5394: Removed > 2.3 syntax from distutils.msvc9compiler.
-  Original patch by Akira Kitada.
+- bpo-5394: Removed > 2.3 syntax from distutils.msvc9compiler. Original
+  patch by Akira Kitada.
 
-- Issue #5385: Fixed mmap crash after resize failure on windows.
+- bpo-5385: Fixed mmap crash after resize failure on windows.
 
-- Issue #5179: Fixed subprocess handle leak on failure on windows.
+- bpo-5179: Fixed subprocess handle leak on failure on windows.
 
 - PEP 372: Added collections.OrderedDict().
 
@@ -8676,697 +9117,708 @@ Library
 
 - The configparser module now defaults to using an ordered dictionary.
 
-- Issue #4308: httplib.IncompleteRead's repr doesn't include all of the data all
-  ready received.
+- bpo-4308: httplib.IncompleteRead's repr doesn't include all of the data
+  all ready received.
 
-- Issue #5401: Fixed a performance problem in mimetypes when ``from mimetypes
+- bpo-5401: Fixed a performance problem in mimetypes when ``from mimetypes
   import guess_extension`` was used.
 
-- Issue #1733986: Fixed mmap crash on Windows in accessing elements of second
+- bpo-1733986: Fixed mmap crash on Windows in accessing elements of second
   map object with same tagname but larger size than first map.
 
-- Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer
+- bpo-5386: mmap.write_byte didn't check map size, so it could cause buffer
   overrun.
 
-- Issue #1533164: Installed but not listed *.pyo was breaking Distutils
+- bpo-1533164: Installed but not listed *.pyo was breaking Distutils
   bdist_rpm command.
 
-- Issue #5378: Added --quiet option to Distutils bdist_rpm command.
+- bpo-5378: Added --quiet option to Distutils bdist_rpm command.
 
-- Issue #5052: Make Distutils compatible with 2.3 again.
+- bpo-5052: Make Distutils compatible with 2.3 again.
 
 - Deprecated methods of symtable.Symbol have been removed: is_keywordarg(),
   is_vararg(), and is_in_tuple().
 
-- Issue #5316: Fixed buildbot failures introduced by multiple inheritance in
+- bpo-5316: Fixed buildbot failures introduced by multiple inheritance in
   Distutils tests.
 
-- Issue #5287: Add exception handling around findCaller() call to help out
+- bpo-5287: Add exception handling around findCaller() call to help out
   IronPython.
 
-- Issue #5282: Fixed mmap resize on 32bit Windows and Unix.  When ``offset >
+- bpo-5282: Fixed mmap resize on 32bit Windows and Unix.  When ``offset >
   0``, the file was resized to wrong size.
 
-- Issue #5292: Fixed mmap crash on its boundary access m[len(m)].
+- bpo-5292: Fixed mmap crash on its boundary access m[len(m)].
 
-- Issue #2279: distutils.sdist.add_defaults now add files from the package_data
+- bpo-2279: distutils.sdist.add_defaults now add files from the package_data
   and the data_files metadata.
 
-- Issue #5257: Refactored all tests in distutils, so they use
+- bpo-5257: Refactored all tests in distutils, so they use
   support.TempdirManager, to avoid writing in the tests directory.
 
-- Issue #4524: distutils build_script command failed with --with-suffix=3.
+- bpo-4524: distutils build_script command failed with --with-suffix=3.
   Initial patch by Amaury Forgeot d'Arc.
 
-- Issue #2461: Added tests for distutils.util.
+- bpo-2461: Added tests for distutils.util.
 
-- Issue #1008086: Fixed socket.inet_aton() to always return 4 bytes even on LP64
-  platforms (most 64-bit Linux, bsd, unix systems).
+- bpo-1008086: Fixed socket.inet_aton() to always return 4 bytes even on
+  LP64 platforms (most 64-bit Linux, bsd, unix systems).
 
-- Issue #5203: Fixed ctypes segfaults when passing a unicode string to a
+- bpo-5203: Fixed ctypes segfaults when passing a unicode string to a
   function without argtypes (only occurs if HAVE_USABLE_WCHAR_T is false).
 
-- Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored
+- bpo-3386: distutils.sysconfig.get_python_lib prefix argument was ignored
   under NT and OS2. Patch by Philip Jenvey.
 
-- Issue #5128: Make compileall properly inspect bytecode to determine if needs
-  to be recreated.  This avoids a timing hole thanks to the old reliance on the
-  ctime of the files involved.
+- bpo-5128: Make compileall properly inspect bytecode to determine if needs
+  to be recreated.  This avoids a timing hole thanks to the old reliance on
+  the ctime of the files involved.
 
-- Issue #5122: Synchronize tk load failure check to prevent a potential
+- bpo-5122: Synchronize tk load failure check to prevent a potential
   deadlock.
 
-- Issue #1818: collections.namedtuple() now supports a keyword argument 'rename'
-  which lets invalid fieldnames be automatically converted to positional names
-  in the form, _1, _2, ...
+- bpo-1818: collections.namedtuple() now supports a keyword argument
+  'rename' which lets invalid fieldnames be automatically converted to
+  positional names in the form, _1, _2, ...
 
-- Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
+- bpo-4890: Handle empty text search pattern in Tkinter.Text.search.
 
-- Issue #5170: Fixed Unicode output bug in logging and added test case.  This is
-  a regression which did not occur in 2.5.
+- bpo-5170: Fixed Unicode output bug in logging and added test case.  This
+  is a regression which did not occur in 2.5.
 
-- Issue #4512 (part 2): Promote ``ZipImporter._get_filename()`` to be a public
+- bpo-4512: Promote ``ZipImporter._get_filename()`` to be a public
   documented method ``ZipImporter.get_filename()``.
 
-- Issue #4195: The ``runpy`` module (and the ``-m`` switch) now support the
-  execution of packages by looking for and executing a ``__main__`` submodule
-  when a package name is supplied. Initial patch by Andi Vajda.
+- bpo-4195: The ``runpy`` module (and the ``-m`` switch) now support the
+  execution of packages by looking for and executing a ``__main__``
+  submodule when a package name is supplied. Initial patch by Andi Vajda.
 
-- Issue #1731706: Call Tcl_ConditionFinalize for Tcl_Conditions that will not be
-  used again (this requires Tcl/Tk 8.3.1), also fix a memory leak in Tkapp_Call
-  when calling from a thread different than the one that created the Tcl
-  interpreter.  Patch by Robert Hancock.
+- bpo-1731706: Call Tcl_ConditionFinalize for Tcl_Conditions that will not
+  be used again (this requires Tcl/Tk 8.3.1), also fix a memory leak in
+  Tkapp_Call when calling from a thread different than the one that created
+  the Tcl interpreter.  Patch by Robert Hancock.
 
-- Issue #1520877: Now distutils.sysconfig reads $AR from the
+- bpo-1520877: Now distutils.sysconfig reads $AR from the
   environment/Makefile. Patch by Douglas Greiman.
 
-- Issue #4285: Change sys.version_info to be a named tuple.  Patch by Ross
+- bpo-4285: Change sys.version_info to be a named tuple.  Patch by Ross
   Light.
 
-- Issue #1276768: The verbose option was not used in the code of
+- bpo-1276768: The verbose option was not used in the code of
   distutils.file_util and distutils.dir_util.
 
-- Issue #5132: Fixed trouble building extensions under Solaris with
-  --enabled-shared activated. Initial patch by Dave Peterson.
+- bpo-5132: Fixed trouble building extensions under Solaris with --enabled-
+  shared activated. Initial patch by Dave Peterson.
 
-- Issue #1581476: Always use the Tcl global namespace when calling into Tcl.
+- bpo-1581476: Always use the Tcl global namespace when calling into Tcl.
 
-- Issue #2047: shutil.move() could believe that its destination path was inside
-  its source path if it began with the same letters (e.g. "src" vs.  "src.new").
+- bpo-2047: shutil.move() could believe that its destination path was inside
+  its source path if it began with the same letters (e.g. "src" vs.
+  "src.new").
 
-- Issue #4920: Fixed .next() vs .__next__() issues in the ABCs for Iterator and
+- bpo-4920: Fixed .next() vs .__next__() issues in the ABCs for Iterator and
   MutableSet.
 
 - Added the ttk module. See issue #2983: Ttk support for Tkinter.
 
-- Issue #5021: doctest.testfile() did not create __name__ and
+- bpo-5021: doctest.testfile() did not create __name__ and
   collections.namedtuple() relied on __name__ being defined.
 
-- Backport importlib from Python 3.1. Only the import_module() function has been
-  backported to help facilitate transitions from 2.7 to 3.1.
+- Backport importlib from Python 3.1. Only the import_module() function has
+  been backported to help facilitate transitions from 2.7 to 3.1.
 
-- Issue #1885: distutils: When running sdist with --formats=tar,gztar the tar
+- bpo-1885: distutils: When running sdist with --formats=tar,gztar the tar
   file was overridden by the gztar one.
 
-- Issue #4863: distutils.mwerkscompiler has been removed.
+- bpo-4863: distutils.mwerkscompiler has been removed.
 
-- Added new itertools functions: combinations_with_replacement() and compress().
+- Added new itertools functions: combinations_with_replacement() and
+  compress().
 
-- Issue #5032: Added a step argument to itertools.count() and allowed
-  non-integer arguments.
+- bpo-5032: Added a step argument to itertools.count() and allowed non-
+  integer arguments.
 
-- Fix and properly document the multiprocessing module's logging support, expose
-  the internal levels and provide proper usage examples.
+- Fix and properly document the multiprocessing module's logging support,
+  expose the internal levels and provide proper usage examples.
 
-- Issue #1672332: Fix unpickling of subnormal floats, which was
-  producing a ValueError on some platforms.
+- bpo-1672332: Fix unpickling of subnormal floats, which was producing a
+  ValueError on some platforms.
 
-- Issue #3881: Help Tcl to load even when started through the unreadable local
+- bpo-3881: Help Tcl to load even when started through the unreadable local
   symlink to "Program Files" on Vista.
 
-- Issue #4710: Extract directories properly in the zipfile module; allow adding
+- bpo-4710: Extract directories properly in the zipfile module; allow adding
   directories to a zipfile.
 
-- Issue #3807: _multiprocessing build fails when configure is passed
-  --without-threads argument. When this occurs, _multiprocessing will be
-  disabled, and not compiled.
+- bpo-3807: _multiprocessing build fails when configure is passed --without-
+  threads argument. When this occurs, _multiprocessing will be disabled, and
+  not compiled.
 
-- Issue #5008: When a file is opened in append mode with the new IO library, do
-  an explicit seek to the end of file (so that e.g. tell() returns the file size
-  rather than 0). This is consistent with the behaviour of the traditional 2.x
-  file object.
+- bpo-5008: When a file is opened in append mode with the new IO library, do
+  an explicit seek to the end of file (so that e.g. tell() returns the file
+  size rather than 0). This is consistent with the behaviour of the
+  traditional 2.x file object.
 
-- Issue #5013: Fixed a bug in FileHandler which occurred when the delay
+- bpo-5013: Fixed a bug in FileHandler which occurred when the delay
   parameter was set.
 
-- Issue #4998: The memory saving effect of __slots__ had been lost on Fractions
+- bpo-4998: The memory saving effect of __slots__ had been lost on Fractions
   which inherited from numbers.py which did not have __slots__ defined.  The
   numbers hierarchy now has its own __slots__ declarations.
 
-- Issue #3321: _multiprocessing.Connection() doesn't check handle; added checks
-  for *nix machines for negative handles and large int handles.  Without this
-  check it is possible to segfault the interpreter.
+- bpo-3321: _multiprocessing.Connection() doesn't check handle; added checks
+  for *nix machines for negative handles and large int handles.  Without
+  this check it is possible to segfault the interpreter.
 
-- Issue #4449: AssertionError in mp_benchmarks.py, caused by an underlying issue
-  in sharedctypes.py.
+- bpo-4449: AssertionError in mp_benchmarks.py, caused by an underlying
+  issue in sharedctypes.py.
 
-- Issue #1225107: inspect.isclass() returned True for instances with a custom
+- bpo-1225107: inspect.isclass() returned True for instances with a custom
   __getattr__.
 
-- Issue #3997: Zipfiles generated with more than 65536 files could not be opened
-  with other applications.
+- bpo-3997: Zipfiles generated with more than 65536 files could not be
+  opened with other applications.
 
-- Issue #1162154: ``inspect.getmembers()`` now skips attributes that raise
+- bpo-1162154: ``inspect.getmembers()`` now skips attributes that raise
   AttributeError, e.g. a __slots__ attribute which has not been set.
 
-- Issue #1696199: Add collections.Counter() for rapid and convenient counting.
+- bpo-1696199: Add collections.Counter() for rapid and convenient counting.
 
-- Issue #3860: GzipFile and BZ2File now support the context management protocol.
+- bpo-3860: GzipFile and BZ2File now support the context management
+  protocol.
 
-- Issue #4272: Add an optional argument to the GzipFile constructor to override
-  the timestamp in the gzip stream.  The default value remains the current time.
-  The information can be used by e.g. gunzip when decompressing.  Patch by
-  Jacques Frechet.
+- bpo-4272: Add an optional argument to the GzipFile constructor to override
+  the timestamp in the gzip stream.  The default value remains the current
+  time. The information can be used by e.g. gunzip when decompressing.
+  Patch by Jacques Frechet.
 
 - Restore Python 2.3 compatibility for decimal.py.
 
-- Issue #1702551: distutils sdist was not excluding VCS directories under
+- bpo-1702551: distutils sdist was not excluding VCS directories under
   Windows. Initial solution by Guy Dalberto.
 
 - The _tkinter module functions "createfilehandler", "deletefilehandler",
-  "createtimerhandler", "mainloop", "dooneevent" and "quit" have been deprecated
-  for removal in 3.x
+  "createtimerhandler", "mainloop", "dooneevent" and "quit" have been
+  deprecated for removal in 3.x
 
-- Issue #4796: Added Decimal.from_float() and
+- bpo-4796: Added Decimal.from_float() and
   Context.create_decimal_from_float() to the decimal module.
 
-- Issue #4812: Add missing underscore prefix to some internal-use-only constants
-  in the decimal module.  (Dec_0 becomes _Dec_0, etc.)
+- bpo-4812: Add missing underscore prefix to some internal-use-only
+  constants in the decimal module.  (Dec_0 becomes _Dec_0, etc.)
 
-- Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
+- bpo-4795: inspect.isgeneratorfunction() returns False instead of None when
   the function is not a generator.
 
-- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case no
+- bpo-4702: Throwing a DistutilsPlatformError instead of IOError in case no
   MSVC compiler is found under Windows.  Original patch by Philip Jenvey.
 
-- Issue #4646: distutils was choking on empty options arg in the setup function.
-  Original patch by Thomas Heller.
+- bpo-4646: distutils was choking on empty options arg in the setup
+  function. Original patch by Thomas Heller.
 
-- Fractions.from_float() no longer loses precision for integers too big to cast
-  as floats.
+- Fractions.from_float() no longer loses precision for integers too big to
+  cast as floats.
 
-- Issue #4790: The nsmallest() and nlargest() functions in the heapq module did
+- bpo-4790: The nsmallest() and nlargest() functions in the heapq module did
   unnecessary work in the common case where no key function was specified.
 
-- Issue #3767: Convert Tk object to string in tkColorChooser.
+- bpo-3767: Convert Tk object to string in tkColorChooser.
 
-- Issue #3248: Allow placing ScrolledText in a PanedWindow.
+- bpo-3248: Allow placing ScrolledText in a PanedWindow.
 
-- Issue #4444: Allow assertRaises() to be used as a context handler, so that the
-  code under test can be written inline if more practical.
+- bpo-4444: Allow assertRaises() to be used as a context handler, so that
+  the code under test can be written inline if more practical.
 
-- Issue #4739: Add pydoc help topics for symbols, so that e.g. help('@') works
+- bpo-4739: Add pydoc help topics for symbols, so that e.g. help('@') works
   as expected in the interactive environment.
 
-- Issue #4756: zipfile.is_zipfile() now supports file-like objects. Patch by
+- bpo-4756: zipfile.is_zipfile() now supports file-like objects. Patch by
   Gabriel Genellina.
 
-- Issue #4400: .pypirc default generated file was broken in distutils.
+- bpo-4400: .pypirc default generated file was broken in distutils.
 
-- Issue #4736: io.BufferedRWPair's closed property now functions properly.
+- bpo-4736: io.BufferedRWPair's closed property now functions properly.
 
-- Issue #3954: Fix a potential SystemError in _hotshot.logreader error handling.
+- bpo-3954: Fix a potential SystemError in _hotshot.logreader error
+  handling.
 
-- Issue #4574: Fix a crash in io.IncrementalNewlineDecoder when a carriage
-  return encodes to more than one byte in the source encoding (e.g. UTF-16) and
-  gets split on a chunk boundary.
+- bpo-4574: Fix a crash in io.IncrementalNewlineDecoder when a carriage
+  return encodes to more than one byte in the source encoding (e.g. UTF-16)
+  and gets split on a chunk boundary.
 
-- Issue #4223: inspect.getsource() will now correctly display source code for
-  packages loaded via zipimport (or any other conformant PEP 302
-  loader). Original patch by Alexander Belopolsky.
+- bpo-4223: inspect.getsource() will now correctly display source code for
+  packages loaded via zipimport (or any other conformant PEP 302 loader).
+  Original patch by Alexander Belopolsky.
 
-- Issue #4201: pdb can now access and display source code loaded via zipimport
+- bpo-4201: pdb can now access and display source code loaded via zipimport
   (or any other conformant PEP 302 loader).  Original patch by Alexander
   Belopolsky.
 
-- Issue #4197: Doctests in modules loaded via zipimport (or any other PEP 302
+- bpo-4197: Doctests in modules loaded via zipimport (or any other PEP 302
   conformant loader) will now work correctly in most cases (they are still
   subject to the constraints that exist for all code running from inside a
   module loaded via a PEP 302 loader and attempting to perform IO operations
-  based on __file__).  Original patch by Alexander Belopolsky.
+  based on __file__). Original patch by Alexander Belopolsky.
 
-- Issues #4082 and #4512: Add runpy support to zipimport in a manner that allows
-  backporting to maintenance branches.  Original patch by Alexander Belopolsky.
+- bpo-4082: Add runpy support to zipimport in a manner that allows
+  backporting to maintenance branches.  Original patch by Alexander
+  Belopolsky. (See also: bpo-4512)
 
-- Issue #4163: Use unicode-friendly word splitting in the textwrap functions
+- bpo-4163: Use unicode-friendly word splitting in the textwrap functions
   when given a Unicode string.
 
-- Issue #4616: TarFile.utime(): Restore directory times on Windows.
+- bpo-4616: TarFile.utime(): Restore directory times on Windows.
 
-- Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to give correct
-  results in the case where one argument is a quiet NaN and the other is a
-  finite number that requires rounding.
+- bpo-4084: Fix max, min, max_mag and min_mag Decimal methods to give
+  correct results in the case where one argument is a quiet NaN and the
+  other is a finite number that requires rounding.
 
-- Issue #1030250: Distutils created directories even when run with the --dry-run
-  option.
+- bpo-1030250: Distutils created directories even when run with the --dry-
+  run option.
 
-- Issue #4483: _dbm module now builds on systems with gdbm & gdbm_compat libs.
+- bpo-4483: _dbm module now builds on systems with gdbm & gdbm_compat libs.
 
-- Issue #4529: Fix the parser module's validation of try-except-finally
+- bpo-4529: Fix the parser module's validation of try-except-finally
   statements.
 
-- Issue #4458: getopt.gnu_getopt() now recognizes a single "-" as an argument,
+- bpo-4458: getopt.gnu_getopt() now recognizes a single "-" as an argument,
   not a malformed option.
 
-- Added the subprocess.check_output() convenience function to get output from a
-  subprocess on success or raise an exception on error.
+- Added the subprocess.check_output() convenience function to get output
+  from a subprocess on success or raise an exception on error.
 
-- Issue #1055234: cgi.parse_header(): Fixed parsing of header parameters to
+- bpo-1055234: cgi.parse_header(): Fixed parsing of header parameters to
   support unusual filenames (such as those containing semi-colons) in
   Content-Disposition headers.
 
-- Issue #4384: Added logging integration with warnings module using
-  captureWarnings().  This change includes a NullHandler which does nothing; it
-  will be of use to library developers who want to avoid the "No handlers could
-  be found for logger XXX" message which can appear if the library user doesn't
-  configure logging.
+- bpo-4384: Added logging integration with warnings module using
+  captureWarnings(). This change includes a NullHandler which does nothing;
+  it will be of use to library developers who want to avoid the "No handlers
+  could be found for logger XXX" message which can appear if the library
+  user doesn't configure logging.
 
-- Issue #3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an
+- bpo-3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an
   exception.
 
-- Issue #4363: The uuid.uuid1() and uuid.uuid4() functions now work even if the
+- bpo-4363: The uuid.uuid1() and uuid.uuid4() functions now work even if the
   ctypes module is not present.
 
 - FileIO's mode attribute now always includes ``"b"``.
 
-- Issue #4116: Resolve member name conflict in ScrolledCanvas.__init__.
+- bpo-4116: Resolve member name conflict in ScrolledCanvas.__init__.
 
-- httplib.HTTPConnection.putheader() now accepts an arbitrary number of values
-  for any header, matching what the documentation has claimed for a while.
+- httplib.HTTPConnection.putheader() now accepts an arbitrary number of
+  values for any header, matching what the documentation has claimed for a
+  while.
 
-- Issue #3774: Fixed an error when create a Tkinter menu item without command
+- bpo-3774: Fixed an error when create a Tkinter menu item without command
   and then remove it.
 
 - Fixed a modulefinder crash on certain relative imports.
 
-- Issue #4150: Pdb's "up" command now works for generator frames in post-mortem
+- bpo-4150: Pdb's "up" command now works for generator frames in post-mortem
   debugging.
 
-- Issue #4092: Return ArgInfo as promised in the documentation from
+- bpo-4092: Return ArgInfo as promised in the documentation from
   inspect.getargvalues.
 
-- Issue #3935: Properly support list subclasses in bisect's C implementation.
+- bpo-3935: Properly support list subclasses in bisect's C implementation.
 
-- Issue #4014: Don't claim that Python has an Alpha release status, in addition
+- bpo-4014: Don't claim that Python has an Alpha release status, in addition
   to claiming it is Mature.
 
-- Issue #4730: Fixed the cPickle module to handle correctly astral characters
+- bpo-4730: Fixed the cPickle module to handle correctly astral characters
   when protocol 0 is used.
 
-- Issue #1594: MacOS.GetCreatorAndType now always returns a big-endian result,
+- bpo-1594: MacOS.GetCreatorAndType now always returns a big-endian result,
   to be consistent with Apple tools.
 
-- Issue #900949: plat-mac/videoreader.py no longer relies on a non-existing
+- bpo-900949: plat-mac/videoreader.py no longer relies on a non-existing
   module.
 
-- Issue #16278952: plat-mac/videoreader.py now correctly imports MediaDescr
+- bpo-16278952: plat-mac/videoreader.py now correctly imports MediaDescr
 
-- Issue #1737832: plat-mac/EasyDialog.py no longer uses the broken aepack
+- bpo-1737832: plat-mac/EasyDialog.py no longer uses the broken aepack
   module.
 
-- Issue #1149804: macostools.mkdirs now even works when another process creates
+- bpo-1149804: macostools.mkdirs now even works when another process creates
   one of the needed subdirectories.
 
-- Issue #900506: added --no-zipimport flag to the bundlebuilder script.
+- bpo-900506: added --no-zipimport flag to the bundlebuilder script.
 
-- Issue #841800: bundlebuilder now works with 'python -O'.
+- bpo-841800: bundlebuilder now works with 'python -O'.
 
-- Issue #4861: ctypes.util.find_library(): Robustify. Fix library detection on
-  biarch systems.  Try to rely on ldconfig only, without using objdump and gcc.
+- bpo-4861: ctypes.util.find_library(): Robustify. Fix library detection on
+  biarch systems.  Try to rely on ldconfig only, without using objdump and
+  gcc.
 
-- Issue #5104: The socket module now raises OverflowError when 16-bit port and
-  protocol numbers are supplied outside the allowed 0-65536 range on bind() and
-  getservbyport().
+- bpo-5104: The socket module now raises OverflowError when 16-bit port and
+  protocol numbers are supplied outside the allowed 0-65536 range on bind()
+  and getservbyport().
 
-- Issue #999042: The Python compiler now handles explict global statements
+- bpo-999042: The Python compiler now handles explict global statements
   correctly (should be assigned using STORE_GLOBAL opcode).
 
-- Issue #2703: SimpleXMLRPCDispatcher.__init__: Provide default values for new
+- bpo-2703: SimpleXMLRPCDispatcher.__init__: Provide default values for new
   arguments introduced in 2.5.
 
-- Issue #5828 (Invalid behavior of unicode.lower): Fixed bogus logic in
-  makeunicodedata.py and regenerated the Unicode database (This fixes
-  u'\u1d79'.lower() == '\x00').
+- bpo-5828: Fixed bogus logic in makeunicodedata.py and regenerated the
+  Unicode database (This fixes u'\u1d79'.lower() == '\x00').
 
 - Windows locale mapping updated to Vista.
 
 IDLE
 ----
 
-- Issue #5150: IDLE's format menu now has an option to strip trailing
+- bpo-5150: IDLE's format menu now has an option to strip trailing
   whitespace.
 
-- Issue #5847: Remove -n switch on "Edit with IDLE" menu item.
+- bpo-5847: Remove -n switch on "Edit with IDLE" menu item.
 
 - idle.py modified and simplified to better support developing experimental
   versions of IDLE which are not installed in the standard location.
 
-- Issue #5559: OutputWindow/PyShell right click menu "Go to file/line"
-  wasn't working with file paths containing spaces.
+- bpo-5559: OutputWindow/PyShell right click menu "Go to file/line" wasn't
+  working with file paths containing spaces.
 
-- Issue #5783: Windows: Version string for the .chm help file changed,
-  file not being accessed.  Patch by Guilherme Polo/
+- bpo-5783: Windows: Version string for the .chm help file changed, file not
+  being accessed.  Patch by Guilherme Polo/
 
-- Issue #1529142: Allow multiple IDLE GUI/subprocess pairs to exist
+- bpo-1529142: Allow multiple IDLE GUI/subprocess pairs to exist
   simultaneously. Thanks to David Scherer for suggesting the use of an
-  ephemeral port for the GUI.  Patch by Weeble.
+  ephemeral port for the GUI. Patch by Weeble.
 
-- Remove port spec from run.py and fix bug where subprocess fails to
-  extract port from command line when warnings are present.
+- Remove port spec from run.py and fix bug where subprocess fails to extract
+  port from command line when warnings are present.
 
-- Issue #5129: Tk 8.5 Text widget requires 'wordprocessor' tabstyle attr
-  to handle mixed space/tab properly. Patch by Guilherme Polo.
+- bpo-5129: Tk 8.5 Text widget requires 'wordprocessor' tabstyle attr to
+  handle mixed space/tab properly. Patch by Guilherme Polo.
 
-- Issue #3549: On MacOS the preferences menu was not present
+- bpo-3549: On MacOS the preferences menu was not present
 
 Tools/Demos
 -----------
 
 - Ttk demos added in Demo/tkinter/ttk/.
 
-- Issue #4677: Add two list comprehension tests to pybench.
+- bpo-4677: Add two list comprehension tests to pybench.
 
 Build
 -----
 
-- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it compiles
+- bpo-6603: Change READ_TIMESTAMP macro in ceval.c so that it compiles
   correctly under gcc on x86-64.  This fixes a reported problem with the
   --with-tsc build on x86-64.
 
-- Add 2 new options to ``--with-universal-archs`` on MacOSX: ``intel`` builds a
-  distribution with ``i386`` and ``x86_64`` architectures, while ``3-way``
-  builds a distribution with the ``ppc``, ``i386`` and ``x86_64`` architectures.
+- Add 2 new options to ``--with-universal-archs`` on MacOSX: ``intel``
+  builds a distribution with ``i386`` and ``x86_64`` architectures, while
+  ``3-way`` builds a distribution with the ``ppc``, ``i386`` and ``x86_64``
+  architectures.
 
-- Issue #6802: Fix build issues on MacOSX 10.6.
+- bpo-6802: Fix build issues on MacOSX 10.6.
 
-- Issue #6244: Allow detect_tkinter to look for Tcl/Tk 8.6.
+- bpo-6244: Allow detect_tkinter to look for Tcl/Tk 8.6.
 
-- Issue #5390: Add uninstall icon independent of whether file extensions are
+- bpo-5390: Add uninstall icon independent of whether file extensions are
   installed.
 
-- Issue #5809: Specifying both --enable-framework and --enable-shared is an
+- bpo-5809: Specifying both --enable-framework and --enable-shared is an
   error. Configure now explicitly tells you about this.
 
-- Issue #3585: Add pkg-config support.  It creates a python-2.7.pc file and a
-  python.pc symlink in the $(LIBDIR)/pkgconfig directory.  Patch by Clinton Roy.
+- bpo-3585: Add pkg-config support.  It creates a python-2.7.pc file and a
+  python.pc symlink in the $(LIBDIR)/pkgconfig directory.  Patch by Clinton
+  Roy.
 
-- Issue #6094: Build correctly with Subversion 1.7.
+- bpo-6094: Build correctly with Subversion 1.7.
 
-- Issue #5726: Make Modules/ld_so_aix return the actual exit code of the linker,
-  rather than always exit successfully.  Patch by Floris Bruynooghe.
+- bpo-5726: Make Modules/ld_so_aix return the actual exit code of the
+  linker, rather than always exit successfully.  Patch by Floris Bruynooghe.
 
-- Issue #4587: Add configure option --with-dbmliborder=db1:db2:... to specify
+- bpo-4587: Add configure option --with-dbmliborder=db1:db2:... to specify
   the order that backends for the dbm extension are checked.
 
 - Link the shared python library with $(MODLIBS).
 
-- Issue #5134: Silence compiler warnings when compiling sqlite with VC++.
+- bpo-5134: Silence compiler warnings when compiling sqlite with VC++.
 
-- Issue #4494: Fix build with Py_NO_ENABLE_SHARED on Windows.
+- bpo-4494: Fix build with Py_NO_ENABLE_SHARED on Windows.
 
-- Issue #4895: Use _strdup on Windows CE.
+- bpo-4895: Use _strdup on Windows CE.
 
-- Issue #4472: ``configure --enable-shared`` now works on OSX.
+- bpo-4472: ``configure --enable-shared`` now works on OSX.
 
-- Issues #4728 and #4060: WORDS_BIGEDIAN is now correct in Universal builds.
+- bpo-4728: WORDS_BIGEDIAN is now correct in Universal builds. (See also:
+  bpo-4060)
 
-- Issue #4389: Add icon to the uninstall entry in "add-and-remove-programs".
+- bpo-4389: Add icon to the uninstall entry in "add-and-remove-programs".
 
-- Issue #4289: Remove Cancel button from AdvancedDlg.
+- bpo-4289: Remove Cancel button from AdvancedDlg.
 
-- Issue #1656675: Register a drop handler for .py* files on Windows.
+- bpo-1656675: Register a drop handler for .py* files on Windows.
 
-- Issue #4120: Exclude manifest from extension modules in VS2008.
+- bpo-4120: Exclude manifest from extension modules in VS2008.
 
-- Issue #4091: Install pythonxy.dll in system32 again.
+- bpo-4091: Install pythonxy.dll in system32 again.
 
-- Issue #4018: Disable "for me" installations on Vista.
+- bpo-4018: Disable "for me" installations on Vista.
 
-- Issue #3758: Add ``patchcheck`` build target to ``.PHONY``.
+- bpo-3758: Add ``patchcheck`` build target to ``.PHONY``.
 
-- Issue #4204: Fixed module build errors on FreeBSD 4.
+- bpo-4204: Fixed module build errors on FreeBSD 4.
 
 Documentation
 -------------
 
-- Issue #6556: Fixed the Distutils configuration files location explanation for
+- bpo-6556: Fixed the Distutils configuration files location explanation for
   Windows.
 
-- Issue #6801: symmetric_difference_update also accepts ``|``.  Thanks to Carl
+- bpo-6801: symmetric_difference_update also accepts ``|``.  Thanks to Carl
   Chenet.
 
-C-API
+C API
 -----
 
-- Issue #7528: Add PyLong_AsLongAndOverflow (backported from py3k).
+- bpo-7528: Add PyLong_AsLongAndOverflow (backported from py3k).
 
-- Issue #7228: Add '%lld' and '%llu' support to PyString_FromFormat(V) and
+- bpo-7228: Add '%lld' and '%llu' support to PyString_FromFormat(V) and
   PyErr_Format, on machines with HAVE_LONG_LONG defined.
 
-- Add new C-API function PyOS_string_to_double, and deprecated PyOS_ascii_atof
-  and PyOS_ascii_strtod.
+- Add new C-API function PyOS_string_to_double, and deprecated
+  PyOS_ascii_atof and PyOS_ascii_strtod.
 
-- Removed _PyOS_double_to_string. Use PyOS_double_to_string instead.  This is in
-  preparation for (but not strictly related to) issue #7117, short float repr.
+- Removed _PyOS_double_to_string. Use PyOS_double_to_string instead.  This
+  is in preparation for (but not strictly related to) issue #7117, short
+  float repr.
 
-- Issue #6624: PyArg_ParseTuple with "s" format when parsing argument with NULL:
-  Bogus TypeError detail string.
+- bpo-6624: PyArg_ParseTuple with "s" format when parsing argument with
+  NULL: Bogus TypeError detail string.
 
-- Issue #5954: Add a PyFrame_GetLineNumber() function to replace most uses of
+- bpo-5954: Add a PyFrame_GetLineNumber() function to replace most uses of
   PyCode_Addr2Line().
 
-- Issue #5959: Add a PyCode_NewEmpty() function to create a new empty code
+- bpo-5959: Add a PyCode_NewEmpty() function to create a new empty code
   object at a specified file, function, and line number.
 
-- Issue #1419652: Change the first argument to PyImport_AppendInittab() to
+- bpo-1419652: Change the first argument to PyImport_AppendInittab() to
   ``const char *`` as the string is stored beyond the call.
 
 - Some PyBytes_* aliases have been removed because they don't exist in 3.x.
 
-- Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for negative
-  arguments.  Previously, it raised TypeError.
+- bpo-5175: PyLong_AsUnsignedLongLong now raises OverflowError for negative
+  arguments. Previously, it raised TypeError.
 
-- Issue #4720: The format for PyArg_ParseTupleAndKeywords can begin with '|'.
+- bpo-4720: The format for PyArg_ParseTupleAndKeywords can begin with '|'.
 
-- Issue #3632: From the gdb debugger, the 'pyo' macro can now be called when the
-  GIL is released, or owned by another thread.
+- bpo-3632: From the gdb debugger, the 'pyo' macro can now be called when
+  the GIL is released, or owned by another thread.
 
-- Issue #4122: On Windows, fix a compilation error when using the
+- bpo-4122: On Windows, fix a compilation error when using the
   Py_UNICODE_ISSPACE macro in an extension module.
 
-- Issue #4293: Py_AddPendingCall() is now thread safe and can be used for
-  asynchronous notifications to python from any thread.  Documentation added.
+- bpo-4293: Py_AddPendingCall() is now thread safe and can be used for
+  asynchronous notifications to python from any thread.  Documentation
+  added.
 
-Extension Modules
------------------
+Library
+-------
 
-- Issue #6508: Add posix.{getresuid,getresgid,setresuid,setresgid}.
+- bpo-6508: Add posix.{getresuid,getresgid,setresuid,setresgid}.
 
-- Issue #7078: Set struct.__doc__ from _struct.__doc__.
+- bpo-7078: Set struct.__doc__ from _struct.__doc__.
 
-- Issue #3366: Add erf, erfc, expm1, gamma, lgamma functions to math module.
+- bpo-3366: Add erf, erfc, expm1, gamma, lgamma functions to math module.
 
-- Issue #6823: Allow time.strftime() to accept a tuple with a isdst field
-  outside of the range of [-1, 1] by normalizing the value to within that range.
+- bpo-6823: Allow time.strftime() to accept a tuple with a isdst field
+  outside of the range of [-1, 1] by normalizing the value to within that
+  range.
 
-- Issue #6877: Make it possible to link the readline extension to libedit on
+- bpo-6877: Make it possible to link the readline extension to libedit on
   OSX.
 
-- Issue #6944: Fix a SystemError when socket.getnameinfo() was called with
+- bpo-6944: Fix a SystemError when socket.getnameinfo() was called with
   something other than a tuple as first argument.
 
-- Issue #6865: Fix reference counting issue in the initialization of the pwd
+- bpo-6865: Fix reference counting issue in the initialization of the pwd
   module.
 
-- Issue #6848: Fix curses module build failure on OS X 10.6.
+- bpo-6848: Fix curses module build failure on OS X 10.6.
 
 - Fix a segfault in expat when given a specially crafted input lead to the
   tokenizer not stopping. CVE-2009-3720.
 
-- Issue #6561: '\d' in a regex now matches only characters with Unicode category
-  'Nd' (Number, Decimal Digit).  Previously it also matched characters with
-  category 'No'.
+- bpo-6561: '\d' in a regex now matches only characters with Unicode
+  category 'Nd' (Number, Decimal Digit).  Previously it also matched
+  characters with category 'No'.
 
-- Issue #1523: Remove deprecated overflow wrapping for struct.pack with an
+- bpo-1523: Remove deprecated overflow wrapping for struct.pack with an
   integer format code ('bBhHiIlLqQ').  Packing an out-of-range integer now
   consistently raises struct.error.
 
-- Issues #1530559, #1741130: Fix various struct.pack inconsistencies for the
-  integer formats ('bBhHiIlLqQ').  In the following, '*' represents any of '=',
-  '<', '>'.
+- bpo-1530559: Fix various struct.pack inconsistencies for the integer
+  formats ('bBhHiIlLqQ').  In the following, '*' represents any of '=', '<',
+  '>'.
 
-    - Packing a float now always gives a Deprecation Warning.  Previously it
-      only warned for 'I', 'L', '*B', '*H', '*I', '*L'.
+  - Packing a float now always gives a Deprecation Warning.  Previously it
+  only warned for 'I', 'L', '*B', '*H', '*I', '*L'.
 
-    - If x is not an int, long or float, then packing x will always result in
-      struct.error.  Previously an x with an __int__ method could be packed by
-      'b', 'B', 'h', 'H', 'i', 'l', '*b', '*h' ,'*i', '*l', and an x with a
-      __long__ method could be packed by 'q', 'Q', '*q', '*Q'; for x with
-      neither __int__ nor __long__, TypeError used to be raised (with a
-      confusing error message) for 'I', 'L', '*B', '*H', '*I', '*L', and
-      struct.error in other cases.
+  - If x is not an int, long or float, then packing x will always result in
+  struct.error.  Previously an x with an __int__ method could be packed by
+  'b', 'B', 'h', 'H', 'i', 'l', '*b', '*h' ,'*i', '*l', and an x with a
+  __long__ method could be packed by 'q', 'Q', '*q', '*Q'; for x with
+  neither __int__ nor __long__, TypeError used to be raised (with a
+  confusing error message) for 'I', 'L', '*B', '*H', '*I', '*L', and
+  struct.error in other cases.
 
-  Note: as of Python 2.7 beta 1, the above is out of date.  In 2.7 beta 1, any
-  argument with an __int__ method can be packed, but use of this feature
-  triggers a DeprecationWarning.
+  Note: as of Python 2.7 beta 1, the above is out of date.  In 2.7 beta 1,
+  any argument with an __int__ method can be packed, but use of this feature
+  triggers a DeprecationWarning. (See also: bpo-1741130)
 
-- Issue #4873: Fix resource leaks in error cases of pwd and grp.
+- bpo-4873: Fix resource leaks in error cases of pwd and grp.
 
-- Issue #4751: For hashlib algorithms provided by OpenSSL, the Python GIL is now
-  released during computation on data lengths >= 2048 bytes.
+- bpo-4751: For hashlib algorithms provided by OpenSSL, the Python GIL is
+  now released during computation on data lengths >= 2048 bytes.
 
-- Issue #3745: Fix hashlib to always reject unicode and non buffer-api
+- bpo-3745: Fix hashlib to always reject unicode and non buffer-api
   supporting objects as input no matter how it was compiled (built in
   implementations or external openssl library).  NOTE: Undone in 2.7a2.
 
-- Issue #4397: Fix occasional test_socket failure on OS X.
+- bpo-4397: Fix occasional test_socket failure on OS X.
 
-- Issue #4279: Fix build of parsermodule under Cygwin.
+- bpo-4279: Fix build of parsermodule under Cygwin.
 
-- Issue #4051: Prevent conflict of UNICODE macros in cPickle.
+- bpo-4051: Prevent conflict of UNICODE macros in cPickle.
 
-- Issue #4228: Pack negative values the same way as 2.4 in struct's L format.
+- bpo-4228: Pack negative values the same way as 2.4 in struct's L format.
 
-- Issue #1040026: Fix os.times result on systems where HZ is incorrect.
+- bpo-1040026: Fix os.times result on systems where HZ is incorrect.
 
-- Issues #3167, #3682: Fix test_math failures for log, log10 on Solaris,
-  OpenBSD.
+- bpo-3167: Fix test_math failures for log, log10 on Solaris, OpenBSD. (See
+  also: bpo-3682)
 
-- Issue #4365: Add crtassem.h constants to the msvcrt module.
+- bpo-4365: Add crtassem.h constants to the msvcrt module.
 
-- Issue #4396: The parser module now correctly validates the with statement.
+- bpo-4396: The parser module now correctly validates the with statement.
 
-- Issue #5228: Make functools.partial objects can now be pickled.
+- bpo-5228: Make functools.partial objects can now be pickled.
 
 Tests
 -----
 
-- Issue #7431: Use TESTFN in test_linecache instead of trying to create a file
-  in the Lib/test directory, which might be read-only for the user running the
-  tests.
+- bpo-7431: Use TESTFN in test_linecache instead of trying to create a file
+  in the Lib/test directory, which might be read-only for the user running
+  the tests.
 
-- Issue #7324: Add a sanity check to regrtest argument parsing to catch the case
-  of an option with no handler.
+- bpo-7324: Add a sanity check to regrtest argument parsing to catch the
+  case of an option with no handler.
 
-- Issue #7312: Add a -F flag to run the selected tests in a loop until a test
+- bpo-7312: Add a -F flag to run the selected tests in a loop until a test
   fails.  Can be combined with -j.
 
-- Issue #7295: Do not use a hardcoded file name in test_tarfile.
+- bpo-7295: Do not use a hardcoded file name in test_tarfile.
 
-- Issue #7270: Add some dedicated unit tests for multi-thread synchronization
+- bpo-7270: Add some dedicated unit tests for multi-thread synchronization
   primitives such as Lock, RLock, Condition, Event and Semaphore.
 
-- Issue #7222: Make thread "reaping" more reliable so that reference
-  leak-chasing test runs give sensible results.  The previous method of reaping
+- bpo-7222: Make thread "reaping" more reliable so that reference leak-
+  chasing test runs give sensible results.  The previous method of reaping
   threads could return successfully while some Thread objects were still
-  referenced.  This also introduces a new private function: ``thread._count()``.
+  referenced.  This also introduces a new private function:
+  ``thread._count()``.
 
-- Issue #7151: Fixed regrtest -j so that output to stderr from a test no longer
+- bpo-7151: Fixed regrtest -j so that output to stderr from a test no longer
   runs the risk of causing the worker thread to fail.
 
-- Issue #7055: test___all__ now greedily detects all modules which have an
+- bpo-7055: test___all__ now greedily detects all modules which have an
   __all__ attribute, rather than using a hardcoded and incomplete list.
 
-- Issue #7058: Added save/restore for things like sys.argv and cwd to
+- bpo-7058: Added save/restore for things like sys.argv and cwd to
   runtest_inner in regrtest, with warnings if the called test modifies them,
   and a new section in the summary report at the end.
 
-- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6.
+- bpo-7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6.
 
-- Issue #6806: test_platform failed under OS X 10.6.0 because ``sw_ver`` leaves
+- bpo-6806: test_platform failed under OS X 10.6.0 because ``sw_ver`` leaves
   off the trailing 0 in the version number.
 
-- Issue #5450: Moved tests involving loading tk from Lib/test/test_tcl to
-  Lib/lib-tk/test/test_tkinter/test_loadtk. With this, these tests demonstrate
-  the same behaviour as test_ttkguionly (and now also test_tk) which is to skip
-  the tests if DISPLAY is defined but can't be used.
+- bpo-5450: Moved tests involving loading tk from Lib/test/test_tcl to
+  Lib/lib- tk/test/test_tkinter/test_loadtk. With this, these tests
+  demonstrate the same behaviour as test_ttkguionly (and now also test_tk)
+  which is to skip the tests if DISPLAY is defined but can't be used.
 
-- Issue #6152: New option '-j'/'--multiprocess' for regrtest allows running
+- bpo-6152: New option '-j'/'--multiprocess' for regrtest allows running
   regression tests in parallel, shortening the total runtime.
 
-- Issue #5354: New test support function import_fresh_module() makes it easy to
+- bpo-5354: New test support function import_fresh_module() makes it easy to
   import both normal and optimised versions of modules.  test_heapq and
-  test_warnings have been adjusted to use it, tests for other modules with both
-  C and Python implementations in the stdlib can be adjusted to use it over
-  time.
+  test_warnings have been adjusted to use it, tests for other modules with
+  both C and Python implementations in the stdlib can be adjusted to use it
+  over time.
 
 - Fix test_warnings to no longer reset the warnings filter.
 
 - Fix test_logging to no longer reset the warnings filter.
 
-- Issue #5635: Fix running test_sys with tracing enabled.
+- bpo-5635: Fix running test_sys with tracing enabled.
 
-- regrtest no longer treats ImportError as equivalent to SkipTest.  Imports that
-  should cause a test to be skipped are now done using import_module from test
-  support, which does the conversion.
+- regrtest no longer treats ImportError as equivalent to SkipTest.  Imports
+  that should cause a test to be skipped are now done using import_module
+  from test support, which does the conversion.
 
-- Issue #5083: New 'gui' resource for regrtest.
+- bpo-5083: New 'gui' resource for regrtest.
 
-- Issue #5837: Certain sequences of calls to set() and unset() for
+- bpo-5837: Certain sequences of calls to set() and unset() for
   support.EnvironmentVarGuard objects restored the environment variables
   incorrectly on __exit__.
 
-- Issue #2389: Array objects are now pickled in a portable manner.
+- bpo-2389: Array objects are now pickled in a portable manner.
 
-Misc
-----
+Windows
+-------
 
-- Issue #5611: Auto-detect whether a C file uses tabs or spaces in Vim.
+- bpo-5611: Auto-detect whether a C file uses tabs or spaces in Vim.
 
 
-What's New in Python 2.6 final
-==============================
+What's New in Python 2.6 final?
+===============================
 
 *Release date: 01-Oct-2008*
 
 Core and Builtins
 -----------------
 
-- Issue #3967: Fixed a crash in the count() and find() methods of string-like
+- bpo-3967: Fixed a crash in the count() and find() methods of string-like
   objects, when the "start" parameter is a huge value.
 
-- Issue #3965: Fixed a crash on Windows when open() is given an invalid
+- bpo-3965: Fixed a crash on Windows when open() is given an invalid
   filename or mode, and the filename is a unicode string.
 
-- Bug #3951: Py_USING_MEMORY_DEBUGGER should not be enabled by default.
+- bpo-3951: Py_USING_MEMORY_DEBUGGER should not be enabled by default.
 
 Library
 -------
 
-- Issue #3965: Allow repeated calls to turtle.Screen, by making it a
-  true singleton object.
+- bpo-3965: Allow repeated calls to turtle.Screen, by making it a true
+  singleton object.
 
-- Issue #3895: It was possible to crash the interpreter when an external timer
+- bpo-3895: It was possible to crash the interpreter when an external timer
   was used with cProfile that returned an object that could not be converted
   into a float.
 
-- Issue #3950: Made turtle respect scale factors.
+- bpo-3950: Made turtle respect scale factors.
 
-- Issue #3547: Fixed ctypes structures bitfields of varying integer
-  sizes.
+- bpo-3547: Fixed ctypes structures bitfields of varying integer sizes.
 
-- Issue #3879: A regression in urllib.getproxies_environment was fixed.
+- bpo-3879: A regression in urllib.getproxies_environment was fixed.
 
-- Issue #3863: Disabled a unit test of fork being called from a thread
-  when running on platforms known to exhibit OS bugs when attempting that.
+- bpo-3863: Disabled a unit test of fork being called from a thread when
+  running on platforms known to exhibit OS bugs when attempting that.
 
 Build
 -----
 
-- Bug #3989: Package the 2to3 script (as 2to3.py) in the Windows
-  installer.
+- bpo-3989: Package the 2to3 script (as 2to3.py) in the Windows installer.
 
-- Bug #3887: Package x64 version of CRT for AMD64 Windows binaries.
+- bpo-3887: Package x64 version of CRT for AMD64 Windows binaries.
 
 
 What's New in Python 2.6 release candidate 2?
@@ -9374,31 +9826,28 @@ What's New in Python 2.6 release candidate 2?
 
 *Release date: 17-Sep-2008*
 
-Core and Builtins
------------------
-
-Extension Modules
------------------
+Library
+-------
 
 - Security Issue #2: imageop did not validate arguments correctly and could
   segfault as a result.
 
-- Issue #3886: Possible integer overflows in the _hashopenssl module were
+- bpo-3886: Possible integer overflows in the _hashopenssl module were
   closed.
 
 Tools/Demos
 -----------
 
-- Issue #3850: recursion tests in Tools/scripts/find_recursion_limit.py can raise
-  AttributeError instead of RuntimeError, depending in which C API call
-  exactly the recursion limit is exceeded. Consequently, both exception types
-  are caught and silenced.
+- bpo-3850: recursion tests in Tools/scripts/find_recursion_limit.py can
+  raise AttributeError instead of RuntimeError, depending in which C API
+  call exactly the recursion limit is exceeded. Consequently, both exception
+  types are caught and silenced.
 
 Build
 -----
 
-- Issue #3617: Include a licensing statement regarding the Microsoft
-  C runtime in the Windows installer.
+- bpo-3617: Include a licensing statement regarding the Microsoft C runtime
+  in the Windows installer.
 
 
 What's New in Python 2.6 release candidate 1?
@@ -9409,35 +9858,35 @@ What's New in Python 2.6 release candidate 1?
 Core and Builtins
 -----------------
 
-- Issue #3642: Suppress warning in obmalloc when size_t is larger than uint.
+- bpo-3642: Suppress warning in obmalloc when size_t is larger than uint.
 
-- Issue #3743: In a few places, PY_FORMAT_SIZE_T was incorrectly used with
+- bpo-3743: In a few places, PY_FORMAT_SIZE_T was incorrectly used with
   PyString_FromFormat or PyErr_Format to display size_t values. The macro
   PY_FORMAT_SIZE_T is designed to select the correct format for the OS
   ``printf`` function, whereas PyString_FromFormat has an independent
-  implementation and uses "%zd" on all platforms for size_t values.
-  This makes a difference on win64, where ``printf`` needs "%Id" to display
-  64bit values.
+  implementation and uses "%zd" on all platforms for size_t values. This
+  makes a difference on win64, where ``printf`` needs "%Id" to display 64bit
+  values.
 
-- Issue #3634: _weakref.ref(Exception).__init__() gave invalid return value on
+- bpo-3634: _weakref.ref(Exception).__init__() gave invalid return value on
   error.
 
-- Issue #3777: long() applied to a float object now always return a long
+- bpo-3777: long() applied to a float object now always return a long
   object; previously an int would be returned for small values. the __long__
   method is allowed to return either an int or a long, but the behaviour of
   float objects should not change to respect backward compatibility.
 
-- Issue #3751: str.rpartition would perform a left-partition when called with
-  unicode argument.
+- bpo-3751: str.rpartition would perform a left-partition when called with a
+  unicode argument.
 
-- Issue #3683: Fix compilation when --without-threads is given.
+- bpo-3683: Fix compilation when --without-threads is given.
 
-- Issue #3668: Fix a memory leak with the "s*" argument parser in
+- bpo-3668: Fix a memory leak with the "s*" argument parser in
   PyArg_ParseTuple and friends, which occurred when the argument for "s*"
   was correctly parsed but parsing of subsequent arguments failed.
 
-- Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
-  match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
+- bpo-2534: speed up isinstance() and issubclass() by 50-70%, so as to match
+  Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
   mechanism. In the process, fix a bug where isinstance() and issubclass(),
   when given a tuple of classes as second argument, were looking up
   __instancecheck__ / __subclasscheck__ on the tuple rather than on each
@@ -9447,24 +9896,25 @@ Core and Builtins
 
 - Fix memory leaks found with valgrind and update suppressions file.
 
-- Fix compiler warnings in opt mode which would lead to invalid memory reads.
+- Fix compiler warnings in opt mode which would lead to invalid memory
+  reads.
 
 - Fix problem using wrong name in decimal module reported by pychecker.
 
-- Silenced another compiler warning about a used but not defined
-  function 'stringlib_contains_obj'.
+- Silenced another compiler warning about a used but not defined function
+  'stringlib_contains_obj'.
 
 - Added warnings on the use of ``__getslice__``, ``__setslice__``, or
   ``__delslice__``.
 
-- Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
+- bpo-3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
   library targets in the Makefile.
 
-- Issue #1204: The configure script now tests for additional libraries
-  that may be required when linking against readline.  This fixes issues
-  with x86_64 builds on some platforms (a few Linux flavors and OpenBSD).
+- bpo-1204: The configure script now tests for additional libraries that may
+  be required when linking against readline.  This fixes issues with x86_64
+  builds on some platforms (a few Linux flavors and OpenBSD).
 
-C-API
+C API
 -----
 
 - Aliased PyObject_Bytes to PyObject_Str.
@@ -9472,46 +9922,46 @@ C-API
 Library
 -------
 
-- Issue #3640: Pickling a list or a dict uses less local variables, to reduce
+- bpo-3640: Pickling a list or a dict uses less local variables, to reduce
   stack usage in the case of deeply nested objects.
 
-- Issue #3629: Fix sre "bytecode" validator for an end case.
+- bpo-3629: Fix sre "bytecode" validator for an end case.
 
-- Issue #3811: The Unicode database was updated to 5.1.
+- bpo-3811: The Unicode database was updated to 5.1.
 
-- Issue #3781: Further warnings.catch_warnings() cleanup to prevent
-  silent misbehaviour when a single instance is nested in multiple
-  with statements, or when the methods are invoked in the wrong order.
+- bpo-3781: Further warnings.catch_warnings() cleanup to prevent silent
+  misbehaviour when a single instance is nested in multiple with statements,
+  or when the methods are invoked in the wrong order.
 
-- Issue #3809: Fixed spurious 'test.blah' file left behind by test_logging.
+- bpo-3809: Fixed spurious 'test.blah' file left behind by test_logging.
 
-- Issue #3781: Clean up the API for warnings.catch_warnings() by having it
+- bpo-3781: Clean up the API for warnings.catch_warnings() by having it
   return a list or None rather than a custom object.
 
-- Issue #1638033: Cookie.Morsel gained the httponly attribute.
+- bpo-1638033: Cookie.Morsel gained the httponly attribute.
 
-- Issue #3535: zipfile couldn't read some zip files larger than 2GB.
+- bpo-3535: zipfile couldn't read some zip files larger than 2GB.
 
-- Issue #3776: Deprecate the bsddb package for removal in 3.0.
+- bpo-3776: Deprecate the bsddb package for removal in 3.0.
 
-- Issue #3762: platform.architecture() fails if python is lanched via
-  its symbolic link.
+- bpo-3762: platform.architecture() fails if python is lanched via its
+  symbolic link.
 
-- Issue #3772: Fixed regression problem in StreamHandler.emit().
+- bpo-3772: Fixed regression problem in StreamHandler.emit().
 
-- Issue #600362: Relocated parse_qs() and parse_qsl(), from the cgi module
-  to the urlparse one.  Added a PendingDeprecationWarning in the old
-  module, it will be deprecated in the future.
+- bpo-600362: Relocated parse_qs() and parse_qsl(), from the cgi module to
+  the urlparse one.  Added a PendingDeprecationWarning in the old module, it
+  will be deprecated in the future.
 
-- Issue #2562: Fix distutils PKG-INFO writing logic to allow having
-  non-ascii characters and Unicode in setup.py meta-data.
+- bpo-2562: Fix distutils PKG-INFO writing logic to allow having non-ascii
+  characters and Unicode in setup.py meta-data.
 
-- Issue #3726: Allow spaces in separators in logging configuration files.
+- bpo-3726: Allow spaces in separators in logging configuration files.
 
-- Issue #3719: platform.architecture() fails if there are spaces in the
-  path to the Python binary.
+- bpo-3719: platform.architecture() fails if there are spaces in the path to
+  the Python binary.
 
-- Issue #3602: Moved test.test_support.catch_warning() to
+- bpo-3602: Moved test.test_support.catch_warning() to
   warnings.catch_warnings() along with some API cleanup. Expanding the tests
   for catch_warnings() also led to an improvement in the raising of a
   DeprecationWarning related to warnings.warn_explicit().
@@ -9524,59 +9974,56 @@ Library
 
 - Fixed two format strings in the _collections module.
 
-- Issue #3703: _fileio.FileIO gave unhelpful error message when trying to open a
-  directory.
+- bpo-3703: _fileio.FileIO gave unhelpful error message when trying to open
+  directory.
 
-- Issue #3708: os.urandom no longer goes into an infinite loop when passed a
+- bpo-3708: os.urandom no longer goes into an infinite loop when passed a
   non-integer floating point number.
 
-- Issue #3110: multiprocessing fails to compiel on solaris 10 due to missing
+- bpo-3110: multiprocessing fails to compiel on solaris 10 due to missing
   SEM_VALUE_MAX.
 
-Extension Modules
------------------
-
-- Issue #4301: Patch the logging module to add processName support, remove
+- bpo-4301: Patch the logging module to add processName support, remove
   _check_logger_class from multiprocessing.
 
-- Issue #2975: When compiling several extension modules with Visual Studio 2008
+- bpo-2975: When compiling several extension modules with Visual Studio 2008
   from the same python interpreter, some environment variables would grow
   without limit.
 
-- Issue #3643: Added a few more checks to _testcapi to prevent segfaults by
+- bpo-3643: Added a few more checks to _testcapi to prevent segfaults by
   exploitation of poor argument checking.
 
 - sqlite3: Changed docstring of iterdump() to mark method as "Non-standard".
 
-- Issue #3103: Reduced globals symbols used by sqlite3 module and made sure all
+- bpo-3103: Reduced globals symbols used by sqlite3 module and made sure all
   remaining ones have "pysqlite_" prefix.
 
-- Issue #3846: Release the GIL during sqlite3_prepare calls. This improves
+- bpo-3846: Release the GIL during sqlite3_prepare calls. This improves
   concurrent access to the same SQLite database from multiple
   threads/processes.
 
 Tests
 -----
 
-- Issue #3781: Add test.test_support.check_warnings() as a convenience
-  wrapper for warnings.catch_warnings() that makes it easier to check
-  that expected warning messages are being reported.
+- bpo-3781: Add test.test_support.check_warnings() as a convenience wrapper
+  for warnings.catch_warnings() that makes it easier to check that expected
+  warning messages are being reported.
 
-- Issue #3796: Some tests functions were not enabled in test_float.
+- bpo-3796: Some tests functions were not enabled in test_float.
 
-- Issue #3768: Move test_py3kwarn over to the new API for catch_warnings().
+- bpo-3768: Move test_py3kwarn over to the new API for catch_warnings().
 
 Build
 -----
 
-- Issue #3833: Use a different upgrade code for Win64 installers.
+- bpo-3833: Use a different upgrade code for Win64 installers.
 
-- Issue #2271: Set SecureCustomProperties so that installation will properly
+- bpo-2271: Set SecureCustomProperties so that installation will properly
   use the TARGETDIR even for unprivileged users.
 
 - Allow passing the MSI file name to merge.py.
 
-- Issue #3758: Rename the 'check' target to 'patchcheck' so as to not clash
+- bpo-3758: Rename the 'check' target to 'patchcheck' so as to not clash
   with GNU build target guidelines.
 
 
@@ -9588,127 +10035,129 @@ What's New in Python 2.6 beta 3?
 Core and Builtins
 -----------------
 
-- Issue #1878: Remove Py_TPFLAGS_HAVE_VERSION_TAG from
-  Py_TPFLAGS_DEFAULT when not building the core.  This means 3rd party
-  extensions do not automatically benefit from the class attribute
-  cache; they will have to explicitly add Py_TPFLAGS_HAVE_VERSION_TAG
-  to their tp_flags field if they care.  This is a backwards
-  compatibility feature; in 3.0, all types will use the cache by
-  default.
+- bpo-1878: Remove Py_TPFLAGS_HAVE_VERSION_TAG from Py_TPFLAGS_DEFAULT when
+  not building the core.  This means 3rd party extensions do not
+  automatically benefit from the class attribute cache; they will have to
+  explicitly add Py_TPFLAGS_HAVE_VERSION_TAG to their tp_flags field if they
+  care.  This is a backwards compatibility feature; in 3.0, all types will
+  use the cache by default.
 
 - Keyword arguments can now follow starred arguments. (``f(a, *args,
   keyword=23)`` is now valid syntax.)
 
-- ctypes function pointers that are COM methods have a boolean True
-  value again.
+- ctypes function pointers that are COM methods have a boolean True value
+  again.
 
-- Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
-  by denying s# to parse objects that have a releasebuffer procedure,
-  and introducing s*.
+- bpo-3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple, by
+  denying s# to parse objects that have a releasebuffer procedure, and
+  introducing s*.
 
-- Issue #3537: Fix an assertion failure when an empty but presized dict
-  object was stored in the freelist.
+- bpo-3537: Fix an assertion failure when an empty but presized dict object
+  was stored in the freelist.
 
-- Issue #1481296: Make long(float('nan')) and int(float('nan')) raise
+- bpo-1481296: Make long(float('nan')) and int(float('nan')) raise
   ValueError consistently across platforms.
 
-- Issue #3479: On platforms where sizeof(int) is smaller than sizeof(long)
+- bpo-3479: On platforms where sizeof(int) is smaller than sizeof(long)
   (64bit Unix, for example), unichr() would truncate its argument and return
   u'\x00' for unichr(2**32). Now it properly raises an OverflowError.
 
 - Apply security patches from Apple.
 
-- Issue #2542: Now that issubclass() may call arbitrary code, ensure that
+- bpo-2542: Now that issubclass() may call arbitrary code, ensure that
   PyErr_ExceptionMatches returns 0 when an exception occurs there.
 
-- Issue #1819: function calls with several named parameters are now on
-  average 35% faster (as measured by pybench).
+- bpo-1819: function calls with several named parameters are now on average
+  35% faster (as measured by pybench).
 
-- Issue #2378: An unexpected UnboundLocalError or NameError could appear when
-  the python debugger steps into a class statement: the free variables (local
-  variables defined in an outer scope) would be deleted from the outer scope.
+- bpo-2378: An unexpected UnboundLocalError or NameError could appear when
+  the python debugger steps into a class statement: the free variables
+  (local variables defined in an outer scope) would be deleted from the
+  outer scope.
 
-- Issue #2620: Overflow checking when allocating or reallocating memory
-  was not always being done properly in some python types and extension
-  modules.  PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have
-  all been updated to perform better checks and places in the code that
-  would previously leak memory on the error path when such an allocation
-  failed have been fixed.
+- bpo-2620: Overflow checking when allocating or reallocating memory was not
+  always being done properly in some python types and extension modules.
+  PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have all been
+  updated to perform better checks and places in the code that would
+  previously leak memory on the error path when such an allocation failed
+  have been fixed.
 
 Library
 -------
 
-- Issue #3612: Added some missing basic types in ctypes.wintypes.
+- bpo-3612: Added some missing basic types in ctypes.wintypes.
 
 - The methods ``is_in_tuple()``, ``is_vararg()``, and ``is_keywordarg()`` of
-  symtable.Symbol have been deprecated for removal in 3.0 and the next release.
+  symtable.Symbol have been deprecated for removal in 3.0 and the next
+  release.
 
-- Issue #2234: distutils failed for some versions of the cygwin compiler. The
+- bpo-2234: distutils failed for some versions of the cygwin compiler. The
   version reported by these tools does not necessarily follow the python
   version numbering scheme, so the module is less strict when parsing it.
 
-- Issue #2235: Added Py3k warnings for types which will become unhashable
-  under the stricter __hash__ inheritance rules in 3.0. Several types
-  which did not meet the rules for hash invariants and were already
-  unhashable in 3.0 have now been explicitly flagged as unhashable in
-  2.6 as well (collections.Mapping, collections.Set, unittest.TestSuite,
+- bpo-2235: Added Py3k warnings for types which will become unhashable under
+  the stricter __hash__ inheritance rules in 3.0. Several types which did
+  not meet the rules for hash invariants and were already unhashable in 3.0
+  have now been explicitly flagged as unhashable in 2.6 as well
+  (collections.Mapping, collections.Set, unittest.TestSuite,
   xml.dom.minidom.NamedNodeMap, numbers.Number, UserList.UserList)
 
-- Update __all__ for cookielib, csv, os, urllib2, and weakref to include things
-  imported into the module but exposed as part of the module's API.
+- Update __all__ for cookielib, csv, os, urllib2, and weakref to include
+  things imported into the module but exposed as part of the module's API.
 
 - Remove an unneeded import of abc.ABCMeta from 'inspect'.
 
 - Remove unneeded imports of 'sys' and 'warnings' from 'io'.
 
-- Remove unneeded imports of 'warnings' from shelve, filecmp, and dummy_thread.
+- Remove unneeded imports of 'warnings' from shelve, filecmp, and
+  dummy_thread.
 
-- Issue #3575: Incremental decoder's decode function now takes bytearray
-  by using 's*' instead of 't#'.
+- bpo-3575: Incremental decoder's decode function now takes bytearray by
+  using 's*' instead of 't#'.
 
-- Issue #2222: Fixed reference leak when occurred os.rename()
-  fails unicode conversion on 2nd parameter. (windows only)
+- bpo-2222: Fixed reference leak when occurred os.rename() fails unicode
+  conversion on 2nd parameter. (windows only)
 
-- Issue #2464: urllib2 now supports a malformation in the URL received
-  in a redirect.
+- bpo-2464: urllib2 now supports a malformation in the URL received in a
+  redirect.
 
 - Silence the DeprecationWarning raised when importing mimetools in
   BaseHTTPServer, cgi (and rfc822), httplib.
 
-- Issue #2776: fixed small issue when handling a URL with double slash
-  after a 302 response in the case of not going through a proxy.
+- bpo-2776: fixed small issue when handling a URL with double slash after a
+  302 response in the case of not going through a proxy.
 
-- Issue #2676: in the email package, content-type parsing was hanging on
+- bpo-2676: in the email package, content-type parsing was hanging on
   pathological input because of quadratic or exponential behaviour of a
   regular expression.
 
-- Issue #3476: binary buffered reading through the new "io" library is now
+- bpo-3476: binary buffered reading through the new "io" library is now
   thread-safe.
 
 - Silence the DeprecationWarning of rfc822 when it is imported by mimetools
   since mimetools itself is deprecated. Because modules are cached, all
   subsequent imports of rfc822 will not raise a visible DeprecationWarning.
 
-- Issue #3134: shutil referenced undefined WindowsError symbol.
+- bpo-3134: shutil referenced undefined WindowsError symbol.
 
-- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
-  menu entries were not deleted.
+- bpo-1342811: Fix leak in Tkinter.Menu.delete. Commands associated to menu
+  entries were not deleted.
 
 - Copied the implementation of reduce() to _functools.reduce() to have a
   version that did not raise a DeprecationWarning under -3.
 
-- Issue #3205: When iterating over a BZ2File fails allocating memory, raise
-  MemoryError rather than silently stop the iteration.
+- bpo-3205: When iterating over a BZ2File fails allocating memory, raise a
+  MemoryError rather than silently stop the iteration.
 
-- Issue #3487: sre "bytecode" validator.  Passing invalid "re-bytecode"
-  to _sre.compile() will now be rejected.  This should not affect anybody
-  since the re.compile() function never generates invalid re-bytecode.
+- bpo-3487: sre "bytecode" validator.  Passing invalid "re-bytecode" to
+  _sre.compile() will now be rejected.  This should not affect anybody since
+  the re.compile() function never generates invalid re-bytecode.
 
-- Issue #3436: Make csv.DictReader's fieldnames attribute a property so that
+- bpo-3436: Make csv.DictReader's fieldnames attribute a property so that
   upon first access it can be automatically initialized from the csv file if
   it wasn't initialized during instantiation.
 
-- Issue #2338: Create imp.reload() to help with transitioning to Python 3.0 as
+- bpo-2338: Create imp.reload() to help with transitioning to Python 3.0 as
   the reload() built-in has been removed.
 
 - Changed code in the following modules/packages to remove warnings raised
@@ -9719,43 +10168,44 @@ Library
   subprocess, sqlite3, tarfile, Tkinter, test.test_support, textwrap,
   threading, tokenize, traceback, urlparse, wsgiref, xml, xmlrpclib.
 
-- Issue #3039: Fix tarfile.TarFileCompat.writestr() which always
-  raised an AttributeError.
+- bpo-3039: Fix tarfile.TarFileCompat.writestr() which always raised an
+  AttributeError.
 
-- Issue #2523: Fix quadratic behaviour when read()ing a binary file without
+- bpo-2523: Fix quadratic behaviour when read()ing a binary file without
   asking for a specific length. This problem only affected files opened
   using the new "io" module, not the built-in open() function.
 
-- Issue #3449: Update decimal module to use most recent specification
-  (v. 1.68) and tests (v. 2.58) from IBM.
+- bpo-3449: Update decimal module to use most recent specification (v. 1.68)
+  and tests (v. 2.58) from IBM.
 
-- Issue #3437: Bug fix in robotparser parsing of Allow: lines.
+- bpo-3437: Bug fix in robotparser parsing of Allow: lines.
 
-- Issue #1592: Improve error reporting when operations are attempted
-  on a closed shelf.
+- bpo-1592: Improve error reporting when operations are attempted on a
+  closed shelf.
 
 - Deprecate the "ast" parser function aliases.
 
-- Issue #3120: On 64-bit Windows the subprocess module was truncating handles.
+- bpo-3120: On 64-bit Windows the subprocess module was truncating handles.
 
-- Issue #3303: Fix a crash in locale.strcoll() when calling it with
-  invalid arguments.
+- bpo-3303: Fix a crash in locale.strcoll() when calling it with invalid
+  arguments.
 
-- Issue #3302: Fix several crashes when calling locale's gettext functions
-  with None arguments.
+- bpo-3302: Fix several crashes when calling locale's gettext functions with
+  None arguments.
 
-- Issue #3389: Allow resolving dotted names for handlers in logging
+- bpo-3389: Allow resolving dotted names for handlers in logging
   configuration files.
 
 - Deprecate the sunaudio module for removal in Python 3.0.
 
-- Issue #3394: zipfile.writestr sets external attributes when passed a
-  file name rather than a ZipInfo instance, so files are extracted with
-  mode 0600 rather than 000 under Unix.
+- bpo-3394: zipfile.writestr sets external attributes when passed a file
+  name rather than a ZipInfo instance, so files are extracted with mode 0600
+  rather than 000 under Unix.
 
-- Issue #1857: subprocess.Popen.poll gained an additional _deadstate keyword
-  argument in python 2.5, this broke code that subclassed Popen to include its
-  own poll method.  Fixed my moving _deadstate to an _internal_poll method.
+- bpo-1857: subprocess.Popen.poll gained an additional _deadstate keyword
+  argument in python 2.5, this broke code that subclassed Popen to include
+  its own poll method.  Fixed my moving _deadstate to an _internal_poll
+  method.
 
 Build
 -----
@@ -9765,13 +10215,13 @@ Build
 Documentation
 -------------
 
-- Issue #2235: the C API function PyObject_HashNotImplemented and its
+- bpo-2235: the C API function PyObject_HashNotImplemented and its
   interaction with the tp_hash slot (added in 2.6b2) are now documented
 
-- Issue #643841: The language reference now provides more detailed
-  coverage of the lookup process for special methods. The disclaimers
-  regarding lack of coverage of new-style classes have also been
-  removed, since the coverage is now fairly reasonable.
+- bpo-643841: The language reference now provides more detailed coverage of
+  the lookup process for special methods. The disclaimers regarding lack of
+  coverage of new-style classes have also been removed, since the coverage
+  is now fairly reasonable.
 
 
 What's New in Python 2.6 beta 2?
@@ -9782,131 +10232,131 @@ What's New in Python 2.6 beta 2?
 Core and Builtins
 -----------------
 
-- Issue #3156: Fix inconsistent behavior of the bytearray type: all
-  its methods now allow for items objects that can be converted to
-  an integer using operator.index().
+- bpo-3156: Fix inconsistent behavior of the bytearray type: all its methods
+  now allow for items objects that can be converted to an integer using
+  operator.index().
 
-- Issue #3360: Fix incorrect parsing of '020000000000.0', which
-  produced a ValueError instead of giving the correct float.
+- bpo-3360: Fix incorrect parsing of '020000000000.0', which produced a
+  ValueError instead of giving the correct float.
 
-- Issue #3083: Add alternate (#) formatting for bin, oct, hex output
-  for str.format().  This adds the prefix 0b, 0o, or 0x, respectively.
+- bpo-3083: Add alternate (#) formatting for bin, oct, hex output for
+  str.format(). This adds the prefix 0b, 0o, or 0x, respectively.
 
-- Issue #3008: the float type has a new instance method 'float.hex'
-  and a new class method 'float.fromhex' to convert floating-point
-  numbers to and from hexadecimal strings, respectively.
+- bpo-3008: the float type has a new instance method 'float.hex' and a new
+  class method 'float.fromhex' to convert floating-point numbers to and from
+  hexadecimal strings, respectively.
 
-- Issue #2235: __hash__ is once again inherited by default. To allow
-  collections.Hashable to remain meaningful in the presence of the
-  default hash implementation (object.__hash__), it is now possible
-  to explicit block inheritance of hash by setting __hash__=None at
-  the Python level, or tp_hash=PyObject_HashNotImplemented at the C
-  level.
+- bpo-2235: __hash__ is once again inherited by default. To allow
+  collections.Hashable to remain meaningful in the presence of the default
+  hash implementation (object.__hash__), it is now possible to explicit
+  block inheritance of hash by setting __hash__=None at the Python level, or
+  tp_hash=PyObject_HashNotImplemented at the C level.
 
-- Issue #3221: Issue a RuntimeWarning instead of raising SystemError if
-  the parent module cannot be found while performing an absolute import.
-  This means that an incorrectly defined __package__ attribute will
-  now only prevent relative imports in that module rather than causing
-  all imports from that module to fail.
+- bpo-3221: Issue a RuntimeWarning instead of raising SystemError if the
+  parent module cannot be found while performing an absolute import. This
+  means that an incorrectly defined __package__ attribute will now only
+  prevent relative imports in that module rather than causing all imports
+  from that module to fail.
 
-- Issue #2517: Allow unicode messages in Exceptions again by correctly
-  bypassing the instance dictionary when looking up __unicode__ on
-  new-style classes.
+- bpo-2517: Allow unicode messages in Exceptions again by correctly
+  bypassing the instance dictionary when looking up __unicode__ on new-style
+  classes.
 
-- Issue #3242: Fix a crash inside the print statement, if sys.stdout is
-  set to a custom object whose write() method happens to install
-  another file in sys.stdout.
+- bpo-3242: Fix a crash inside the print statement, if sys.stdout is set to
+  a custom object whose write() method happens to install another file in
+  sys.stdout.
 
-- Issue #3088: Corrected a race condition in classes derived from
+- bpo-3088: Corrected a race condition in classes derived from
   threading.local: the first member set by a thread could be saved in
   another thread's dictionary.
 
-- Issue #3004: Minor change to slice.indices(): the start and stop
-  arguments are now treated identically, making the behaviour easier
-  to describe and understand.  For example, slice(None, -10,
-  1).indices(9) now returns (0, 0, 1) instead of (0, -1, 1), and
-  slice(None, 10, -1).indices(10) returns (9, 9, -1) instead of (9,
-  10, -1).
+- bpo-3004: Minor change to slice.indices(): the start and stop arguments
+  are now treated identically, making the behaviour easier to describe and
+  understand. For example, slice(None, -10, 1).indices(9) now returns (0, 0,
+  1) instead of (0, -1, 1), and slice(None, 10, -1).indices(10) returns (9,
+  9, -1) instead of (9, 10, -1).
 
-- Issue #3219: Calling a function with repeated keyword arguments,
-  f(a=2, a=23), would not cause a syntax error.  This was a regression
-  from 2.4 caused by the switch to the new compiler.
+- bpo-3219: Calling a function with repeated keyword arguments, f(a=2,
+  a=23), would not cause a syntax error.  This was a regression from 2.4
+  caused by the switch to the new compiler.
 
-- Issue #2862: Make int and float freelist management consistent with
-  other freelists.  Changes their CompactFreeList apis into
-  ClearFreeList apis and calls them via gc.collect().
+- bpo-2862: Make int and float freelist management consistent with other
+  freelists. Changes their CompactFreeList apis into ClearFreeList apis and
+  calls them via gc.collect().
 
 Library
 -------
 
-- Issue #3554: ctypes.string_at and ctypes.wstring_at did call Python
-  api functions without holding the GIL, which could lead to a fatal
-  error when they failed.
+- bpo-3554: ctypes.string_at and ctypes.wstring_at did call Python api
+  functions without holding the GIL, which could lead to a fatal error when
+  they failed.
 
-- Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects.
+- bpo-799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects.
 
-- Issue #3395: fix reference in test_multiprocessing to old debugInfo method
+- bpo-3395: fix reference in test_multiprocessing to old debugInfo method
 
-- Issue #3312: Fix two crashes in sqlite3.
+- bpo-3312: Fix two crashes in sqlite3.
 
-- Issue #1608818: Fix misbehavior in os.listdir() if readdir() fails.
+- bpo-1608818: Fix misbehavior in os.listdir() if readdir() fails.
 
-- Issue #3125: Remove copy_reg in multiprocessing and replace it with
+- bpo-3125: Remove copy_reg in multiprocessing and replace it with
   ForkingPickler.register() to resolve conflict with ctypes.
 
-- Issue #3090: Fixed ARCHFLAGS parsing on OS/X
+- bpo-3090: Fixed ARCHFLAGS parsing on OS/X
 
-- Issue #3313: Fixed a crash when a failed dlopen() call does not set
-  a valid dlerror() message.
+- bpo-3313: Fixed a crash when a failed dlopen() call does not set a valid
+  dlerror() message.
 
-- Issue #3258: Fixed a crash when a ctypes POINTER type to an
-  incomplete structure was created.
+- bpo-3258: Fixed a crash when a ctypes POINTER type to an incomplete
+  structure was created.
 
-- Issue #3339: dummy_thread.acquire() should not return None.
+- bpo-3339: dummy_thread.acquire() should not return None.
 
-- Issue #3285: Fractions from_float() and from_decimal() accept Integral arguments.
+- bpo-3285: Fractions from_float() and from_decimal() accept Integral
+  arguments.
 
-- Issue #3301: Bisect module behaved badly when lo was negative.
+- bpo-3301: Bisect module behaved badly when lo was negative.
 
-- Issue #839496: SimpleHTTPServer used to open text files in text mode. This is
-  both unnecessary (HTTP allows text content to be sent in several forms) and
-  wrong because the actual transmitted size could differ from the
-  content-length.  The problem had been corrected in the 2.4 branch, but never
-  merged into trunk.
+- bpo-839496: SimpleHTTPServer used to open text files in text mode. This is
+  both unnecessary (HTTP allows text content to be sent in several forms)
+  and wrong because the actual transmitted size could differ from the
+  content-length. The problem had been corrected in the 2.4 branch, but
+  never merged into trunk.
 
-- Issue #2663: add filtering capability to shutil.copytree().
+- bpo-2663: add filtering capability to shutil.copytree().
 
-- Issue #1622: Correct interpretation of various ZIP header fields.
+- bpo-1622: Correct interpretation of various ZIP header fields.
 
-- Issue #1526: Allow more than 64k files to be added to Zip64 file.
+- bpo-1526: Allow more than 64k files to be added to Zip64 file.
 
-- Issue #1746: Correct handling of zipfile archive comments (previously
-  archives with comments over 4k were flagged as invalid). Allow writing
-  Zip files with archives by setting the 'comment' attribute of a ZipFile.
+- bpo-1746: Correct handling of zipfile archive comments (previously
+  archives with comments over 4k were flagged as invalid). Allow writing Zip
+  files with archives by setting the 'comment' attribute of a ZipFile.
 
-- Issue #449227: The rlcompleter module now adds "(" to callable objects
-  when completed.
+- bpo-449227: The rlcompleter module now adds "(" to callable objects when
+  completed.
 
-- Issue #3190: Pydoc now hides the automatic module attribute __package__ (the
-  handling is now the same as that of other special attributes like __name__).
+- bpo-3190: Pydoc now hides the automatic module attribute __package__ (the
+  handling is now the same as that of other special attributes like
+  __name__).
 
-- Issue #2885 (partial): The urllib.urlopen() function has been deprecated for
-  removal in Python 3.0 in favor of urllib2.urlopen().
+- bpo-2885: The urllib.urlopen() function has been deprecated for removal in
+  Python 3.0 in favor of urllib2.urlopen().
 
-- Issue #2113: Fix error in subprocess.Popen if the select system call is
+- bpo-2113: Fix error in subprocess.Popen if the select system call is
   interrupted by a signal.
 
-- Issue #3309: Fix bz2.BZFile iterator to release its internal lock
-  properly when raising an exception due to the bz2file being closed.
-  Prevents a deadlock.
+- bpo-3309: Fix bz2.BZFile iterator to release its internal lock properly
+  when raising an exception due to the bz2file being closed. Prevents a
+  deadlock.
 
-- Issue #3094: httplib.HTTPSConnection Host: headers no longer include the
+- bpo-3094: httplib.HTTPSConnection Host: headers no longer include the
   redundant ":443" port number designation when the connection is using the
   default https port (443).
 
-- Issue #874900: after an os.fork() call the threading module state is cleaned
-  up in the child process to prevent deadlock and report proper thread counts
-  if the new process uses the threading module.
+- bpo-874900: after an os.fork() call the threading module state is cleaned
+  up in the child process to prevent deadlock and report proper thread
+  counts if the new process uses the threading module.
 
 Tests
 -----
@@ -9918,13 +10368,13 @@ Tests
 Build
 -----
 
-- Issue #3215: Build sqlite3 as sqlite3.dll, not sqlite3.pyd.
+- bpo-3215: Build sqlite3 as sqlite3.dll, not sqlite3.pyd.
 
 Documentation
 -------------
 
-- Document that robotparser has been renamed to urllib.robotparser in
-  Python 3.0.
+- Document that robotparser has been renamed to urllib.robotparser in Python
+  3.0.
 
 - Document that urlparse has been renamed to urllib.parse in Python 3.0.
 
@@ -9943,64 +10393,63 @@ What's New in Python 2.6 beta 1?
 Core and Builtins
 -----------------
 
-- Issue #3211: warnings.warn_explicit() did not guard against its 'registry'
-  argument being anything other than a dict or None. Also fixed a bug in error
-  handling when 'message' and 'category' were both set to None, triggering a
-  bus error.
+- bpo-3211: warnings.warn_explicit() did not guard against its 'registry'
+  argument being anything other than a dict or None. Also fixed a bug in
+  error handling when 'message' and 'category' were both set to None,
+  triggering a bus error.
 
-- Issue #3100: Corrected a crash on deallocation of a subclassed weakref which
+- bpo-3100: Corrected a crash on deallocation of a subclassed weakref which
   holds the last (strong) reference to its referent.
 
 - Add future_builtins.ascii().
 
 - Several set methods now accept multiple arguments: update(), union(),
-  intersection(), intersection_update(), difference(), and difference_update().
+  intersection(), intersection_update(), difference(), and
+  difference_update().
 
-- Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
+- bpo-2898: Added sys.getsizeof() to retrieve size of objects in bytes.
 
 - New environment variable PYTHONIOENCODING.
 
-- Patch #2488: Add sys.maxsize.
+- bpo-2488: Add sys.maxsize.
 
-- Issue #2353: file.xreadlines() now emits a Py3k warning.
+- bpo-2353: file.xreadlines() now emits a Py3k warning.
 
-- Issue #2863: generators now have a ``gen.__name__`` attribute that
-  equals ``gen.gi_code.co_name``, like ``func.__name___`` that equals
-  ``func.func_code.co_name``.  The repr() of a generator now also
-  contains this name.
+- bpo-2863: generators now have a ``gen.__name__`` attribute that equals
+  ``gen.gi_code.co_name``, like ``func.__name___`` that equals
+  ``func.func_code.co_name``.  The repr() of a generator now also contains
+  this name.
 
-- Issue #2831: enumerate() now has a ``start`` argument.
+- bpo-2831: enumerate() now has a ``start`` argument.
 
-- Issue #2801: fix bug in the float.is_integer method where a
-  ValueError was sometimes incorrectly raised.
+- bpo-2801: fix bug in the float.is_integer method where a ValueError was
+  sometimes incorrectly raised.
 
-- Issue #2790: sys.flags was not properly exposing its bytes_warning
-  attribute.
+- bpo-2790: sys.flags was not properly exposing its bytes_warning attribute.
 
-- Issue #2196: hasattr() now lets exceptions which do not inherit
-  Exception (KeyboardInterrupt, and SystemExit) propagate instead of
-  ignoring them.
+- bpo-2196: hasattr() now lets exceptions which do not inherit Exception
+  (KeyboardInterrupt, and SystemExit) propagate instead of ignoring them.
 
-- Added checks for integer overflows, contributed by Google. Some are
-  only available if asserts are left in the code, in cases where they
-  can't be triggered from Python code.
+- Added checks for integer overflows, contributed by Google. Some are only
+  available if asserts are left in the code, in cases where they can't be
+  triggered from Python code.
 
-Extension Modules
------------------
-- Issue #1179: [CVE-2007-4965] Integer overflow in imageop module.
+Library
+-------
 
-- Issue #3116: marshal.dumps() had quadratic behavior for strings > 32Mb.
+- bpo-1179: [CVE-2007-4965] Integer overflow in imageop module.
 
-- Issue #2138: Add factorial() to the math module.
+- bpo-3116: marshal.dumps() had quadratic behavior for strings > 32Mb.
 
-- The heapq module does comparisons using LT instead of LE.  This
-  makes its implementation match that used by list.sort().
+- bpo-2138: Add factorial() to the math module.
 
-- Issue #2819: add full-precision summation function to math module,
-  based on Hettinger's ASPN Python Cookbook recipe.
+- The heapq module does comparisons using LT instead of LE.  This makes its
+  implementation match that used by list.sort().
 
-- Issue #2592: delegate nb_index and the floor/truediv slots in
-  weakref.proxy.
+- bpo-2819: add full-precision summation function to math module, based on
+  Hettinger's ASPN Python Cookbook recipe.
+
+- bpo-2592: delegate nb_index and the floor/truediv slots in weakref.proxy.
 
 - Support os.O_ASYNC and fcntl.FASYNC if the constants exist on the
   platform.
@@ -10008,53 +10457,49 @@ Extension Modules
 - Support for Windows 9x has been removed from the winsound module.
 
 - bsddb module updated to version 4.7.3.
-  http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.7.3. This
-  code should be compatible with Python 3.0.
+  http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.7.3. This code should
+  be compatible with Python 3.0.
 
-- Issue #2858: Fix potential memory corruption when
-  bsddb.db.DBEnv.lock_get and other bsddb.db object constructors
-  raised an exception.
+- bpo-2858: Fix potential memory corruption when bsddb.db.DBEnv.lock_get and
+  other bsddb.db object constructors raised an exception.
 
-- Issue #2669: bsddb/__init__.py iteration no longer silently fails when
-  the database has changed size during iteration.  It now raises a
-  RuntimeError in the same manner as a dictionary.
+- bpo-2669: bsddb/__init__.py iteration no longer silently fails when the
+  database has changed size during iteration.  It now raises a RuntimeError
+  in the same manner as a dictionary.
 
-- Issue #2870: cmathmodule.c compile error.
+- bpo-2870: cmathmodule.c compile error.
 
 - Added a threading.Thread.ident property.
 
-Library
--------
+- logging.config: Removed out-of-date comment in _install_handlers and used
+  issubclass in place of equality comparison of classes.
 
-- logging.config: Removed out-of-date comment in _install_handlers and
-  used issubclass in place of equality comparison of classes.
+- bpo-2722: Now the os.getcwd() supports very long path names.
 
-- Issue #2722: Now the os.getcwd() supports very long path names.
-
-- Issue #2888: Fixed the behaviour of pprint when working with nested
+- bpo-2888: Fixed the behaviour of pprint when working with nested
   structures, to match the behaviour of 2.5 and 3.0 (now follows the common
   sense).
 
-- Issue #1817: cgi now correctly handles the querystring on POST requests
+- bpo-1817: cgi now correctly handles the querystring on POST requests
 
-- Issue #3136: fileConfig()'s disabling of old loggers is now conditional via
+- bpo-3136: fileConfig()'s disabling of old loggers is now conditional via
   an optional disable_existing_loggers parameter, but the default value is
   such that the old behaviour is preserved. Thanks to Leandro Lucarella for
   the patch.
 
-- Issue #3126: StreamHandler and FileHandler check before calling "flush" and
-  "close" that the stream object has these, using hasattr (thanks to bobf for
-  the patch).
+- bpo-3126: StreamHandler and FileHandler check before calling "flush" and
+  "close" that the stream object has these, using hasattr (thanks to bobf
+  for the patch).
 
-- Issue #2912: platform.uname now tries to determine unknown information even if
-  os.uname exists.
+- bpo-2912: platform.uname now tries to determine unknown information even
+  if os.uname exists.
 
 - The rfc822 module has been deprecated for removal in 3.0.
 
 - The mimetools module has been deprecated for removal in 3.0.
 
-- The ctypes.byref function now takes an optional second parameter
-  which specifies an offset in bytes for the constructed pointer-like object.
+- The ctypes.byref function now takes an optional second parameter which
+  specifies an offset in bytes for the constructed pointer-like object.
 
 - Added the ast module.
 
@@ -10063,131 +10508,112 @@ Library
 - Factored out the indentation cleaning from inspect.getdoc() into
   inspect.cleandoc() to ease standalone use.
 
-- Issue #1798: Add ctypes calling convention that allows safe access
-  to errno.
+- bpo-1798: Add ctypes calling convention that allows safe access to errno.
 
-- Issue #2404: ctypes objects support the new pep3118 buffer interface.
+- bpo-2404: ctypes objects support the new pep3118 buffer interface.
 
-- Patch #2125: Add GetInteger and GetString methods for
-  msilib.Record objects.
+- bpo-2125: Add GetInteger and GetString methods for msilib.Record objects.
 
-- Issue #2782: The datetime module's strftime methods now accept
-  unicode format strings just as time.strftime always has.
+- bpo-2782: The datetime module's strftime methods now accept unicode format
+  strings just as time.strftime always has.
 
-- The sgmllib and htmllib modules have been deprecated for removal
-  in Python 3.0.
+- The sgmllib and htmllib modules have been deprecated for removal in Python
+  3.0.
 
-- Issue #3011: locale module alias table was updated to the latest
-  version from the X.org locale.alias file.
+- bpo-3011: locale module alias table was updated to the latest version from
+  the X.org locale.alias file.
 
-- Issue #1797 (partial fix): ctypes NULL function pointers have a
-  False boolean value now.
+- bpo-1797: ctypes NULL function pointers have a False boolean value now.
 
-- Issue #2985: Allow 64-bit integer responses (``<i8>``) in XMLRPC
-  transfers.
+- bpo-2985: Allow 64-bit integer responses (``<i8>``) in XMLRPC transfers.
 
-- Issue #2877: The UserString.MutableString class has been removed in
-  Python 3.0.
+- bpo-2877: The UserString.MutableString class has been removed in Python
+  3.0.
 
 - Do not close external file objects passed to tarfile.open(mode='w:bz2')
   when the TarFile is closed.
 
-- Issue #2959: For consistency with other file-like objects, gzip's
-  GzipFile.close() can now be called multiple times without raising
-  an exception.
+- bpo-2959: For consistency with other file-like objects, gzip's
+  GzipFile.close() can now be called multiple times without raising an
+  exception.
 
-- Issue #1390: Raise ValueError in toxml when an invalid comment would
+- bpo-1390: Raise ValueError in toxml when an invalid comment would
   otherwise be produced.
 
-- Issue #2914: TimedRotatingFileHandler now takes an optional keyword
-  argument "utc" to use UTC time rather than local time.
+- bpo-2914: TimedRotatingFileHandler now takes an optional keyword argument
+  "utc" to use UTC time rather than local time.
 
-- Issue #2929: TimedRotatingFileHandler was using the wrong path when
-  deleting old log files (filename only instead of full path).
+- bpo-2929: TimedRotatingFileHandler was using the wrong path when deleting
+  old log files (filename only instead of full path).
 
-- Issue #1775025: You can now specify zipfile members to open(),
-  read() or extract() via a ZipInfo instance.  This allows handling
-  duplicate filenames in zipfiles.
+- bpo-1775025: You can now specify zipfile members to open(), read() or
+  extract() via a ZipInfo instance.  This allows handling duplicate
+  filenames in zipfiles.
 
-- Issue #961805: Fix Text.edit_modified() in Tkinter.
+- bpo-961805: Fix Text.edit_modified() in Tkinter.
 
-- Issue #1793: Function ctypes.util.find_msvcrt() added that returns
-  the name of the C runtime library that Python uses.
-  ctypes.util.find_library(name) now call this function when name is
-  'm' or 'c'.
+- bpo-1793: Function ctypes.util.find_msvcrt() added that returns the name
+  of the C runtime library that Python uses. ctypes.util.find_library(name)
+  now call this function when name is 'm' or 'c'.
 
 - The statvfs module has been deprecated for removal in Python 3.0.
 
-- The sunaudiodev and SUNAUDIODEV modules have been deprecated for
-  removal in Python 3.0.
+- The sunaudiodev and SUNAUDIODEV modules have been deprecated for removal
+  in Python 3.0.
 
-- The WAIT module from IRIX has been deprecated for removal in Python
-  3.0.
+- The WAIT module from IRIX has been deprecated for removal in Python 3.0.
 
-- The torgb module from IRIX has been deprecated for removal in Python
-  3.0.
+- The torgb module from IRIX has been deprecated for removal in Python 3.0.
 
-- The SV module from IRIX has been deprecated for removal in Python
-  3.0.
+- The SV module from IRIX has been deprecated for removal in Python 3.0.
 
-- The readcd module from IRIX has been deprecated for removal in
-  Python 3.0.
-
-- The panelparser module from IRIX has been deprecated for removal in
-  Python 3.0.
+- The readcd module from IRIX has been deprecated for removal in Python 3.0.
 
-- The panel module from IRIX has been deprecated for removal in Python
+- The panelparser module from IRIX has been deprecated for removal in Python
   3.0.
 
-- The jpeg module from IRIX has been deprecated for removal in Python
-  3.0.
+- The panel module from IRIX has been deprecated for removal in Python 3.0.
 
-- The IOCTL module from IRIX has been deprecated for removal in Python
-  3.0.
+- The jpeg module from IRIX has been deprecated for removal in Python 3.0.
 
-- The IN module from IRIX has been deprecated for removal in Python
-  3.0.
+- The IOCTL module from IRIX has been deprecated for removal in Python 3.0.
 
-- The imgfile module from IRIX has been deprecated for removal in
-  Python 3.0.
+- The IN module from IRIX has been deprecated for removal in Python 3.0.
 
-- The GLWS module from IRIX has been deprecated for removal in Python
+- The imgfile module from IRIX has been deprecated for removal in Python
   3.0.
 
-- The GET module from IRIX has been deprecated for removal in Python
-  3.0.
+- The GLWS module from IRIX has been deprecated for removal in Python 3.0.
 
-- The fm module from IRIX has been deprecated for removal in Python
-  3.0.
+- The GET module from IRIX has been deprecated for removal in Python 3.0.
 
-- The FL, flp, and fl modules from IRIX have been deprecated for
-  removal in Python 3.0.
+- The fm module from IRIX has been deprecated for removal in Python 3.0.
 
-- The FILE module on IRIX has been deprecated for removal in Python
-  3.0.
+- The FL, flp, and fl modules from IRIX have been deprecated for removal in
+  Python 3.0.
 
-- The ERRNO module on IRIX has been deprecated for removal in Python
-  3.0.
+- The FILE module on IRIX has been deprecated for removal in Python 3.0.
+
+- The ERRNO module on IRIX has been deprecated for removal in Python 3.0.
 
 - The DEVICE, GL, gl, and cgen modules (which indirectly includes
   cgensupport) have been deprecated for removal in Python 3.0.
 
-- The CL, CL_old, and cl modules for IRIX have been deprecated for
-  removal in Python 3.0.
-
-- The cdplayer module for IRIX has been deprecated for removal in
-  Python 3.0.
+- The CL, CL_old, and cl modules for IRIX have been deprecated for removal
+  in Python 3.0.
 
-- The cddb module for IRIX has been deprecated for removal in Python
+- The cdplayer module for IRIX has been deprecated for removal in Python
   3.0.
 
-- The cd and CD modules for IRIX have been deprecated for removal in
-  Python 3.0.
+- The cddb module for IRIX has been deprecated for removal in Python 3.0.
 
-- The al and AL modules for IRIX have been deprecated for removal in
-  Python 3.0.
+- The cd and CD modules for IRIX have been deprecated for removal in Python
+  3.0.
+
+- The al and AL modules for IRIX have been deprecated for removal in Python
+  3.0.
 
-- Issue #1713041: fix pprint's handling of maximum depth.
+- bpo-1713041: fix pprint's handling of maximum depth.
 
 - The timing module has been deprecated for removal in Python 3.0.
 
@@ -10197,17 +10623,14 @@ Library
 
 - The imageop module has been deprecated for removal in Python 3.0.
 
-- Issue #2250: Exceptions raised during evaluation of names in
-  rlcompleter's ``Completer.complete()`` method are now caught and
-  ignored.
+- bpo-2250: Exceptions raised during evaluation of names in rlcompleter's
+  ``Completer.complete()`` method are now caught and ignored.
 
-- Issue #2659: Added ``break_on_hyphens`` option to textwrap
-  TextWrapper class.
+- bpo-2659: Added ``break_on_hyphens`` option to textwrap TextWrapper class.
 
 - The mhlib module has been deprecated for removal in Python 3.0.
 
-- The linuxaudiodev module has been deprecated for removal in Python
-  3.0.
+- The linuxaudiodev module has been deprecated for removal in Python 3.0.
 
 - The ihooks module has been deprecated for removal in Python 3.0.
 
@@ -10219,22 +10642,20 @@ Library
 
 - The compiler package has been deprecated for removal in Python 3.0.
 
-- The Bastion and rexec modules have been deprecated for removal in
-  Python 3.0.
+- The Bastion and rexec modules have been deprecated for removal in Python
+  3.0.
 
 - The bsddb185 module has been deprecated for removal in Python 3.0.
 
 - The pure module has been deprecated for removal in Python 3.0.
 
-- Issue #2487: change the semantics of math.ldexp(x, n) when n is too
-  large to fit in a C long.  ldexp(x, n) now returns a zero (with
-  suitable sign) if n is large and negative; previously, it raised
-  OverflowError.
+- bpo-2487: change the semantics of math.ldexp(x, n) when n is too large to
+  fit in a C long.  ldexp(x, n) now returns a zero (with suitable sign) if n
+  is large and negative; previously, it raised OverflowError.
 
 - The toaiff module has been deprecated for removal in Python 3.0.
 
-- The test.testall module has been deprecated for removal in Python
-  3.0.
+- The test.testall module has been deprecated for removal in Python 3.0.
 
 - The new module has been deprecated for removal in Python 3.0.
 
@@ -10252,16 +10673,16 @@ Library
 
 - pdb gained the "until" command.
 
-- The Mac Modules (including Carbon) have been deprecated for removal
-  in Python 3.0.
+- The Mac Modules (including Carbon) have been deprecated for removal in
+  Python 3.0.
 
-- Library: on MacOS X you can now set ``ARCHFLAGS`` in the shell
-  environment to control the '-arch' flags that are used to build
-  an extension. This was added for compatibility with Apple's build
-  of Python.
+- Library: on MacOS X you can now set ``ARCHFLAGS`` in the shell environment
+  to control the '-arch' flags that are used to build an extension. This was
+  added for compatibility with Apple's build of Python.
 
 - The bundled OSX-specific copy of libbffi is now in sync with the version
-  shipped with PyObjC 2.0 and includes support for x86_64 and ppc64 platforms.
+  shipped with PyObjC 2.0 and includes support for x86_64 and ppc64
+  platforms.
 
 - The threading module gained aliases for names that will be removed in the
   3.x series.
@@ -10271,25 +10692,27 @@ Build
 
 - The Windows installer now includes Tk 8.5, bzip2 1.0.5, and SQLite 3.5.9.
 
-- Patch #1722225: Support QNX 6.
+- bpo-1722225: Support QNX 6.
 
 - ``Lib/lib-old`` is now added to sys.path.
 
-- On MacOS X it is now possible to install the framework in 64-bit
-  mode or even as a 4-way universal binary (that is, PPC, i386,
-  PPC64 and x86_64 support in one binary).
+- On MacOS X it is now possible to install the framework in 64-bit mode or
+  even as a 4-way universal binary (that is, PPC, i386, PPC64 and x86_64
+  support in one binary).
 
   This is controlled by the configure argument ``--with-universal-archs``:
 
   - ``--with-universal-archs=all``: install 4-way universal
 
-  - ``--with-universal-archs=32-bit``: install 2-way universal, 32-bit (the default)
+  - ``--with-universal-archs=32-bit``: install 2-way universal, 32-bit (the
+  default)
 
   - ``--with-universal-archs=64-bit``: install 2-way universal, 64-bit
 
   This option should be used in combination with ``--enable-universalsdk=``.
 
-  NOTE: 64-bit and 4-way builds are only suppported on Mac OS X 10.5 (or later).
+  NOTE: 64-bit and 4-way builds are only suppported on Mac OS X 10.5 (or
+  later).
 
 C API
 -----
@@ -10298,9 +10721,8 @@ C API
 
 - The PyBytes functions have been renamed to PyByteArray.
 
-- The PyString functions have been renamed to PyBytes. A batch of
-  defines were added so that the linker still sees the original
-  PyString names.
+- The PyString functions have been renamed to PyBytes. A batch of defines
+  were added so that the linker still sees the original PyString names.
 
 
 What's New in Python 2.6 alpha 3?
@@ -10308,166 +10730,156 @@ What's New in Python 2.6 alpha 3?
 
 *Release date: 08-May-2008*
 
-Core and builtins
+Core and Builtins
 -----------------
 
-- Issue #2719: backported the ``next()`` builtin from Python 3.
+- bpo-2719: backported the ``next()`` builtin from Python 3.
 
-- Issue #2681: The octal literal ``0o8`` was incorrecly acctepted. Now
-  it properly raises a SyntaxError.
+- bpo-2681: The octal literal ``0o8`` was incorrecly acctepted. Now it
+  properly raises a SyntaxError.
 
-- Issue #2617: Reserved -J and -X arguments for Jython, IronPython and
-  other implementations of Python.
+- bpo-2617: Reserved -J and -X arguments for Jython, IronPython and other
+  implementations of Python.
 
 - Implemented PEP 370: Per user site-packages directory.
 
-Extension Modules
------------------
+Library
+-------
 
-- Issue #2670: Fix a failure in urllib2.build_opener(), when passed
-  two handlers that derive the same default base class.
+- bpo-2670: Fix a failure in urllib2.build_opener(), when passed two
+  handlers that derive the same default base class.
 
 - Added kill, terminate and send_signal(sig) to subprocess.Popen.
 
-- Added phase(z) -> phi, polar(z) -> r, phi and rect(r, phi) -> z to
-  the cmath module.
-
-- Four new methods were added to the math and cmath modules: acosh,
-  asinh, atanh and log1p.
+- Added phase(z) -> phi, polar(z) -> r, phi and rect(r, phi) -> z to the
+  cmath module.
 
-- zlib.decompressobj().flush(value) no longer crashes the interpreter
-  when passed a value less than or equal to zero.
+- Four new methods were added to the math and cmath modules: acosh, asinh,
+  atanh and log1p.
 
-- Issue #1631171: Re-implement the 'warnings' module in C (the
-  original Python code has been kept as backup). This will allow for
-  using the 'warning's machinery in such places as the parser where
-  use of pure Python code is not possible.  Both the ``showarning()``
-  and ``formatwarning()`` gain an optional 'line' argument which is
-  not called by default for backwards-compatibility reasons. Setting
-  ``warnings.showwarning()`` to an implementation that lacks support
-  for the ``line`` argument will raise a DeprecationWarning.
+- zlib.decompressobj().flush(value) no longer crashes the interpreter when
+  passed a value less than or equal to zero.
 
-Library
--------
+- bpo-1631171: Re-implement the 'warnings' module in C (the original Python
+  code has been kept as backup). This will allow for using the 'warning's
+  machinery in such places as the parser where use of pure Python code is
+  not possible.  Both the ``showarning()`` and ``formatwarning()`` gain an
+  optional 'line' argument which is not called by default for backwards-
+  compatibility reasons. Setting ``warnings.showwarning()`` to an
+  implementation that lacks support for the ``line`` argument will raise a
+  DeprecationWarning.
 
 - The audiodev module has been deprecated for removal in Python 3.0.
 
-- Issue #2750: Add the 'json' package. Based on simplejson 1.9 and
-  contributed by Bob Ippolito.
+- bpo-2750: Add the 'json' package. Based on simplejson 1.9 and contributed
+  by Bob Ippolito.
 
-- Issue #1734346: Support Unicode file names for zipfiles.
+- bpo-1734346: Support Unicode file names for zipfiles.
 
-- Issue #2581: distutils: Vista UAC/elevation support for
-  bdist_wininst.
+- bpo-2581: distutils: Vista UAC/elevation support for bdist_wininst.
 
-- Issue #2635: Fix bug in 'fix_sentence_endings' textwrap.fill option,
-  where an extra space was added after a word containing (but not
-  ending in) '.', '!' or '?'.
+- bpo-2635: Fix bug in 'fix_sentence_endings' textwrap.fill option, where an
+  extra space was added after a word containing (but not ending in) '.', '!'
+  or '?'.
 
-- Add from_buffer() and from_buffer_copy() class methods to ctypes
-  data types.
+- Add from_buffer() and from_buffer_copy() class methods to ctypes data
+  types.
 
-- Issue #2682: ctypes callback functions no longer contain a cyclic
-  reference to themselves.
+- bpo-2682: ctypes callback functions no longer contain a cyclic reference
+  to themselves.
 
-- The getpass module has been improved on Unix.  It now uses /dev/tty
-  by default and uses stderr instead of stdout.  A GetPassWarning is
-  issued when input echo cannot be controlled.
+- The getpass module has been improved on Unix.  It now uses /dev/tty by
+  default and uses stderr instead of stdout.  A GetPassWarning is issued
+  when input echo cannot be controlled.
 
-- Issue #2014: Allow XML-RPC datetime objects to have dates before
-  1900-01-01.
+- bpo-2014: Allow XML-RPC datetime objects to have dates before 1900-01-01.
 
-- Issue #2439: Added new function pkgutil.get_data(), which is a
-  convenience wrapper for the PEP 302 get_data() API.
+- bpo-2439: Added new function pkgutil.get_data(), which is a convenience
+  wrapper for the PEP 302 get_data() API.
 
-- Issue #2616: The ctypes.pointer() and ctypes.POINTER() functions are
-  now implemented in C for better performance.
+- bpo-2616: The ctypes.pointer() and ctypes.POINTER() functions are now
+  implemented in C for better performance.
 
-- Issue #2408: The ``_types`` module, which was used as in
-  implementation detail of the public ``types`` module, has been
-  removed and replaced by pure python code.
+- bpo-2408: The ``_types`` module, which was used as in implementation
+  detail of the public ``types`` module, has been removed and replaced by
+  pure python code.
 
-- Issue #2513: distutils on Windows is now capable of cross-compiling
-  extension modules between 32 and 64 bit platforms.  See the distutls
-  build documentation for more information.
+- bpo-2513: distutils on Windows is now capable of cross-compiling extension
+  modules between 32 and 64 bit platforms.  See the distutls build
+  documentation for more information.
 
-- Issue #815646: Individual file objects may now be used from multiple
-  threads at once without fear of crashing the Python interpreter.  If
-  file.close() is called while an object is in use by another thread
-  an IOError exception will be raised and the file will not be closed.
+- bpo-815646: Individual file objects may now be used from multiple threads
+  at once without fear of crashing the Python interpreter.  If file.close()
+  is called while an object is in use by another thread an IOError exception
+  will be raised and the file will not be closed.
 
 - The bundled libffi copy is now in sync with the recently released
   libffi3.0.5 version, apart from some small changes to
   Modules/_ctypes/libffi/configure.ac.
 
-- Issue #2385: distutils.core.run_script() makes __file__ available,
-  so the controlled environment will more closely mirror the typical
-  script environment.  This supports setup.py scripts that refer to
-  data files.
+- bpo-2385: distutils.core.run_script() makes __file__ available, so the
+  controlled environment will more closely mirror the typical script
+  environment.  This supports setup.py scripts that refer to data files.
 
 Tests
 -----
 
-- Issue #2550: The approach used by client/server code for obtaining
-  ports to listen on in network-oriented tests has been refined in an
-  effort to facilitate running multiple instances of the entire
-  regression test suite in parallel without issue.
-  test_support.bind_port() has been fixed such that it will always
-  return a unique port -- which wasn't always the case with the
-  previous implementation, especially if socket options had been set
-  that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT).  The
-  new implementation of bind_port() will actually raise an exception
-  if it is passed an AF_INET/SOCK_STREAM socket with either the
-  SO_REUSEADDR or SO_REUSEPORT socket option set.  Furthermore, if
-  available, bind_port() will set the SO_EXCLUSIVEADDRUSE option on
-  the socket it's been passed.  This currently only applies to
-  Windows.  This option prevents any other sockets from binding to the
-  host/port we've bound to, thus removing the possibility of the
-  'non-deterministic' behaviour, as Microsoft puts it, that occurs
-  when a second SOCK_STREAM socket binds and accepts to a host/port
-  that's already been bound by another socket.  The optional preferred
-  port parameter to bind_port() has been removed.  Under no
+- bpo-2550: The approach used by client/server code for obtaining ports to
+  listen on in network-oriented tests has been refined in an effort to
+  facilitate running multiple instances of the entire regression test suite
+  in parallel without issue. test_support.bind_port() has been fixed such
+  that it will always return a unique port -- which wasn't always the case
+  with the previous implementation, especially if socket options had been
+  set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT).  The
+  new implementation of bind_port() will actually raise an exception if it
+  is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or
+  SO_REUSEPORT socket option set.  Furthermore, if available, bind_port()
+  will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed.
+  This currently only applies to Windows.  This option prevents any other
+  sockets from binding to the host/port we've bound to, thus removing the
+  possibility of the 'non-deterministic' behaviour, as Microsoft puts it,
+  that occurs when a second SOCK_STREAM socket binds and accepts to a
+  host/port that's already been bound by another socket.  The optional
+  preferred port parameter to bind_port() has been removed.  Under no
   circumstances should tests be hard coding ports!
 
-  test_support.find_unused_port() has also been introduced, which will
-  pass a temporary socket object to bind_port() in order to obtain an
-  unused port.  The temporary socket object is then closed and
-  deleted, and the port is returned.  This method should only be used
-  for obtaining an unused port in order to pass to an external program
-  (i.e. the -accept [port] argument to openssl's s_server mode) or as
-  a parameter to a server-oriented class that doesn't give you direct
-  access to the underlying socket used.
+  test_support.find_unused_port() has also been introduced, which will pass
+  a temporary socket object to bind_port() in order to obtain an unused
+  port. The temporary socket object is then closed and deleted, and the port
+  is returned.  This method should only be used for obtaining an unused port
+  in order to pass to an external program (i.e. the -accept [port] argument
+  to openssl's s_server mode) or as a parameter to a server-oriented class
+  that doesn't give you direct access to the underlying socket used.
 
-  Finally, test_support.HOST has been introduced, which should be used
-  for the host argument of any relevant socket calls (i.e. bind and
-  connect).
+  Finally, test_support.HOST has been introduced, which should be used for
+  the host argument of any relevant socket calls (i.e. bind and connect).
 
   The following tests were updated to following the new conventions:
-    test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
-    test_poplib, test_ftplib, test_telnetlib, test_socketserver,
-    test_asynchat and test_socket_ssl.
+  test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
+  test_poplib, test_ftplib, test_telnetlib, test_socketserver,
+  test_asynchat and test_socket_ssl.
 
-  It is now possible for multiple instances of the regression test
-  suite to run in parallel without issue.
+  It is now possible for multiple instances of the regression test suite to
+  run in parallel without issue.
 
 Build
 -----
 
-- Issue #1496032: On alpha, use -mieee when gcc is the compiler.
+- bpo-1496032: On alpha, use -mieee when gcc is the compiler.
 
-- Issue #2544: On HP-UX systems, use 'gcc -shared' for linking when
-  gcc is used as compiler.
+- bpo-2544: On HP-UX systems, use 'gcc -shared' for linking when gcc is used
+  as compiler.
 
-- Issue #2573: On MacOS X it is now possible to install the framework
-  with a different name using --with-framework-name=NAME.
+- bpo-2573: On MacOS X it is now possible to install the framework with a
+  different name using --with-framework-name=NAME.
 
 C API
 -----
 
-- Added implementation of copysign, acosh, asinh, atanh and log1p to
-  the new files Include/pymath.h and Python/pymath.h for platforms
-  which provide the functions through their libm. The files also
-  contains several helpers and constants for math.
+- Added implementation of copysign, acosh, asinh, atanh and log1p to the new
+  files Include/pymath.h and Python/pymath.h for platforms which provide the
+  functions through their libm. The files also contains several helpers and
+  constants for math.
 
 - Added a new convenience macro, PyErr_WarnPy3k, for issuing Py3k warnings.
 
@@ -10477,195 +10889,184 @@ What's New in Python 2.6 alpha 2?
 
 *Release date: 02-Apr-2008*
 
-Core and builtins
+Core and Builtins
 -----------------
 
-- Issue #1733757: The interpreter would hang on shutdown if the
-  tracing function set by sys.settrace is still active and happens to
-  call threading.currentThread().
+- bpo-1733757: The interpreter would hang on shutdown if the tracing
+  function set by sys.settrace is still active and happens to call
+  threading.currentThread().
 
-- Patch #1442: properly report exceptions when the PYTHONSTARTUP file
-  cannot be executed.
+- bpo-1442: properly report exceptions when the PYTHONSTARTUP file cannot be
+  executed.
 
 - The compilation of a class nested in another class used to leak one
   reference on the outer class name.
 
-- Patch #1810: compile() can now compile _ast trees as returned by
+- bpo-1810: compile() can now compile _ast trees as returned by
   ``compile(..., PyCF_ONLY_AST)``.
 
-- Patch #2426: Added sqlite3.Connection.iterdump method to allow easy
-  dumping of databases.  Contributed by Paul Kippes at PyCon 2008.
+- bpo-2426: Added sqlite3.Connection.iterdump method to allow easy dumping
+  of databases. Contributed by Paul Kippes at PyCon 2008.
 
-- Patch #2477: Added from __future__ import unicode_literals.
+- bpo-2477: Added from __future__ import unicode_literals.
 
 - Added backport of bytearray type.
 
-- Issue #2355: add Py3k warning for buffer().
+- bpo-2355: add Py3k warning for buffer().
 
-- Issue #1477: With narrow Unicode builds, the unicode escape sequence
-  \Uxxxxxxxx did not accept values outside the Basic Multilingual
-  Plane.  This affected raw unicode literals and the
-  'raw-unicode-escape' codec.  Now UTF-16 surrogates are generated in
-  this case, like normal unicode literals and the 'unicode-escape'
-  codec.
+- bpo-1477: With narrow Unicode builds, the unicode escape sequence
+  \Uxxxxxxxx did not accept values outside the Basic Multilingual Plane.
+  This affected raw unicode literals and the 'raw-unicode-escape' codec.
+  Now UTF-16 surrogates are generated in this case, like normal unicode
+  literals and the 'unicode- escape' codec.
 
-- Issue #2348: add Py3k warning for file.softspace.
+- bpo-2348: add Py3k warning for file.softspace.
 
-- Issue #2346/#2347: add Py3k warnings for __methods__ and
-  __members__.
+- bpo-2346: add Py3k warnings for __methods__ and __members__. (See also:
+  bpo-2347)
 
-- Issue #2358: Add a Py3k warning on sys.exc_clear() usage.
+- bpo-2358: Add a Py3k warning on sys.exc_clear() usage.
 
-- Issue #2400: Allow relative imports to "import *".
+- bpo-2400: Allow relative imports to "import *".
 
-- Issue #1745: Backport print function with ``from __future__ import
+- bpo-1745: Backport print function with ``from __future__ import
   print_function``.
 
-- Issue #2332: add new attribute names for instance method objects.
-  The two changes are: im_self -> __self__ and im_func -> __func__
+- bpo-2332: add new attribute names for instance method objects. The two
+  changes are: im_self -> __self__ and im_func -> __func__
 
-- Issue #2379: Raise a Py3K warning for __getitem__ or __getslice__ on
+- bpo-2379: Raise a Py3K warning for __getitem__ or __getslice__ on
   exception instances.
 
-- Issue #2371: Add a Py3k warning when catching an exception that
-  doesn't derive from BaseException.
+- bpo-2371: Add a Py3k warning when catching an exception that doesn't
+  derive from BaseException.
 
-- Issue #2341: Add a Py3k warning when raising an exception that
-  doesn't derive from BaseException.
+- bpo-2341: Add a Py3k warning when raising an exception that doesn't derive
+  from BaseException.
 
-- Issue #2321: use pymalloc for unicode object string data to reduce
-  memory usage in some circumstances.
+- bpo-2321: use pymalloc for unicode object string data to reduce memory
+  usage in some circumstances.
 
-- PEP 3127: octal literals now start with "0o". Old-style octal
-  literals are still valid. There are binary literals with a prefix of
-  "0b".  This also affects int(x, 0).
+- PEP 3127: octal literals now start with "0o". Old-style octal literals are
+  still valid. There are binary literals with a prefix of "0b".  This also
+  affects int(x, 0).
 
-- Issue #2359: Adding deprecation warnings for array.{read,write}.
+- bpo-2359: Adding deprecation warnings for array.{read,write}.
 
-- Issue #1779871: GNU gcc can now build Python on OS X because the
-  flags -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd are no
-  longer passed.
+- bpo-1779871: GNU gcc can now build Python on OS X because the flags -Wno-
+  long-double, -no-cpp-precomp, and -mno-fused-madd are no longer passed.
 
 - Add a warning when asserting a non-empty tuple which is always true.
 
-- Issue #2179: speed up with statement execution by storing the exit
-  method on the stack instead of in a temporary variable (patch by
-  Jeffrey Yaskin)
+- bpo-2179: speed up with statement execution by storing the exit method on
+  the stack instead of in a temporary variable (patch by Jeffrey Yaskin)
 
-- Issue #2238: Some syntax errors in *args and **kwargs expressions
-  could give bogus error messages.
+- bpo-2238: Some syntax errors in *args and **kwargs expressions could give
+  bogus error messages.
 
-- Issue #2143: Fix embedded readline() hang on SSL socket EOF.
-
-Extension Modules
------------------
-
-- Patch #2240: Implement signal.setitimer and signal.getitimer.
+- bpo-2143: Fix embedded readline() hang on SSL socket EOF.
 
 Library
 -------
 
-- Issue #2315: logging.handlers: TimedRotatingFileHandler now accounts
-  for daylight savings time in calculating the next rollover.
+- bpo-2240: Implement signal.setitimer and signal.getitimer.
 
-- Issue #2316: logging.handlers: TimedRotatingFileHandler now
-  calculates rollovers correctly even when nothing is logged for a
-  while.
+- bpo-2315: logging.handlers: TimedRotatingFileHandler now accounts for
+  daylight savings time in calculating the next rollover.
+
+- bpo-2316: logging.handlers: TimedRotatingFileHandler now calculates
+  rollovers correctly even when nothing is logged for a while.
 
-- Issue #2317: logging.handlers: TimedRotatingFileHandler now uses
-  improved logic for removing old files.
+- bpo-2317: logging.handlers: TimedRotatingFileHandler now uses improved
+  logic for removing old files.
 
-- Issue #2495: tokenize.untokenize now inserts a space between two
-  consecutive string literals; previously, ["" ""] was rendered as
-  [""""], which is incorrect python code.
+- bpo-2495: tokenize.untokenize now inserts a space between two consecutive
+  string literals; previously, ["" ""] was rendered as [""""], which is
+  incorrect python code.
 
-- Issue #2248: return the result of the QUIT command. from
-  SMTP.quit().
+- bpo-2248: return the result of the QUIT command. from SMTP.quit().
 
 - Backport of Python 3.0's io module.
 
-- Issue #2482: Make sure that the coefficient of a Decimal is always
-  stored as a str instance, not as a unicode instance.  This ensures
-  that str(Decimal) is always an instance of str.
+- bpo-2482: Make sure that the coefficient of a Decimal is always stored as
+  a str instance, not as a unicode instance.  This ensures that str(Decimal)
+  is always an instance of str.
 
-- Issue #2478: fix failure of decimal.Decimal(0).sqrt()
+- bpo-2478: fix failure of decimal.Decimal(0).sqrt()
 
-- Issue #2432: give DictReader the dialect and line_num attributes
-  advertised in the docs.
+- bpo-2432: give DictReader the dialect and line_num attributes advertised
+  in the docs.
 
-- Issue #2460: Make Ellipsis object copyable.
+- bpo-2460: Make Ellipsis object copyable.
 
-- Issue #1681432: Add triangular distribution to the random module
+- bpo-1681432: Add triangular distribution to the random module
 
-- Issue #2136: urllib2's auth handler now allows single-quoted realms
-  in the WWW-Authenticate header.
+- bpo-2136: urllib2's auth handler now allows single-quoted realms in the
+  WWW- Authenticate header.
 
-- Issue #2434: Enhanced platform.win32_ver() to also work on Python
+- bpo-2434: Enhanced platform.win32_ver() to also work on Python
   installation which do not have the win32all package installed.
 
-- Added support to platform.uname() to also report the machine and
-  processor information on Windows XP and later. As a result,
-  platform.machine() and platform.processor() will report this
-  information as well.
+- Added support to platform.uname() to also report the machine and processor
+  information on Windows XP and later. As a result, platform.machine() and
+  platform.processor() will report this information as well.
 
-- The library implementing the 2to3 conversion, lib2to3, was added to
-  the standard distribution.
+- The library implementing the 2to3 conversion, lib2to3, was added to the
+  standard distribution.
 
-- Issue #1747858: Fix chown to work with large uid's and gid's on
-  64-bit platforms.
+- bpo-1747858: Fix chown to work with large uid's and gid's on 64-bit
+  platforms.
 
-- Issue #1202: zlib.crc32 and zlib.adler32 no longer return different
-  values on 32-bit vs. 64-bit python interpreters.  Both were correct,
-  but they now both return a signed integer object for consistency.
+- bpo-1202: zlib.crc32 and zlib.adler32 no longer return different values on
+  32-bit vs. 64-bit python interpreters.  Both were correct, but they now
+  both return a signed integer object for consistency.
 
-- Issue #1158: add %f format (fractions of a second represented as
+- bpo-1158: add %f format (fractions of a second represented as
   microseconds) to datetime objects.  Understood by both strptime and
   strftime.
 
-- Issue #705836: struct.pack(">f", x) now raises OverflowError on all
-  platforms when x is too large to fit into an IEEE 754 float;
-  previously it only raised OverflowError on non IEEE 754 platforms.
+- bpo-705836: struct.pack(">f", x) now raises OverflowError on all platforms
+  when x is too large to fit into an IEEE 754 float; previously it only
+  raised OverflowError on non IEEE 754 platforms.
 
-- Issues #2166, #1741 and #1531505: now distutils deals with HOME
-  correctly under win32
+- bpo-2166: now distutils deals with HOME correctly under win32 (See also:
+  bpo-1741, bpo-1531505)
 
-- Patch #1858: distutils: added multiple server support in .pypirc
+- bpo-1858: distutils: added multiple server support in .pypirc
 
-- Issue #1106316: pdb.post_mortem()'s parameter, "traceback", is now
-  optional: it defaults to the traceback of the exception that is
-  currently being handled (is mandatory to be in the middle of an
-  exception, otherwise it raises ValueError).
+- bpo-1106316: pdb.post_mortem()'s parameter, "traceback", is now optional:
+  it defaults to the traceback of the exception that is currently being
+  handled (is mandatory to be in the middle of an exception, otherwise it
+  raises ValueError).
 
-- Issue #1193577: A .shutdown() method has been added to SocketServers
-  which terminates the .serve_forever() loop.
+- bpo-1193577: A .shutdown() method has been added to SocketServers which
+  terminates the .serve_forever() loop.
 
-- Issue #2220: handle rlcompleter attribute match failure more
-  gracefully.
+- bpo-2220: handle rlcompleter attribute match failure more gracefully.
 
-- Issue #2225: py_compile, when executed as a script, now returns a
-  non- zero status code if not all files could be compiled
-  successfully.
+- bpo-2225: py_compile, when executed as a script, now returns a non- zero
+  status code if not all files could be compiled successfully.
 
-- Bug #1725737: In distutils' sdist, exclude RCS, CVS etc. also in the
-  root directory, and also exclude .hg, .git, .bzr, and _darcs.
+- bpo-1725737: In distutils' sdist, exclude RCS, CVS etc. also in the root
+  directory, and also exclude .hg, .git, .bzr, and _darcs.
 
-- Issue #1872: The struct module typecode for _Bool has been changed
-  from 't' to '?'.
+- bpo-1872: The struct module typecode for _Bool has been changed from 't'
+  to '?'.
 
 - The bundled libffi copy is now in sync with the recently released
   libffi3.0.4 version, apart from some small changes to
-  Modules/_ctypes/libffi/configure.ac.  On OS X, preconfigured libffi
-  files are used.  On all linux systems the --with-system-ffi
-  configure option defaults to "yes".
+  Modules/_ctypes/libffi/configure.ac.  On OS X, preconfigured libffi files
+  are used.  On all linux systems the --with-system-ffi configure option
+  defaults to "yes".
 
-- Issue #1577: shutil.move() now calls os.rename() if the destination
-  is a directory instead of copying-then-remove-source.
+- bpo-1577: shutil.move() now calls os.rename() if the destination is a
+  directory instead of copying-then-remove-source.
 
 Tests
 -----
 
-- test_nis no longer fails when test.test_support.verbose is true and
-  NIS is not set up on the testing machine.
+- test_nis no longer fails when test.test_support.verbose is true and NIS is
+  not set up on the testing machine.
 
 - Output comparison tests are no longer supported.
 
@@ -10678,34 +11079,33 @@ Tests
 - GHOP 293: Convert test_strftime, test_getargs, and test_pep247 to
   unittest.
 
-- Issue #2055: Convert test_fcntl to unittest.
+- bpo-2055: Convert test_fcntl to unittest.
 
-- Issue #1960: Convert test_gdbm to unittest.
+- bpo-1960: Convert test_gdbm to unittest.
 
-- GHOP 294: Convert test_contains, test_crypt, and test_select to
-  unittest.
+- GHOP 294: Convert test_contains, test_crypt, and test_select to unittest.
 
 - GHOP 238: Convert test_tokenize to use doctest.
 
 - GHOP 237: Rewrite test_thread using unittest.
 
-- Patch #2232: os.tmpfile might fail on Windows if the user has no
-  permission to create files in the root directory.
+- bpo-2232: os.tmpfile might fail on Windows if the user has no permission
+  to create files in the root directory.
 
 Build
 -----
 
 - A new script 2to3 is now installed, to run the 2.x to 3.x converter.
 
-- Python/memmove.c and Python/strerror.c have been removed; both
-  functions are in the C89 standard library.
+- Python/memmove.c and Python/strerror.c have been removed; both functions
+  are in the C89 standard library.
 
-- Patch #2284: Add -x64 option to rt.bat.
+- bpo-2284: Add -x64 option to rt.bat.
 
 C API
 -----
 
-- Patch #2477: Added PyParser_ParseFileFlagsEx() and
+- bpo-2477: Added PyParser_ParseFileFlagsEx() and
   PyParser_ParseStringFlagsFilenameEx().
 
 
@@ -10714,189 +11114,180 @@ What's New in Python 2.6 alpha 1?
 
 *Release date: 29-Feb-2008*
 
-Core and builtins
+Core and Builtins
 -----------------
 
-- Issue #2051: pyc and pyo files are no longer created with permission
-  644. The mode is now inherited from the py file.
+- bpo-2051: pyc and pyo files are no longer created with permission 644. The
+  mode is now inherited from the py file.
 
-- Issue #2067: file.__exit__() now calls subclasses' close() method.
+- bpo-2067: file.__exit__() now calls subclasses' close() method.
 
-- Patch #1759: Backport of PEP 3129 class decorators.
+- bpo-1759: Backport of PEP 3129 class decorators.
 
-- Issue #1881: An internal parser limit has been increased. Also see
-  issue #215555 for a discussion.
+- bpo-1881: An internal parser limit has been increased. Also see issue
+  #215555 for a discussion.
 
-- Added the future_builtins module, which contains hex() and oct().
-  These are the PEP 3127 version of these functions, designed to be
-  compatible with the hex() and oct() builtins from Python 3.0.  They
-  differ slightly in their output formats from the existing, unchanged
-  Python 2.6 builtins.  The expected usage of the future_builtins
-  module is:
-    from future_builtins import hex, oct
+- Added the future_builtins module, which contains hex() and oct(). These
+  are the PEP 3127 version of these functions, designed to be compatible
+  with the hex() and oct() builtins from Python 3.0.  They differ slightly
+  in their output formats from the existing, unchanged Python 2.6 builtins.
+  The expected usage of the future_builtins module is:   from
+  future_builtins import hex, oct
 
-- Issue #1600: Modified PyOS_ascii_formatd to use at most 2 digit
-  exponents for exponents with absolute value < 100.  Follows C99
-  standard.  This is a change on Windows, which would use 3 digits.
-  Also, added 'n' to the formats that PyOS_ascii_formatd understands,
-  so that any alterations it does to the resulting string will be
-  available in stringlib/formatter.h (for float.__format__).
+- bpo-1600: Modified PyOS_ascii_formatd to use at most 2 digit exponents for
+  exponents with absolute value < 100.  Follows C99 standard.  This is a
+  change on Windows, which would use 3 digits. Also, added 'n' to the
+  formats that PyOS_ascii_formatd understands, so that any alterations it
+  does to the resulting string will be available in stringlib/formatter.h
+  (for float.__format__).
 
-- Implemented PEP 3101, Advanced String Formatting.  This adds a new
-  builtin format(); a format() method for str and unicode; a
-  __format__() method to object, str, unicode, int, long, float, and
-  datetime; the class string.Formatter; and the C API
-  PyObject_Format().
+- Implemented PEP 3101, Advanced String Formatting.  This adds a new builtin
+  format(); a format() method for str and unicode; a __format__() method to
+  object, str, unicode, int, long, float, and datetime; the class
+  string.Formatter; and the C API PyObject_Format().
 
-- Fixed several potential crashes, all caused by specially crafted
-  __del__ methods exploiting objects in temporarily inconsistent
-  state.
+- Fixed several potential crashes, all caused by specially crafted __del__
+  methods exploiting objects in temporarily inconsistent state.
 
-- Issue #2115: Important speedup in setting __slot__ attributes.  Also
-  prevent a possible crash: an Abstract Base Class would try to access
-  a slot on a registered virtual subclass.
+- bpo-2115: Important speedup in setting __slot__ attributes.  Also prevent
+  a possible crash: an Abstract Base Class would try to access a slot on a
+  registered virtual subclass.
 
-- Fixed repr() and str() of complex numbers with infinity or nan as
-  real or imaginary part.
+- Fixed repr() and str() of complex numbers with infinity or nan as real or
+  imaginary part.
 
-- Clear all free lists during a gc.collect() of the highest generation
-  in order to allow pymalloc to free more arenas. Python may give back
-  memory to the OS earlier.
+- Clear all free lists during a gc.collect() of the highest generation in
+  order to allow pymalloc to free more arenas. Python may give back memory
+  to the OS earlier.
 
-- Issue #2045: Fix an infinite recursion triggered when printing a
-  subclass of collections.defaultdict, if its default_factory is set
-  to a bound method.
+- bpo-2045: Fix an infinite recursion triggered when printing a subclass of
+  collections.defaultdict, if its default_factory is set to a bound method.
 
-- Fixed a minor memory leak in dictobject.c. The content of the free
-  list was not freed on interpreter shutdown.
+- Fixed a minor memory leak in dictobject.c. The content of the free list
+  was not freed on interpreter shutdown.
 
-- Limit free list of method and built-in function objects to 256
-  entries each.
+- Limit free list of method and built-in function objects to 256 entries
+  each.
 
-- Patch #1953: Added ``sys._compact_freelists()`` and the C API
-  functions ``PyInt_CompactFreeList`` and ``PyFloat_CompactFreeList``
-  to compact the internal free lists of pre-allocted ints and floats.
+- bpo-1953: Added ``sys._compact_freelists()`` and the C API functions
+  ``PyInt_CompactFreeList`` and ``PyFloat_CompactFreeList`` to compact the
+  internal free lists of pre-allocted ints and floats.
 
-- Issue #1983: Fixed return type of fork(), fork1() and forkpty()
-  calls.  Python expected the return type int but the fork familie
-  returns pi_t.
+- bpo-1983: Fixed return type of fork(), fork1() and forkpty() calls.
+  Python expected the return type int but the fork familie returns pi_t.
 
-- Issue #1678380: Fix a bug that identifies 0j and -0j when they
-  appear in the same code unit.
+- bpo-1678380: Fix a bug that identifies 0j and -0j when they appear in the
+  same code unit.
 
-- Issue #2025: Add tuple.count() and tuple.index() methods to comply
-  with the collections.Sequence API.
+- bpo-2025: Add tuple.count() and tuple.index() methods to comply with the
+  collections.Sequence API.
 
-- Patch #1970 by Antoine Pitrou: Speedup unicode whitespace and
-  linebreak detection
+- bpo-1970: Speedup unicode whitespace and linebreak detection.  (Patch by
+  Antoine Pitrou.)
 
-- Added ``PyType_ClearCache()`` and ``sys._clear_type_cache`` to clear
-  the internal lookup cache for ref leak tests.
+- Added ``PyType_ClearCache()`` and ``sys._clear_type_cache`` to clear the
+  internal lookup cache for ref leak tests.
 
-- Patch #1473257: generator objects gain a gi_code attribute. This is
-  the same object as the func_code attribute of the function that
-  produced the generator.
+- bpo-1473257: generator objects gain a gi_code attribute. This is the same
+  object as the func_code attribute of the function that produced the
+  generator.
 
-- Issue #1920: "while 0" statements were completely removed by the
-  compiler, even in the presence of an "else" clause, which is
-  supposed to be run when the condition is false. Now the compiler
-  correctly emits bytecode for the "else" suite.
+- bpo-1920: "while 0" statements were completely removed by the compiler,
+  even in the presence of an "else" clause, which is supposed to be run when
+  the condition is false. Now the compiler correctly emits bytecode for the
+  "else" suite.
 
 - A few crashers fixed: weakref_in_del.py (issue #1377858);
-  loosing_dict_ref.py (issue #1303614, test67.py);
-  borrowed_ref_[34].py (not in tracker).
+  loosing_dict_ref.py (issue #1303614, test67.py); borrowed_ref_[34].py (not
+  in tracker).
 
-- Issue #1069410: The "can't load dll" message box on Windows is
-  suppressed while an extension is loaded by calling SetErrorMode in
-  dynload_win.c. The error is still reported properly.
+- bpo-1069410: The "can't load dll" message box on Windows is suppressed
+  while an extension is loaded by calling SetErrorMode in dynload_win.c. The
+  error is still reported properly.
 
-- Issue #1915: Python compiles with --enable-unicode=no again. However
-  several extension methods and modules do not work without unicode
-  support.
+- bpo-1915: Python compiles with --enable-unicode=no again. However several
+  extension methods and modules do not work without unicode support.
 
-- Issue #1882: when compiling code from a string, encoding cookies in the
+- bpo-1882: when compiling code from a string, encoding cookies in the
   second line of code were not always recognized correctly.
 
-- Issue #1679: "0x" was taken as a valid integer literal.
+- bpo-1679: "0x" was taken as a valid integer literal.
 
-- Issue #1865: ``bytes`` as an alias for ``str`` and b"" as an alias "" were
+- bpo-1865: ``bytes`` as an alias for ``str`` and b"" as an alias "" were
   added.
 
-- sys.float_info / PyFloat_GetInfo: The floating point information
-  object was converted from a dict to a specialized structseq object.
+- sys.float_info / PyFloat_GetInfo: The floating point information object
+  was converted from a dict to a specialized structseq object.
 
-- Patch #1816: Added sys.flags structseq. It exposes the status of
-  most command line arguments and PYTHON* environment variables.
+- bpo-1816: Added sys.flags structseq. It exposes the status of most command
+  line arguments and PYTHON* environment variables.
 
-- Objects/structseq.c: Implemented new structseq representation. The
-  patch makes structseqs (e.g. the return value of os.stat) more
-  readable.
+- Objects/structseq.c: Implemented new structseq representation. The patch
+  makes structseqs (e.g. the return value of os.stat) more readable.
 
-- Patch #1700288: added a type attribute cache that caches method
-  accesses, resulting in speedups in heavily object-oriented code.
+- bpo-1700288: added a type attribute cache that caches method accesses,
+  resulting in speedups in heavily object-oriented code.
 
-- Bug #1776: __import__() no longer accepts filenames on any platform.
-  The first parameter to __import__() must be a valid module name.
+- bpo-1776: __import__() no longer accepts filenames on any platform. The
+  first parameter to __import__() must be a valid module name.
 
-- Patch #1668: renamed THREADDEBUG envvar to PYTHONTHREADDEBUG.
+- bpo-1668: renamed THREADDEBUG envvar to PYTHONTHREADDEBUG.
 
-- Patch #602345: Add -B command line option, PYTHONDONTWRITEBYTECODE
-  envvar and sys.dont_write_bytecode attribute. All these can be set
-  to forbid Python to attempt to write compiled bytecode files.
+- bpo-602345: Add -B command line option, PYTHONDONTWRITEBYTECODE envvar and
+  sys.dont_write_bytecode attribute. All these can be set to forbid Python
+  to attempt to write compiled bytecode files.
 
-- Improve some exception messages when Windows fails to load an
-  extension module. Now we get for example '%1 is not a valid Win32
-  application' instead of 'error code 193'.
+- Improve some exception messages when Windows fails to load an extension
+  module. Now we get for example '%1 is not a valid Win32 application'
+  instead of 'error code 193'.
 
-- Bug #1481296: Fixed long(float('nan')) != 0L.
+- bpo-1481296: Fixed long(float('nan')) != 0L.
 
-- Issue #1640: Added math.isinf(x), math.isnan(x) and math.copysign(x,
-  y) functions.
+- bpo-1640: Added math.isinf(x), math.isnan(x) and math.copysign(x, y)
+  functions.
 
-- Issue #1635: Platform independent creation and representation of NaN
-  and INF. float("nan"), float("inf") and float("-inf") now work on
-  every platform with IEEE 754 semantics.
+- bpo-1635: Platform independent creation and representation of NaN and INF.
+  float("nan"), float("inf") and float("-inf") now work on every platform
+  with IEEE 754 semantics.
 
-- Compiler now generates simpler and faster code for dictionary
-  literals.  The oparg for BUILD_MAP now indicates an estimated
-  dictionary size.  There is a new opcode, STORE_MAP, for adding
-  entries to the dictionary.
+- Compiler now generates simpler and faster code for dictionary literals.
+  The oparg for BUILD_MAP now indicates an estimated dictionary size.  There
+  is a new opcode, STORE_MAP, for adding entries to the dictionary.
 
-- Issue #1638: %zd configure test fails on Linux.
+- bpo-1638: %zd configure test fails on Linux.
 
-- Issue #1620: New property decorator syntax was modifying the
-  decorator in place instead of creating a new decorator object.
+- bpo-1620: New property decorator syntax was modifying the decorator in
+  place instead of creating a new decorator object.
 
-- Issue #1538: Avoid copying string in split/rsplit if the split char
-  is not found.
+- bpo-1538: Avoid copying string in split/rsplit if the split char is not
+  found.
 
-- Issue #1553: An erroneous __length_hint__ can make list() raise a
+- bpo-1553: An erroneous __length_hint__ can make list() raise a
   SystemError.
 
-- PEP 366: Allow explicit relative imports when executing modules
-  inside packages with the -m switch via a new module level
-  __package__ attribute.
+- PEP 366: Allow explicit relative imports when executing modules inside
+  packages with the -m switch via a new module level __package__ attribute.
 
-- Issue #1402: Fix a crash on exit, when another thread is still
-  running, and if the deallocation of its frames somehow calls the
-  PyGILState_Ensure() / PyGILState_Release() functions.
+- bpo-1402: Fix a crash on exit, when another thread is still running, and
+  if the deallocation of its frames somehow calls the PyGILState_Ensure() /
+  PyGILState_Release() functions.
 
 - Expose the Py_Py3kWarningFlag as sys.py3kwarning.
 
-- Issue #1445: Fix a SystemError when accessing the ``cell_contents``
-  attribute of an empty cell object.
+- bpo-1445: Fix a SystemError when accessing the ``cell_contents`` attribute
+  of an empty cell object.
 
-- Issue #1460: The utf-7 incremental decoder did not accept truncated
-  input.  It now correctly saves its state between chunks of data.
+- bpo-1460: The utf-7 incremental decoder did not accept truncated input.
+  It now correctly saves its state between chunks of data.
 
-- Patch #1739468: Directories and zipfiles containing a __main__.py
-  file can now be directly executed by passing their name to the
-  interpreter. The directory/zipfile is automatically inserted as the
-  first entry in sys.path.
+- bpo-1739468: Directories and zipfiles containing a __main__.py file can
+  now be directly executed by passing their name to the interpreter. The
+  directory/zipfile is automatically inserted as the first entry in
+  sys.path.
 
-- Issue #1265: Fix a problem with sys.settrace, if the tracing
-  function uses a generator expression when at the same time the
-  executed code is closing a paused generator.
+- bpo-1265: Fix a problem with sys.settrace, if the tracing function uses a
+  generator expression when at the same time the executed code is closing a
+  paused generator.
 
 - sets and frozensets now have an isdisjoint() method.
 
@@ -10908,538 +11299,496 @@ Core and builtins
   smaller than LONG_MAX.  Formerly, it raised an OverflowError.  Now,
   automatically shifts from ints to longs.
 
-- Issue #1686386: Tuple's tp_repr did not take into account the
-  possibility of having a self-referential tuple, which is possible
-  from C code.  Nor did object's tp_str consider that a type's tp_str
-  could do something that could lead to an inifinite recursion.
-  Py_ReprEnter() and Py_EnterRecursiveCall(), respectively, fixed the
-  issues.
+- bpo-1686386: Tuple's tp_repr did not take into account the possibility of
+  having a self- referential tuple, which is possible from C code.  Nor did
+  object's tp_str consider that a type's tp_str could do something that
+  could lead to an inifinite recursion. Py_ReprEnter() and
+  Py_EnterRecursiveCall(), respectively, fixed the issues.
 
-- Issue #1164: It was possible to trigger deadlock when using the
-  'print' statement to write to a file since the GIL was not released
-  as needed.  Now PyObject_Print() does the right thing along with
-  various tp_print implementations of the built-in types and those in
-  the collections module.
+- bpo-1164: It was possible to trigger deadlock when using the 'print'
+  statement to write to a file since the GIL was not released as needed.
+  Now PyObject_Print() does the right thing along with various tp_print
+  implementations of the built-in types and those in the collections module.
 
-- Issue #1147: Exceptions were directly allowing string exceptions in
-  their throw() method even though string exceptions no longer
-  allowed.
+- bpo-1147: Exceptions were directly allowing string exceptions in their
+  throw() method even though string exceptions no longer allowed.
 
-- Issue #1096: Prevent a segfault from getting the repr of a very
-  deeply nested list by using the recursion counter.
+- bpo-1096: Prevent a segfault from getting the repr of a very deeply nested
+  list by using the recursion counter.
 
-- Issue #1202533: Fix infinite recursion calls triggered by calls to
-  PyObject_Call() never calling back out to Python code to trigger
-  recursion depth updates/checks.  Required the creation of a static
-  RuntimeError instance in case normalizing an exception put the
-  recursion check value past its limit.  Fixes crashers
-  infinite_rec_(1|2|4|5).py.
+- bpo-1202533: Fix infinite recursion calls triggered by calls to
+  PyObject_Call() never calling back out to Python code to trigger recursion
+  depth updates/checks. Required the creation of a static RuntimeError
+  instance in case normalizing an exception put the recursion check value
+  past its limit.  Fixes crashers infinite_rec_(1|2|4|5).py.
 
-- Patch #1031213: Decode source line in SyntaxErrors back to its
-  original source encoding.
+- bpo-1031213: Decode source line in SyntaxErrors back to its original
+  source encoding.
 
-- Patch #1673759: add a missing overflow check when formatting floats
-  with %G.
+- bpo-1673759: add a missing overflow check when formatting floats with %G.
 
-- Prevent expandtabs() on string and unicode objects from causing a
-  segfault when a large width is passed on 32-bit platforms.
+- Prevent expandtabs() on string and unicode objects from causing a segfault
+  when a large width is passed on 32-bit platforms.
 
-- Issue #1733488: Fix compilation of bufferobject.c on AIX.
+- bpo-1733488: Fix compilation of bufferobject.c on AIX.
 
-- Issue #1722485: remove docstrings again when running with -OO.
+- bpo-1722485: remove docstrings again when running with -OO.
 
-- Add new attribute names for function objects.  All the func_* become
-  __*__ attributes.  (Some already existed, e.g., __doc__ and
-  __name__.)
+- Add new attribute names for function objects.  All the func_* become __*__
+  attributes.  (Some already existed, e.g., __doc__ and __name__.)
 
 - Add -3 option to the interpreter to warn about features that are
   deprecated and will be changed/removed in Python 3.0.
 
-- Patch #1686487: you can now pass any mapping after '**' in function
-  calls.
+- bpo-1686487: you can now pass any mapping after '**' in function calls.
 
-- except clauses may now be spelled either "except E, target:" or
-  "except E as target:". This is to provide forwards compatibility
-  with Python 3.0.
+- except clauses may now be spelled either "except E, target:" or "except E
+  as target:". This is to provide forwards compatibility with Python 3.0.
 
 - Deprecate BaseException.message as per PEP 352.
 
-- Issue #1303614: don't expose object's __dict__ when the dict is
-  inherited from a built-in base.
+- bpo-1303614: don't expose object's __dict__ when the dict is inherited
+  from a built-in base.
 
 - When __slots__ are set to a unicode string, make it work the same as
   setting a plain string, ie don't expand to single letter identifiers.
 
-- Request #1191699: Slices can now be pickled.
+- bpo-1191699: Slices can now be pickled.
 
-- Request #1193128: str.translate() now allows a None argument for
-  translations that only remove characters without re-mapping the
-  remaining characters.
+- bpo-1193128: str.translate() now allows a None argument for translations
+  that only remove characters without re-mapping the remaining characters.
 
-- Patch #1682205: a TypeError while unpacking an iterable is no longer
-  masked by a generic one with the message "unpack non-sequence".
+- bpo-1682205: a TypeError while unpacking an iterable is no longer masked
+  by a generic one with the message "unpack non-sequence".
 
 - Remove unused file Python/fmod.c.
 
-- Bug #1683368: The object.__init__() and object.__new__() methods are
-  now stricter in rejecting excess arguments.  The only time when
-  either allows excess arguments is when it is not overridden and the
-  other one is.  For backwards compatibility, when both are
-  overridden, it is a deprecation warning (for now; maybe a Py3k
-  warning later).  Also, type.__init__() insists on the same signature
-  as supported by type.__new__().
-
-- Patch #1675423: PyComplex_AsCComplex() now tries to convert an
-  object to complex using its __complex__() method before falling back
-  to the __float__() method. Therefore, the functions in the cmath
-  module now can operate on objects that define a __complex__()
-  method.
+- bpo-1683368: The object.__init__() and object.__new__() methods are now
+  stricter in rejecting excess arguments.  The only time when either allows
+  excess arguments is when it is not overridden and the other one is.  For
+  backwards compatibility, when both are overridden, it is a deprecation
+  warning (for now; maybe a Py3k warning later).  Also, type.__init__()
+  insists on the same signature as supported by type.__new__().
 
-- Patch #1623563: allow __class__ assignment for classes with
-  __slots__.  The old and the new class are still required to have the
-  same slot names.
+- bpo-1675423: PyComplex_AsCComplex() now tries to convert an object to
+  complex using its __complex__() method before falling back to the
+  __float__() method. Therefore, the functions in the cmath module now can
+  operate on objects that define a __complex__() method.
 
-- Patch #1642547: Fix an error/crash when encountering syntax errors
-  in complex if statements.
+- bpo-1623563: allow __class__ assignment for classes with __slots__.  The
+  old and the new class are still required to have the same slot names.
 
-- Patch #1462488: Python no longer segfaults when
-  ``object.__reduce_ex__()`` is called with an object that is faking
-  its type.
+- bpo-1642547: Fix an error/crash when encountering syntax errors in complex
+  if statements.
 
-- Patch #1680015: Don't modify __slots__ tuple if it contains a
-  unicode name.
+- bpo-1462488: Python no longer segfaults when ``object.__reduce_ex__()`` is
+  called with an object that is faking its type.
 
-- Patch #1444529: the builtin compile() now accepts keyword arguments.
+- bpo-1680015: Don't modify __slots__ tuple if it contains a unicode name.
 
-- Bug #1678647: write a newline after printing an exception in any
-  case, even when converting the value to a string failed.
+- bpo-1444529: the builtin compile() now accepts keyword arguments.
 
-- The dir() function has been extended to call the __dir__() method on
-  its argument, if it exists. If not, it will work like before. This
-  allows customizing the output of dir() in the presence of a
-  __getattr__().
+- bpo-1678647: write a newline after printing an exception in any case, even
+  when converting the value to a string failed.
 
-- Patch #922167: Python no longer segfaults when faced with infinitely
-  self-recursive reload() calls (as reported by bug #742342).
+- The dir() function has been extended to call the __dir__() method on its
+  argument, if it exists. If not, it will work like before. This allows
+  customizing the output of dir() in the presence of a __getattr__().
 
-- Patch #1675981: remove unreachable code from ``type.__new__()``
-  method.
+- bpo-922167: Python no longer segfaults when faced with infinitely self-
+  recursive reload() calls (as reported by bug #742342).
+
+- bpo-1675981: remove unreachable code from ``type.__new__()`` method.
 
-- Patch #1491866: change the complex() constructor to allow
-  parthensized forms. This means complex(repr(x)) now works instead of
-  raising a ValueError.
+- bpo-1491866: change the complex() constructor to allow parthensized forms.
+  This means complex(repr(x)) now works instead of raising a ValueError.
 
-- Patch #703779: unset __file__ in __main__ after running a file. This
-  makes the filenames the warning module prints much more sensible
-  when a PYTHONSTARTUP file is used.
+- bpo-703779: unset __file__ in __main__ after running a file. This makes
+  the filenames the warning module prints much more sensible when a
+  PYTHONSTARTUP file is used.
 
-- Variant of patch #697613: don't exit the interpreter on a SystemExit
-  exception if the -i command line option or PYTHONINSPECT environment
-  variable is given, but break into the interactive interpreter just
-  like on other exceptions or normal program exit.
+- bpo-697613: Don't exit the interpreter on a SystemExit exception if the -i
+  command line option or PYTHONINSPECT environment variable is given, but
+  break into the interactive interpreter just like on other exceptions or
+  normal program exit.
 
-- Patch #1638879: don't accept strings with embedded NUL bytes in
-  long().
+- bpo-1638879: don't accept strings with embedded NUL bytes in long().
 
-- Bug #1674503: close the file opened by execfile() in an error
-  condition.
+- bpo-1674503: close the file opened by execfile() in an error condition.
 
-- Patch #1674228: when assigning a slice (old-style), check for the
+- bpo-1674228: when assigning a slice (old-style), check for the
   sq_ass_slice instead of the sq_slice slot.
 
-- When printing an unraisable error, don't print exceptions. before
-  the name.  This duplicates the behavior whening normally printing
-  exceptions.
+- When printing an unraisable error, don't print exceptions. before the
+  name. This duplicates the behavior whening normally printing exceptions.
 
-- Bug #1653736: Properly discard third argument to
-  slot_nb_inplace_power.
+- bpo-1653736: Properly discard third argument to slot_nb_inplace_power.
 
-- PEP 352: Raising a string exception now triggers a TypeError.
-  Attempting to catch a string exception raises DeprecationWarning.
+- PEP 352: Raising a string exception now triggers a TypeError. Attempting
+  to catch a string exception raises DeprecationWarning.
 
-- Bug #1377858: Fix the segfaulting of the interpreter when an object
-  created a weakref on itself during a __del__ call for new-style
-  classes (classic classes still have the bug).
+- bpo-1377858: Fix the segfaulting of the interpreter when an object created
+  a weakref on itself during a __del__ call for new-style classes (classic
+  classes still have the bug).
 
-- Bug #1579370: Make PyTraceBack_Here use the current thread, not the
-  frame's thread state.
+- bpo-1579370: Make PyTraceBack_Here use the current thread, not the frame's
+  thread state.
 
-- patch #1630975: Fix crash when replacing sys.stdout in
-  sitecustomize.py.
+- bpo-1630975: Fix crash when replacing sys.stdout in sitecustomize.py.
 
-- Prevent seg fault on shutdown which could occur if an object raised
-  warning.
+- Prevent seg fault on shutdown which could occur if an object raised a
+  warning.
 
-- Bug #1566280: Explicitly invoke threading._shutdown from Py_Main, to
-  avoid relying on atexit.
+- bpo-1566280: Explicitly invoke threading._shutdown from Py_Main, to avoid
+  relying on atexit.
 
-- Bug #1590891: random.randrange don't return correct value for big
-  number.
+- bpo-1590891: random.randrange don't return correct value for big number.
 
-- Patch #1586791: Better exception messages for some operations on
-  strings, tuples and lists.
+- bpo-1586791: Better exception messages for some operations on strings,
+  tuples and lists.
 
-- Bug #1067760: Deprecate passing floats to file.seek.
+- bpo-1067760: Deprecate passing floats to file.seek.
 
-- Bug #1591996: Correctly forward exception in instance_contains().
+- bpo-1591996: Correctly forward exception in instance_contains().
 
-- Bug #1588287: fix invalid assertion for `1,2` in debug builds.
+- bpo-1588287: fix invalid assertion for `1,2` in debug builds.
 
-- Bug #1576657: when setting a KeyError for a tuple key, make sure
-  that the tuple isn't used as the "exception arguments tuple".
+- bpo-1576657: when setting a KeyError for a tuple key, make sure that the
+  tuple isn't used as the "exception arguments tuple".
 
-- Bug #1565514: SystemError not raised on too many nested blocks.
+- bpo-1565514: SystemError not raised on too many nested blocks.
 
-- Bug #1576174: WindowsError now displays the windows error code
-  again, no longer the posix error code.
+- bpo-1576174: WindowsError now displays the windows error code again, no
+  longer the posix error code.
 
-- Patch #1549049: Support long values in structmember, issue warnings
-  if the assigned value for structmember fields gets truncated.
+- bpo-1549049: Support long values in structmember, issue warnings if the
+  assigned value for structmember fields gets truncated.
 
 - Update the peephole optimizer to remove more dead code (jumps after
   returns) and inline unconditional jumps to returns.
 
-- Bug #1545497: when given an explicit base, int() did ignore NULs
-  embedded in the string to convert.
+- bpo-1545497: when given an explicit base, int() did ignore NULs embedded
+  in the string to convert.
 
-- Bug #1569998: break inside a try statement (outside a loop) is now
+- bpo-1569998: break inside a try statement (outside a loop) is now
   recognized and rejected.
 
 - list.pop(x) accepts any object x following the __index__ protocol.
 
-- A number of places, including integer negation and absolute value,
-  were fixed to not rely on undefined behaviour of the C compiler
-  anymore.
+- A number of places, including integer negation and absolute value, were
+  fixed to not rely on undefined behaviour of the C compiler anymore.
 
-- Bug #1566800: make sure that EnvironmentError can be called with any
-  number of arguments, as was the case in Python 2.4.
+- bpo-1566800: make sure that EnvironmentError can be called with any number
+  of arguments, as was the case in Python 2.4.
 
-- Patch #1567691: super() and new.instancemethod() now don't accept
-  keyword arguments any more (previously they accepted them, but
-  didn't use them).
+- bpo-1567691: super() and new.instancemethod() now don't accept keyword
+  arguments any more (previously they accepted them, but didn't use them).
 
-- Fix a bug in the parser's future statement handling that led to
-  "with" not being recognized as a keyword after, e.g., this
-  statement: from __future__ import division, with_statement
+- Fix a bug in the parser's future statement handling that led to "with" not
+  being recognized as a keyword after, e.g., this statement: from __future__
+  import division, with_statement
 
-- Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)).
+- bpo-1557232: fix seg fault with def f((((x)))) and def f(((x),)).
 
 - Fix %zd string formatting on Mac OS X so it prints negative numbers.
 
 - Allow exception instances to be directly sliced again.
 
-- Bug #1551432: Exceptions do not define an explicit __unicode__
-  method.  This allows calling unicode() on exceptions classes
-  directly to succeed.
+- bpo-1551432: Exceptions do not define an explicit __unicode__ method.
+  This allows calling unicode() on exceptions classes directly to succeed.
 
-- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack.
-  Also make sure that every exception class has __module__ set to
-  'exceptions'.
+- bpo-1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make
+  sure that every exception class has __module__ set to 'exceptions'.
 
-- Bug #1550983: emit better error messages for erroneous relative
-  imports (if not in package and if beyond toplevel package).
+- bpo-1550983: emit better error messages for erroneous relative imports (if
+  not in package and if beyond toplevel package).
 
 - Overflow checking code in integer division ran afoul of new gcc
   optimizations.  Changed to be more standard-conforming.
 
-- Patch #1542451: disallow continue anywhere under a finally.
+- bpo-1542451: disallow continue anywhere under a finally.
 
-- Patch #1546288: fix seg fault in dict_equal due to ref counting bug.
+- bpo-1546288: fix seg fault in dict_equal due to ref counting bug.
 
-- The return tuple from str.rpartition(sep) is (tail, sep, head) where
-  head is the original string if sep was not found.
+- The return tuple from str.rpartition(sep) is (tail, sep, head) where head
+  is the original string if sep was not found.
 
-- Bug #1520864: unpacking singleton tuples in list comprehensions and
-  generator expressions (x for x, in ... ) works again.  Fixing this
-  problem required changing the .pyc magic number.  This means that
-  .pyc files generated before 2.5c2 will be regenerated.
+- bpo-1520864: unpacking singleton tuples in list comprehensions and
+  generator expressions (x for x, in ... ) works again.  Fixing this problem
+  required changing the .pyc magic number.  This means that .pyc files
+  generated before 2.5c2 will be regenerated.
 
 - ``with`` and ``as`` are now keywords.
 
-- Bug #1664966: Fix crash in exec if Unicode filename can't be
-  decoded.
+- bpo-1664966: Fix crash in exec if Unicode filename can't be decoded.
 
-- Issue #1537: Changed GeneratorExit's base class from Exception to
+- bpo-1537: Changed GeneratorExit's base class from Exception to
   BaseException.
 
-- Issue #1703448: A joined thread could show up in the
-  threading.enumerate() list after the join() for a brief period until
-  it actually exited.
+- bpo-1703448: A joined thread could show up in the threading.enumerate()
+  list after the join() for a brief period until it actually exited.
 
 Library
 -------
 
-- Patch #2274: Add heapq.heappushpop().
+- bpo-2274: Add heapq.heappushpop().
 
 - Add inspect.isabstract(object) to fix bug #2223
 
 - Add a __format__ method to Decimal, to support PEP 3101.
 
-- Add a timing parameter when using trace.Trace to print out
-  timestamps.
+- Add a timing parameter when using trace.Trace to print out timestamps.
 
-- Issue #1627: httplib now ignores negative Content-Length headers.
+- bpo-1627: httplib now ignores negative Content-Length headers.
 
-- Issue #900744: If an invalid chunked-encoding header is sent by a
-  server, httplib will now raise IncompleteRead and close the
-  connection instead of raising ValueError.
+- bpo-900744: If an invalid chunked-encoding header is sent by a server,
+  httplib will now raise IncompleteRead and close the connection instead of
+  raising ValueError.
 
-- Issue #1492: The content type of BaseHTTPServer error messages can
-  now be overridden.
+- bpo-1492: The content type of BaseHTTPServer error messages can now be
+  overridden.
 
-- Issue #1781: ConfigParser now does not let you add the "default" section
+- bpo-1781: ConfigParser now does not let you add the "default" section
   (ignore-case)
 
-- Removed uses of dict.has_key() from distutils, and uses of
-  callable() from copy_reg.py, so the interpreter now starts up
-  without warnings when '-3' is given.  More work like this needs to
-  be done in the rest of the stdlib.
+- Removed uses of dict.has_key() from distutils, and uses of callable() from
+  copy_reg.py, so the interpreter now starts up without warnings when '-3'
+  is given.  More work like this needs to be done in the rest of the stdlib.
 
-- Issue #1916: added isgenerator() and isgeneratorfunction() to
-  inspect.py.
+- bpo-1916: added isgenerator() and isgeneratorfunction() to inspect.py.
 
-- Issue #1224: Fixed bad url parsing when path begins with double
-  slash.
+- bpo-1224: Fixed bad url parsing when path begins with double slash.
 
 - ctypes instances that are not or do not contain pointers can now be
   pickled.
 
-- Patch #1966: Break infinite loop in httplib when the servers
-  implements the chunked encoding incorrectly.
+- bpo-1966: Break infinite loop in httplib when the servers implements the
+  chunked encoding incorrectly.
 
-- Rename rational.py to fractions.py and the rational.Rational class
-  to fractions.Fraction, to avoid the name clash with the abstract
-  base class numbers.Rational.  See discussion in issue #1682.
+- Rename rational.py to fractions.py and the rational.Rational class to
+  fractions.Fraction, to avoid the name clash with the abstract base class
+  numbers.Rational.  See discussion in issue #1682.
 
-- The pickletools module now provides an optimize() function that
-  eliminates unused PUT opcodes from a pickle string.
+- The pickletools module now provides an optimize() function that eliminates
+  unused PUT opcodes from a pickle string.
 
-- Patch #2021: Allow tempfile.NamedTemporaryFile and
-  SpooledTemporaryFile to be used in with statements by correctly
-  supporting the context management protocol.
+- bpo-2021: Allow tempfile.NamedTemporaryFile and SpooledTemporaryFile to be
+  used in with statements by correctly supporting the context management
+  protocol.
 
-- Patch #1979: Add rich comparisons to Decimal, and make Decimal
-  comparisons involving a NaN follow the IEEE 754 standard.
+- bpo-1979: Add rich comparisons to Decimal, and make Decimal comparisons
+  involving a NaN follow the IEEE 754 standard.
 
-- Issue #2004: tarfile.py: Use mode 0700 for temporary directories and
-  default permissions for missing directories.
+- bpo-2004: tarfile.py: Use mode 0700 for temporary directories and default
+  permissions for missing directories.
 
-- Issue #175006: The debugger used to skip the condition of a "while"
-  statement after the first iteration. Now it correctly steps on the
-  expression, and breakpoints on the "while" statement are honored on
-  each loop.
+- bpo-175006: The debugger used to skip the condition of a "while" statement
+  after the first iteration. Now it correctly steps on the expression, and
+  breakpoints on the "while" statement are honored on each loop.
 
-- Issue #1765140: add an optional delay argument to FileHandler and
-  its subclasses. Defaults to false (existing behaviour), but if true,
-  defers opening the file until the first call to emit().
+- bpo-1765140: add an optional delay argument to FileHandler and its
+  subclasses. Defaults to false (existing behaviour), but if true, defers
+  opening the file until the first call to emit().
 
 - The pprint module now supports sets and frozensets.
 
-- Issue #1221598: add optional callbacks to ftplib.FTP's storbinary()
-  and storlines() methods.  (Contributed by Phil Schwartz)
+- bpo-1221598: add optional callbacks to ftplib.FTP's storbinary() and
+  storlines() methods. (Contributed by Phil Schwartz)
 
-- Issue #1715: include sub-extension modules in pydoc's text output.
+- bpo-1715: include sub-extension modules in pydoc's text output.
 
-- Issue #1836: fix an off-by-one bug in TimedRotatingHandler's
-  rollover time calculation.
+- bpo-1836: fix an off-by-one bug in TimedRotatingHandler's rollover time
+  calculation.
 
-- Issue #1021: fix a bug to allow basicConfig to accept NOTSET as a
-  level.
+- bpo-1021: fix a bug to allow basicConfig to accept NOTSET as a level.
 
-- Issue #932563: add LoggerAdapter convenience class to make it easier
-  to add contextual information in logging output.
+- bpo-932563: add LoggerAdapter convenience class to make it easier to add
+  contextual information in logging output.
 
-- Issue #1760556: fix a bug to avoid FileHandler throwing an exception
-  in flush().
+- bpo-1760556: fix a bug to avoid FileHandler throwing an exception in
+  flush().
 
-- Bug #1530959: distutils' build command now uses different build
-  directory when building extension modules against versions of Python
-  compiled with ``--with-pydebug``.
+- bpo-1530959: distutils' build command now uses different build directory
+  when building extension modules against versions of Python compiled with
+  ``--with- pydebug``.
 
-- Issue #1555501: move plistlib from plat-mac directory to general
-  library.
+- bpo-1555501: move plistlib from plat-mac directory to general library.
 
-- Issue #1269: fix a bug in pstats.add_callers() and add a unit test
-  file for pstats.
+- bpo-1269: fix a bug in pstats.add_callers() and add a unit test file for
+  pstats.
 
-- Issue #1669: don't allow shutil.rmtree() to be called on a symlink
-  to a directory.
+- bpo-1669: don't allow shutil.rmtree() to be called on a symlink to a
+  directory.
 
-- Issue #1664522: in urllib, don't read non-existing directories in
-  ftp mode, returning a 0-byte file -- raise an IOError instead.
+- bpo-1664522: in urllib, don't read non-existing directories in ftp mode,
+  returning a 0-byte file -- raise an IOError instead.
 
-- Issue #856047: respect the ``no_proxy`` environment variable when
-  using the ``http_proxy`` etc. environment variables in urllib.
+- bpo-856047: respect the ``no_proxy`` environment variable when using the
+  ``http_proxy`` etc. environment variables in urllib.
 
-- Issue #1178141: add a getcode() method to the addinfourls that
-  urllib.open() returns so that you can retrieve the HTTP status code.
+- bpo-1178141: add a getcode() method to the addinfourls that urllib.open()
+  returns so that you can retrieve the HTTP status code.
 
-- Issue #1003: Fix zipfile decryption check, it would fail zip files
-  with extended local headers.
+- bpo-1003: Fix zipfile decryption check, it would fail zip files with
+  extended local headers.
 
-- Issue #1189216: Fix the zipfile module to work on archives with
-  headers past the 2**31 byte boundary.
+- bpo-1189216: Fix the zipfile module to work on archives with headers past
+  the 2**31 byte boundary.
 
-- Issue #1336: fix a race condition in subprocess.Popen if the garbage
-  collector kicked in at the wrong time that would cause the process
-  to hang when the child wrote to stderr.
+- bpo-1336: fix a race condition in subprocess.Popen if the garbage
+  collector kicked in at the wrong time that would cause the process to hang
+  when the child wrote to stderr.
 
-- Issue #1146: fix how textwrap breaks a long word that would start in
-  the last column of a line.
+- bpo-1146: fix how textwrap breaks a long word that would start in the last
+  column of a line.
 
-- Issue #1693149: trace.py --ignore-module - accept multiple
-  comma-separated modules to be given.
+- bpo-1693149: trace.py --ignore-module - accept multiple comma-separated
+  modules to be given.
 
-- Issue #1822: MIMEMultipart.is_multipart() behaves correctly for a
-  just-created (and empty) instance. Thanks Jonathan Share.
+- bpo-1822: MIMEMultipart.is_multipart() behaves correctly for a just-
+  created (and empty) instance. Thanks Jonathan Share.
 
-- Issue #1861: Added an attribute to the sched module which returns an
-  ordered list of upcoming events (displayed as named tuples).
+- bpo-1861: Added an attribute to the sched module which returns an ordered
+  list of upcoming events (displayed as named tuples).
 
-- Issue #1837: The queue module now also supports a LIFO queue and a
-  priority queue.
+- bpo-1837: The queue module now also supports a LIFO queue and a priority
+  queue.
 
-- Patch #1048820: Add insert-mode editing to curses.textpad.Textbox
-  (patch by Stefan Wehr).  Also, fix an off-by-one bug in
-  Textbox.gather().
+- bpo-1048820: Add insert-mode editing to curses.textpad.Textbox (patch by
+  Stefan Wehr). Also, fix an off-by-one bug in Textbox.gather().
 
-- Issue #1831: ctypes now raises a TypeError if conflicting positional
-  and named arguments are passed to a Structure or Union initializer.
-  When too many positional arguments are passed, also a TypeError is
-  raised instead of a ValueError.
+- bpo-1831: ctypes now raises a TypeError if conflicting positional and
+  named arguments are passed to a Structure or Union initializer. When too
+  many positional arguments are passed, also a TypeError is raised instead
+  of a ValueError.
 
-- Convert the internal ctypes array type cache to a WeakValueDict so
-  that array types do not live longer than needed.
+- Convert the internal ctypes array type cache to a WeakValueDict so that
+  array types do not live longer than needed.
 
-- Issue #1786: pdb should use its own stdin/stdout around an exec call
-  and when creating a recursive instance.
+- bpo-1786: pdb should use its own stdin/stdout around an exec call and when
+  creating a recursive instance.
 
-- Issue #1698398: ZipFile.printdir() crashed because the format string
-  expected a tuple type of length six instead of time.struct_time
-  object.
+- bpo-1698398: ZipFile.printdir() crashed because the format string expected
+  a tuple type of length six instead of time.struct_time object.
 
-- Issue #1780: The Decimal constructor now accepts arbitrary leading
-  and trailing whitespace when constructing from a string.
+- bpo-1780: The Decimal constructor now accepts arbitrary leading and
+  trailing whitespace when constructing from a string.
   Context.create_decimal no longer accepts trailing newlines.
 
-- Decimal.as_tuple(), difflib.find_longest_match() and inspect
-  functions that returned a tuple now return a named tuple.
+- Decimal.as_tuple(), difflib.find_longest_match() and inspect functions
+  that returned a tuple now return a named tuple.
 
-- Doctest now returns results as a named tuple for readability:
-      (0, 7) --> TestResults(failed=0, attempted=7)
+- Doctest now returns results as a named tuple for readability:     (0, 7)
+  --> TestResults(failed=0, attempted=7)
 
-- Issue #846388: re.match is interruptible now, which is particularly
-  good for long regular expression matches.
+- bpo-846388: re.match is interruptible now, which is particularly good for
+  long regular expression matches.
 
-- Patch #1137: allow setting buffer_size attribute on pyexpat Parser
-  objects to set the character data buffer size.
+- bpo-1137: allow setting buffer_size attribute on pyexpat Parser objects to
+  set the character data buffer size.
 
-- Issue #1757: The hash of a Decimal instance is no longer affected by
-  the current context.
+- bpo-1757: The hash of a Decimal instance is no longer affected by the
+  current context.
 
-- Patch #467924: add ZipFile.extract() and ZipFile.extractall() in the
-  zipfile module.
+- bpo-467924: add ZipFile.extract() and ZipFile.extractall() in the zipfile
+  module.
 
-- Issue #1646: Make socket support the TIPC protocol.
+- bpo-1646: Make socket support the TIPC protocol.
 
-- Bug #1742: return os.curdir from os.path.relpath() if both arguments
-  are equal instead of raising an exception.
+- bpo-1742: return os.curdir from os.path.relpath() if both arguments are
+  equal instead of raising an exception.
 
-- Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
+- bpo-1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
 
-- Patch #1698: allow '@' in username parsed by urlparse.py.
+- bpo-1698: allow '@' in username parsed by urlparse.py.
 
-- Issue #1735: TarFile.extractall() now correctly sets directory
-  permissions and times.
+- bpo-1735: TarFile.extractall() now correctly sets directory permissions
+  and times.
 
-- Bug #1713: posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
+- bpo-1713: posixpath.ismount() claims symlink to a mountpoint is a
+  mountpoint.
 
-- Bug #1687: Fxed plistlib.py restricts <integer> to Python int when
-  writing
+- bpo-1687: Fxed plistlib.py restricts <integer> to Python int when writing
 
-- Issue #1700: Regular expression inline flags incorrectly handle
-  certain unicode characters.
+- bpo-1700: Regular expression inline flags incorrectly handle certain
+  unicode characters.
 
-- Issue #1689: PEP 3141, numeric abstract base classes.
+- bpo-1689: PEP 3141, numeric abstract base classes.
 
-- Tk issue #1851526: Return results from Python callbacks to Tcl as
-  Tcl objects.
+- Tk issue #1851526: Return results from Python callbacks to Tcl as Tcl
+  objects.
 
-- Issue #1642: Fix segfault in ctypes when trying to delete attributes.
+- bpo-1642: Fix segfault in ctypes when trying to delete attributes.
 
-- Issue #1727780: Support loading pickles of random.Random objects
-  created on 32-bit systems on 64-bit systems, and vice versa. As a
-  consequence of the change, Random pickles created by Python 2.6
-  cannot be loaded in Python 2.5.
+- bpo-1727780: Support loading pickles of random.Random objects created on
+  32-bit systems on 64-bit systems, and vice versa. As a consequence of the
+  change, Random pickles created by Python 2.6 cannot be loaded in Python
+  2.5.
 
-- Issue #1455: The distutils package now supports VS 2005 and VS 2008
-  for both the msvccompiler and cygwincompiler.
+- bpo-1455: The distutils package now supports VS 2005 and VS 2008 for both
+  the msvccompiler and cygwincompiler.
 
-- Issue #1531: tarfile.py: Read fileobj from the current offset, do
-  not seek to the start.
+- bpo-1531: tarfile.py: Read fileobj from the current offset, do not seek to
+  the start.
 
-- Issue #1534: Added a dictionary sys.float_info with information
-  about the internal floating point type to the sys module.
+- bpo-1534: Added a dictionary sys.float_info with information about the
+  internal floating point type to the sys module.
 
-- Issue #1429818: patch for trace and doctest modules so they play
-  nicely together.
+- bpo-1429818: patch for trace and doctest modules so they play nicely
+  together.
 
 - doctest made a bad assumption that a package's __loader__.get_data()
   method used universal newlines.
 
-- Issue #1705170: contextlib.contextmanager was still swallowing
-  StopIteration in some cases. This should no longer happen.
+- bpo-1705170: contextlib.contextmanager was still swallowing StopIteration
+  in some cases. This should no longer happen.
 
-- Issue #1292: On alpha, arm, ppc, and s390 linux systems the
-  --with-system-ffi configure option defaults to "yes".
+- bpo-1292: On alpha, arm, ppc, and s390 linux systems the --with-system-ffi
+  configure option defaults to "yes".
 
-- IN module for FreeBSD 8 is added and preexisting FreeBSD 6 and 7
-  files are updated.
+- IN module for FreeBSD 8 is added and preexisting FreeBSD 6 and 7 files are
+  updated.
 
-- Issues #1181, #1287: unsetenv() is now called when the
-  os.environ.pop() and os.environ.clear() methods are used.
+- bpo-1181: unsetenv() is now called when the os.environ.pop() and
+  os.environ.clear() methods are used. (See also: bpo-1287)
 
-- ctypes will now work correctly on 32-bit systems when Python is
-  configured with --with-system-ffi.
+- ctypes will now work correctly on 32-bit systems when Python is configured
+  with --with-system-ffi.
 
-- Patch #1203: ctypes now does work on OS X when Python is built with
-  --disable-toolbox-glue.
+- bpo-1203: ctypes now does work on OS X when Python is built with
+  --disable-toolbox- glue.
 
 - collections.deque() now supports a "maxlen" argument.
 
-- itertools.count() is no longer bounded to LONG_MAX.  Formerly, it
-  raised an OverflowError.  Now, automatically shifts from ints to
-  longs.
+- itertools.count() is no longer bounded to LONG_MAX.  Formerly, it raised
+  an OverflowError.  Now, automatically shifts from ints to longs.
 
-- Added itertools.product() which forms the Cartesian product of the
-  input iterables.
+- Added itertools.product() which forms the Cartesian product of the input
+  iterables.
 
 - Added itertools.combinations() and itertools.permutations().
 
-- Patch #1541463: optimize performance of cgi.FieldStorage operations.
+- bpo-1541463: optimize performance of cgi.FieldStorage operations.
 
-- Decimal is fully updated to the latest Decimal Specification
-  (v1.66).
+- Decimal is fully updated to the latest Decimal Specification (v1.66).
 
-- Bug #1153: repr.repr() now doesn't require set and dictionary items
-  to be orderable to properly represent them.
+- bpo-1153: repr.repr() now doesn't require set and dictionary items to be
+  orderable to properly represent them.
 
 - A 'c_longdouble' type was added to the ctypes module.
 
-- Bug #1709599: Run test_1565150 only if the file system is NTFS.
+- bpo-1709599: Run test_1565150 only if the file system is NTFS.
 
-- When encountering a password-protected robots.txt file the
-  RobotFileParser no longer prompts interactively for a username and
-  password (bug 813986).
+- When encountering a password-protected robots.txt file the RobotFileParser
+  no longer prompts interactively for a username and password (bug 813986).
 
-- TarFile.__init__() no longer fails if no name argument is passed and
-  the fileobj argument has no usable name attribute (e.g. StringIO).
+- TarFile.__init__() no longer fails if no name argument is passed and the
+  fileobj argument has no usable name attribute (e.g. StringIO).
 
-- The functools module now provides 'reduce', for forward
-  compatibility with Python 3000.
+- The functools module now provides 'reduce', for forward compatibility with
+  Python 3000.
 
-- Server-side SSL support and cert verification added, by Bill
-  Janssen.
+- Server-side SSL support and cert verification added, by Bill Janssen.
 
 - socket.ssl deprecated; use new ssl module instead.
 
@@ -11453,47 +11802,44 @@ Library
 
 - Add new codecs for UTF-32, UTF-32-LE and UTF-32-BE.
 
-- Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
-  represent the result in a single character.
+- bpo-1704793: Return UTF-16 pair if unicodedata.lookup cannot represent the
+  result in a single character.
 
-- Bug #978833: Close https sockets by releasing the _ssl object.
+- bpo-978833: Close https sockets by releasing the _ssl object.
 
 - Change location of the package index to pypi.python.org/pypi
 
-- Bug #1701409: Fix a segfault in printing ctypes.c_char_p and
-  ctypes.c_wchar_p when they point to an invalid location.  As a
-  sideeffect the representation of these instances has changed.
+- bpo-1701409: Fix a segfault in printing ctypes.c_char_p and
+  ctypes.c_wchar_p when they point to an invalid location.  As a sideeffect
+  the representation of these instances has changed.
 
 - tarfile.py: Added "exclude" keyword argument to TarFile.add().
 
-- Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple
-  attribute.
+- bpo-1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute.
 
-- The urlopen function of urllib2 now has an optional timeout
-  parameter (note that it actually works with HTTP, HTTPS, FTP and
-  FTPS connections).
+- The urlopen function of urllib2 now has an optional timeout parameter
+  (note that it actually works with HTTP, HTTPS, FTP and FTPS connections).
 
-- In ftplib, the FTP.ntransfercmd method, when in passive mode, now
-  uses the socket.create_connection function, using the timeout
-  specified at connection time.
+- In ftplib, the FTP.ntransfercmd method, when in passive mode, now uses the
+  socket.create_connection function, using the timeout specified at
+  connection time.
 
-- Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it
-  reads a file that ends with incomplete sequence and sizehint
-  argument for .read() is specified.
+- bpo-1728403: Fix a bug that CJKCodecs StreamReader hangs when it reads a
+  file that ends with incomplete sequence and sizehint argument for .read()
+  is specified.
 
-- Bug #1730389: Change time.strptime() to use ``\s+`` instead of
-  ``\s*`` when matching spaces in the specified format argument.
+- bpo-1730389: Change time.strptime() to use ``\s+`` instead of ``\s*`` when
+  matching spaces in the specified format argument.
 
-- Bugs #1668596/#1720897: distutils now copies data files even if
-  package_dir is empty.
+- bpo-1668596: distutils now copies data files even if package_dir is empty.
+  (See also: bpo-1720897)
 
 - sha now raises a DeprecationWarning upon import.
 
 - md5 now raises a DeprecationWarning upon import.
 
-- Issue #1385: The hmac module now computes the correct hmac when
-  using hashes with a block size other than 64 bytes (such as sha384
-  and sha512).
+- bpo-1385: The hmac module now computes the correct hmac when using hashes
+  with a block size other than 64 bytes (such as sha384 and sha512).
 
 - mimify now raises a DeprecationWarning upon import.
 
@@ -11508,197 +11854,186 @@ Library
 
 - The posixfile module now raises a DeprecationWarning.
 
-- Remove the gopherlib module.  This also leads to the removal of
-  gopher support in urllib/urllib2.
+- Remove the gopherlib module.  This also leads to the removal of gopher
+  support in urllib/urllib2.
 
-- Fix bug in marshal where bad data would cause a segfault due to lack
-  of an infinite recursion check.
+- Fix bug in marshal where bad data would cause a segfault due to lack of an
+  infinite recursion check.
 
-- Removed plat-freebsd2 and plat-freebsd3 directories (and IN.py in
-  the directories).
+- Removed plat-freebsd2 and plat-freebsd3 directories (and IN.py in the
+  directories).
 
-- HTML-escape the plain traceback in cgitb's HTML output, to prevent
-  the traceback inadvertently or maliciously closing the comment and
-  injecting HTML into the error page.
+- HTML-escape the plain traceback in cgitb's HTML output, to prevent the
+  traceback inadvertently or maliciously closing the comment and injecting
+  HTML into the error page.
 
 - The popen2 module and os.popen* are deprecated.  Use the subprocess
   module.
 
-- Added an optional credentials argument to SMTPHandler, for use with
-  SMTP servers which require authentication.
+- Added an optional credentials argument to SMTPHandler, for use with SMTP
+  servers which require authentication.
 
-- Patch #1695948: Added optional timeout parameter to SocketHandler.
+- bpo-1695948: Added optional timeout parameter to SocketHandler.
 
-- Bug #1652788: Minor fix for currentframe.
+- bpo-1652788: Minor fix for currentframe.
 
-- Patch #1598415: Added WatchedFileHandler to better support external
-  log file rotation using e.g. newsyslog or logrotate. This handler is
-  only useful in Unix/Linux environments.
+- bpo-1598415: Added WatchedFileHandler to better support external log file
+  rotation using e.g. newsyslog or logrotate. This handler is only useful in
+  Unix/Linux environments.
 
-- Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
-  (as opposed to the command line) will now write file names ending in
-  ".cpp" too.
+- bpo-1706381: Specifying the SWIG option "-c++" in the setup.py file (as
+  opposed to the command line) will now write file names ending in ".cpp"
+  too.
 
-- As specified in RFC 2616, an HTTP response like 2xx indicates that
-  the client's request was successfully received, understood, and
-  accepted.  Now in these cases no error is raised in urllib (issue
-  #1177) and urllib2.
+- As specified in RFC 2616, an HTTP response like 2xx indicates that the
+  client's request was successfully received, understood, and accepted.  Now
+  in these cases no error is raised in urllib (issue #1177) and urllib2.
 
-- Bug #1290505: time.strptime's internal cache of locale information
-  is now properly recreated when the locale is changed.
+- bpo-1290505: time.strptime's internal cache of locale information is now
+  properly recreated when the locale is changed.
 
-- Patch #1685563: remove (don't add) duplicate paths in
-  distutils.MSVCCompiler.
+- bpo-1685563: remove (don't add) duplicate paths in distutils.MSVCCompiler.
 
 - Added a timeout parameter to the constructor of other protocols
-  (telnetlib, ftplib, smtplib and poplib). This is second part of the
-  work started with create_connection() and timeout in httplib, and
-  closes patch #723312.
+  (telnetlib, ftplib, smtplib and poplib). This is second part of the work
+  started with create_connection() and timeout in httplib, and closes patch
+  #723312.
 
-- Patch #1676823: Added create_connection() to socket.py, which may be
-  called with a timeout, and use it from httplib (whose HTTPConnection
-  and HTTPSConnection now accept an optional timeout).
+- bpo-1676823: Added create_connection() to socket.py, which may be called
+  with a timeout, and use it from httplib (whose HTTPConnection and
+  HTTPSConnection now accept an optional timeout).
 
-- Bug #978833: Revert r50844, as it broke _socketobject.dup.
+- bpo-978833: Revert r50844, as it broke _socketobject.dup.
 
-- Bug #1675967: re patterns pickled with Python 2.4 and earlier can
-  now be unpickled with Python 2.5 and newer.
+- bpo-1675967: re patterns pickled with Python 2.4 and earlier can now be
+  unpickled with Python 2.5 and newer.
 
-- Patch #1630118: add a SpooledTemporaryFile class to tempfile.py.
+- bpo-1630118: add a SpooledTemporaryFile class to tempfile.py.
 
-- Patch #1273829: os.walk() now has a "followlinks" parameter. If set
-  to True (which is not the default), it visits symlinks pointing to
-  directories.
+- bpo-1273829: os.walk() now has a "followlinks" parameter. If set to True
+  (which is not the default), it visits symlinks pointing to directories.
 
-- Bug #1681228: the webbrowser module now correctly uses the default
-  GNOME or KDE browser, depending on whether there is a session of one
-  of those present. Also, it tries the Windows default browser before
-  trying Mozilla variants.
+- bpo-1681228: the webbrowser module now correctly uses the default GNOME or
+  KDE browser, depending on whether there is a session of one of those
+  present. Also, it tries the Windows default browser before trying Mozilla
+  variants.
 
-- Patch #1339796: add a relpath() function to os.path.
+- bpo-1339796: add a relpath() function to os.path.
 
-- Patch #1681153: the wave module now closes a file object it opened if
+- bpo-1681153: the wave module now closes a file object it opened if
   initialization failed.
 
-- Bug #767111: fix long-standing bug in urllib which caused an
-  AttributeError instead of an IOError when the server's response
-  didn't contain a valid HTTP status line.
+- bpo-767111: fix long-standing bug in urllib which caused an AttributeError
+  instead of an IOError when the server's response didn't contain a valid
+  HTTP status line.
 
-- Patch #957650: "%var%" environment variable references are now
-  properly expanded in ntpath.expandvars(), also "~user" home
-  directory references are recognized and handled on Windows.
+- bpo-957650: "%var%" environment variable references are now properly
+  expanded in ntpath.expandvars(), also "~user" home directory references
+  are recognized and handled on Windows.
 
-- Patch #1429539: pdb now correctly initializes the __main__ module
-  for the debugged script, which means that imports from __main__ work
-  correctly now.
+- bpo-1429539: pdb now correctly initializes the __main__ module for the
+  debugged script, which means that imports from __main__ work correctly
+  now.
 
 - The nonobvious commands.getstatus() function is now deprecated.
 
-- Patch #1393667: pdb now has a "run" command which restarts the
-  debugged Python program, optionally with different arguments.
+- bpo-1393667: pdb now has a "run" command which restarts the debugged
+  Python program, optionally with different arguments.
 
-- Patch #1649190: Adding support for _Bool to ctypes as c_bool.
+- bpo-1649190: Adding support for _Bool to ctypes as c_bool.
 
-- Patch #1530482: add pydoc.render_doc() which returns the
-  documentation for a thing instead of paging it to stdout, which
-  pydoc.doc() does.
+- bpo-1530482: add pydoc.render_doc() which returns the documentation for a
+  thing instead of paging it to stdout, which pydoc.doc() does.
 
-- Patch #1533909: the timeit module now accepts callables in addition
-  to strings for the code to time and the setup code. Also added two
-  convenience functions for instantiating a Timer and calling its
-  methods.
+- bpo-1533909: the timeit module now accepts callables in addition to
+  strings for the code to time and the setup code. Also added two
+  convenience functions for instantiating a Timer and calling its methods.
 
-- Patch #1537850: tempfile.NamedTemporaryFile now has a "delete"
-  parameter which can be set to False to prevent the default
-  delete-on-close behavior.
+- bpo-1537850: tempfile.NamedTemporaryFile now has a "delete" parameter
+  which can be set to False to prevent the default delete-on-close behavior.
 
-- Patch #1581073: add a flag to textwrap that prevents the dropping of
+- bpo-1581073: add a flag to textwrap that prevents the dropping of
   whitespace while wrapping.
 
-- Patch #1603688: ConfigParser.SafeConfigParser now checks values that
-  are set for invalid interpolation sequences that would lead to
-  errors on reading back those values.
+- bpo-1603688: ConfigParser.SafeConfigParser now checks values that are set
+  for invalid interpolation sequences that would lead to errors on reading
+  back those values.
 
-- Added support for the POSIX.1-2001 (pax) format to
-  tarfile.py. Extended and cleaned up the test suite. Added a new
-  testtar.tar.
+- Added support for the POSIX.1-2001 (pax) format to tarfile.py. Extended
+  and cleaned up the test suite. Added a new testtar.tar.
 
-- Patch #1449244: Support Unicode strings in
+- bpo-1449244: Support Unicode strings in
   email.message.Message.{set_charset,get_content_charset}.
 
-- Patch #1542681: add entries for "with", "as" and "CONTEXTMANAGERS"
-  to pydoc's help keywords.
+- bpo-1542681: add entries for "with", "as" and "CONTEXTMANAGERS" to pydoc's
+  help keywords.
 
-- Patch #1555098: use str.join() instead of repeated string
-  concatenation in robotparser.
+- bpo-1555098: use str.join() instead of repeated string concatenation in
+  robotparser.
 
-- Patch #1635454: the csv.DictWriter class now includes the offending
-  field names in its exception message if you try to write a record
-  with a dictionary containing fields not in the CSV field names list.
+- bpo-1635454: the csv.DictWriter class now includes the offending field
+  names in its exception message if you try to write a record with a
+  dictionary containing fields not in the CSV field names list.
 
-- Patch #1668100: urllib2 now correctly raises URLError instead of
-  OSError if accessing a local file via the file:// protocol fails.
+- bpo-1668100: urllib2 now correctly raises URLError instead of OSError if
+  accessing a local file via the file:// protocol fails.
 
-- Patch #1677862: Require a space or tab after import in .pth files.
+- bpo-1677862: Require a space or tab after import in .pth files.
 
-- Patch #1192590: Fix pdb's "ignore" and "condition" commands so they
-  trap the IndexError caused by passing in an invalid breakpoint
-  number.
+- bpo-1192590: Fix pdb's "ignore" and "condition" commands so they trap the
+  IndexError caused by passing in an invalid breakpoint number.
 
-- Patch #1599845: Add an option to disable the implicit calls to
-  server_bind() and server_activate() in the constructors for
-  TCPServer, SimpleXMLRPCServer and DocXMLRPCServer.
+- bpo-1599845: Add an option to disable the implicit calls to server_bind()
+  and server_activate() in the constructors for TCPServer,
+  SimpleXMLRPCServer and DocXMLRPCServer.
 
-- Bug #1531963: Make SocketServer.TCPServer's server_address always be
-  equal to calling getsockname() on the server's socket. Fixed by
-  patch #1545011.
+- bpo-1531963: Make SocketServer.TCPServer's server_address always be equal
+  to calling getsockname() on the server's socket. Fixed by patch #1545011.
 
-- Patch #742598: Add .timeout attribute to SocketServer that calls
+- bpo-742598: Add .timeout attribute to SocketServer that calls
   .handle_timeout() when no requests are received.
 
-- Bug #1651235: When a tuple was passed to a ctypes function call,
-  Python would crash instead of raising an error.
+- bpo-1651235: When a tuple was passed to a ctypes function call, Python
+  would crash instead of raising an error.
 
-- Bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
+- bpo-1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
   returned string up to the first NUL character.
 
-- Patch #957003: Implement smtplib.LMTP.
+- bpo-957003: Implement smtplib.LMTP.
 
-- Patch #1481079: add support for HTTP_REFERER to CGIHTTPServer.
+- bpo-1481079: add support for HTTP_REFERER to CGIHTTPServer.
 
-- Patch #1675424: Added tests for uncovered code in the zipfile
-  module.  The KeyError raised by Zipfile.getinfo for nonexistent
-  names now has a descriptive message.
+- bpo-1675424: Added tests for uncovered code in the zipfile module.  The
+  KeyError raised by Zipfile.getinfo for nonexistent names now has a
+  descriptive message.
 
-- Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', '').
+- bpo-1115886: os.path.splitext('.cshrc') gives now ('.cshrc', '').
 
-- unittest now verifies more of its assumptions. In particular,
-  TestCase and TestSuite subclasses (not instances) are no longer
-  accepted in TestSuite.addTest(). This should cause no
-  incompatibility since it never made sense with ordinary subclasses
-  -- the failure just occurred later, with a more cumbersome
-  exception.
+- unittest now verifies more of its assumptions. In particular, TestCase and
+  TestSuite subclasses (not instances) are no longer accepted in
+  TestSuite.addTest(). This should cause no incompatibility since it never
+  made sense with ordinary subclasses -- the failure just occurred later,
+  with a more cumbersome exception.
 
-- Patch #787789: allow passing custom TestRunner instances to
-  unittest's main() function.
+- bpo-787789: allow passing custom TestRunner instances to unittest's main()
+  function.
 
-- Patches #1550273, #1550272: fix a few bugs in unittest and add a
-  comprehensive test suite for the module.
+- bpo-1550273: fix a few bugs in unittest and add a comprehensive test suite
+  for the module. (See also: bpo-1550272)
 
-- Patch #1001604: glob.glob() now returns unicode filenames if it was
-  given a unicode argument and os.listdir() returns unicode filenames.
+- bpo-1001604: glob.glob() now returns unicode filenames if it was given a
+  unicode argument and os.listdir() returns unicode filenames.
 
-- Patch #1673619: setup.py identifies extension modules it doesn't
-  know how to build and those it knows how to build but that fail to
-  build.
+- bpo-1673619: setup.py identifies extension modules it doesn't know how to
+  build and those it knows how to build but that fail to build.
 
-- Patch #912410: Replace HTML entity references for attribute values
-  in HTMLParser.
+- bpo-912410: Replace HTML entity references for attribute values in
+  HTMLParser.
 
-- Patch #1663234: you can now run doctest on test files and modules
-  using "python -m doctest [-v] filename ...".
+- bpo-1663234: you can now run doctest on test files and modules using
+  "python -m doctest [-v] filename ...".
 
-- Patch #1121142: Implement ZipFile.open.
+- bpo-1121142: Implement ZipFile.open.
 
 - Taught setup.py how to locate Berkeley DB on Macs using MacPorts.
 
@@ -11711,331 +12046,307 @@ Library
 - Have the encoding package's search function dynamically import using
   absolute import semantics.
 
-- Patch #1647484: Renamed GzipFile's filename attribute to name.
+- bpo-1647484: Renamed GzipFile's filename attribute to name.
 
-- Patch #1517891: Mode 'a' for ZipFile now creates the file if it
-  doesn't exist.
+- bpo-1517891: Mode 'a' for ZipFile now creates the file if it doesn't
+  exist.
 
-- Patch #698833: Support file decryption in zipfile.
+- bpo-698833: Support file decryption in zipfile.
 
-- Patch #685268: Consider a package's __path__ in imputil.
+- bpo-685268: Consider a package's __path__ in imputil.
 
-- Patch #1463026: Support default namespace in XMLGenerator.
+- bpo-1463026: Support default namespace in XMLGenerator.
 
-- Patch #1571379: Make trace's --ignore-dir facility work in the face
-  of relative directory names.
+- bpo-1571379: Make trace's --ignore-dir facility work in the face of
+  relative directory names.
 
-- Bug #1600860: Search for shared python library in LIBDIR, not
+- bpo-1600860: Search for shared python library in LIBDIR, not
   lib/python/config, on "linux" and "gnu" systems.
 
-- Patch #1652681: tarfile.py: create nonexistent files in append mode
-  and allow appending to empty files.
+- bpo-1652681: tarfile.py: create nonexistent files in append mode and allow
+  appending to empty files.
 
-- Bug #1124861: Automatically create pipes if GetStdHandle fails in
+- bpo-1124861: Automatically create pipes if GetStdHandle fails in
   subprocess.
 
-- Patch #1634778: add missing encoding aliases for iso8859_15 and
-  iso8859_16.
+- bpo-1634778: add missing encoding aliases for iso8859_15 and iso8859_16.
 
-- Patch #1638243: the compiler package is now able to correctly
-  compile a with statement; previously, executing code containing a
-  with statement compiled by the compiler package crashed the
-  interpreter.
+- bpo-1638243: the compiler package is now able to correctly compile a with
+  statement; previously, executing code containing a with statement compiled
+  by the compiler package crashed the interpreter.
 
-- Bug #1643943: Fix time.strptime's support for the %U directive.
+- bpo-1643943: Fix time.strptime's support for the %U directive.
 
-- Patch #1507247: tarfile.py: use current umask for intermediate
-  directories.
+- bpo-1507247: tarfile.py: use current umask for intermediate directories.
 
-- Patch #1627441: close sockets properly in urllib2.
+- bpo-1627441: close sockets properly in urllib2.
 
-- Bug #494589: make ntpath.expandvars behave according to its
-  docstring.
+- bpo-494589: make ntpath.expandvars behave according to its docstring.
 
-- Changed platform module API python_version_tuple() to actually
-  return a tuple (it used to return a list).
+- Changed platform module API python_version_tuple() to actually return a
+  tuple (it used to return a list).
 
 - Added new platform module APIs python_branch(), python_revision(),
   python_implementation() and linux_distribution().
 
 - Added support for IronPython and Jython to the platform module.
 
-- The sets module has been deprecated.  Use the built-in set/frozenset
-  types instead.
+- The sets module has been deprecated.  Use the built-in set/frozenset types
+  instead.
 
-- Bug #1610795: make ctypes.util.find_library work on BSD systems.
+- bpo-1610795: make ctypes.util.find_library work on BSD systems.
 
-- Fixes for 64-bit Windows: In ctypes.wintypes, correct the
-  definitions of HANDLE, WPARAM, LPARAM data types.  Make
-  parameterless foreign function calls work.
+- Fixes for 64-bit Windows: In ctypes.wintypes, correct the definitions of
+  HANDLE, WPARAM, LPARAM data types.  Make parameterless foreign function
+  calls work.
 
 - The version number of the ctypes package changed to "1.1.0".
 
-- Bug #1627575: logging: Added _open() method to FileHandler which can
-  be used to reopen files. The FileHandler instance now saves the
-  encoding (which can be None) in an attribute called "encoding".
+- bpo-1627575: logging: Added _open() method to FileHandler which can be
+  used to reopen files. The FileHandler instance now saves the encoding
+  (which can be None) in an attribute called "encoding".
 
-- Bug #411881: logging.handlers: bare except clause removed from
+- bpo-411881: logging.handlers: bare except clause removed from
   SMTPHandler.emit. Now, only ImportError is trapped.
 
-- Bug #411881: logging.handlers: bare except clause removed from
+- bpo-411881: logging.handlers: bare except clause removed from
   SocketHandler.createSocket. Now, only socket.error is trapped.
 
-- Bug #411881: logging: bare except clause removed from
-  LogRecord.__init__.  Now, only ValueError, TypeError and
-  AttributeError are trapped.
+- bpo-411881: logging: bare except clause removed from LogRecord.__init__.
+  Now, only ValueError, TypeError and AttributeError are trapped.
 
-- Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj
-  argument.
+- bpo-1504073: Fix tarfile.open() for mode "r" with a fileobj argument.
 
-- Patch #1182394 from Shane Holloway: speed up HMAC.hexdigest.
+- bpo-1182394: Speed up ``HMAC.hexdigest``.  (Patch by Shane Holloway.)
 
-- Patch #1262036: Prevent TarFiles from being added to themselves
-  under certain conditions.
+- bpo-1262036: Prevent TarFiles from being added to themselves under certain
+  conditions.
 
-- Patch #1230446: tarfile.py: fix ExFileObject so that read() and
-  tell() work correctly together with readline().
+- bpo-1230446: tarfile.py: fix ExFileObject so that read() and tell() work
+  correctly together with readline().
 
-- Patch #1484695: The tarfile module now raises a HeaderError
-  exception if a buffer given to frombuf() is invalid.
+- bpo-1484695: The tarfile module now raises a HeaderError exception if a
+  buffer given to frombuf() is invalid.
 
-- Bug #1503765: Fix a problem in logging.config with spaces in comma-
+- bpo-1503765: Fix a problem in logging.config with spaces in comma-
   separated lists read from logging config files.
 
-- Patch #1604907: Fix problems in logging.handlers caused at logging
-  shutdown when syslog handlers fail to initialize because of syslogd
-  problems.
+- bpo-1604907: Fix problems in logging.handlers caused at logging shutdown
+  when syslog handlers fail to initialize because of syslogd problems.
 
-- Patch #1608267: fix a race condition in os.makedirs() if the
-  directory to be created is already there.
+- bpo-1608267: fix a race condition in os.makedirs() if the directory to be
+  created is already there.
 
-- Patch #1610437: fix a tarfile bug with long filename headers.
+- bpo-1610437: fix a tarfile bug with long filename headers.
 
-- Patch #1371075: Make ConfigParser accept optional dict type for
-  ordering, sorting, etc.
+- bpo-1371075: Make ConfigParser accept optional dict type for ordering,
+  sorting, etc.
 
-- Bug #1563807: _ctypes built on AIX fails with ld ffi error.
+- bpo-1563807: _ctypes built on AIX fails with ld ffi error.
 
-- Bug #1598620: A ctypes Structure cannot contain itself.
+- bpo-1598620: A ctypes Structure cannot contain itself.
 
-- Patch #1070046: Marshal new-style objects like InstanceType in
-  xmlrpclib.
+- bpo-1070046: Marshal new-style objects like InstanceType in xmlrpclib.
 
-- cStringIO.truncate(-1) now raises an IOError, like StringIO and
-  regular files.
+- cStringIO.truncate(-1) now raises an IOError, like StringIO and regular
+  files.
 
-- Patch #1472877: Fix Tix subwidget name resolution.
+- bpo-1472877: Fix Tix subwidget name resolution.
 
-- Patch #1594554: Always close a tkSimpleDialog on ok(), even if an
-  exception occurs.
+- bpo-1594554: Always close a tkSimpleDialog on ok(), even if an exception
+  occurs.
 
-- Patch #1538878: Don't make tkSimpleDialog dialogs transient if the
-  parent window is withdrawn.
+- bpo-1538878: Don't make tkSimpleDialog dialogs transient if the parent
+  window is withdrawn.
 
-- Bug #1597824: return the registered function from atexit.register()
-  to facilitate usage as a decorator.
+- bpo-1597824: return the registered function from atexit.register() to
+  facilitate usage as a decorator.
 
-- Patch #1360200: Use unmangled_version RPM spec field to deal with
-  file name mangling.
+- bpo-1360200: Use unmangled_version RPM spec field to deal with file name
+  mangling.
 
-- Patch #1359217: Process 2xx response in an ftplib transfer that
-  precedes an 1xx response.
+- bpo-1359217: Process 2xx response in an ftplib transfer that precedes an
+  1xx response.
 
-- Patch #1355023: support whence argument for GzipFile.seek.
+- bpo-1355023: support whence argument for GzipFile.seek.
 
-- Patch #1065257: Support passing open files as body in
+- bpo-1065257: Support passing open files as body in
   HTTPConnection.request().
 
-- Bug #1569790: mailbox.py: Maildir.get_folder() and MH.get_folder()
-  weren't passing the message factory on to newly created Maildir/MH
-  objects.
+- bpo-1569790: mailbox.py: Maildir.get_folder() and MH.get_folder() weren't
+  passing the message factory on to newly created Maildir/MH objects.
 
-- Patch #1514543: mailbox.py: In the Maildir class, report errors if
-  there's a filename clash instead of possibly losing a message.
-  (Patch by David Watson.)
+- bpo-1514543: mailbox.py: In the Maildir class, report errors if there's a
+  filename clash instead of possibly losing a message. (Patch by David
+  Watson.)
 
-- Patch #1514544: Try to ensure that messages/indexes have been
-  physically written to disk after calling .flush() or
-  .close(). (Patch by David Watson.)
+- bpo-1514544: Try to ensure that messages/indexes have been physically
+  written to disk after calling .flush() or .close(). (Patch by David
+  Watson.)
 
-- Patch #1592250: Add elide argument to Tkinter.Text.search.
+- bpo-1592250: Add elide argument to Tkinter.Text.search.
 
-- Patch #838546: Make terminal become controlling in pty.fork().
+- bpo-838546: Make terminal become controlling in pty.fork().
 
-- Patch #1351744: Add askyesnocancel helper for tkMessageBox.
+- bpo-1351744: Add askyesnocancel helper for tkMessageBox.
 
-- Patch #1060577: Extract list of RPM files from spec file in
-  bdist_rpm.
+- bpo-1060577: Extract list of RPM files from spec file in bdist_rpm.
 
-- Bug #1586613: fix zlib and bz2 codecs' incremental en/decoders.
+- bpo-1586613: fix zlib and bz2 codecs' incremental en/decoders.
 
-- Patch #1583880: fix tarfile's problems with long names and posix/
-  GNU modes.
+- bpo-1583880: fix tarfile's problems with long names and posix/ GNU modes.
 
-- Bug #1586448: the compiler module now emits the same bytecode for
-  list comprehensions as the built-in compiler, using the LIST_APPEND
-  opcode.
+- bpo-1586448: the compiler module now emits the same bytecode for list
+  comprehensions as the built-in compiler, using the LIST_APPEND opcode.
 
-- Fix codecs.EncodedFile which did not use file_encoding in 2.5.0, and
-  fix all codecs file wrappers to work correctly with the "with"
-  statement (bug #1586513).
+- Fix codecs.EncodedFile which did not use file_encoding in 2.5.0, and fix
+  all codecs file wrappers to work correctly with the "with" statement (bug
+  #1586513).
 
-- Lib/modulefinder.py now handles absolute and relative imports
-  correctly.
+- Lib/modulefinder.py now handles absolute and relative imports correctly.
 
-- Patch #1567274: Support SMTP over TLS.
+- bpo-1567274: Support SMTP over TLS.
 
-- Patch #1560695: Add .note.GNU-stack to ctypes' sysv.S so that ctypes
-  isn't considered as requiring executable stacks.
+- bpo-1560695: Add .note.GNU-stack to ctypes' sysv.S so that ctypes isn't
+  considered as requiring executable stacks.
 
-- ctypes callback functions only support 'fundamental' data types as
-  result type.  Raise an error when something else is used.  This is a
-  partial fix for Bug #1574584.
+- ctypes callback functions only support 'fundamental' data types as result
+  type.  Raise an error when something else is used.  This is a partial fix
+  for Bug #1574584.
 
-- Fix turtle so that time.sleep is imported for the entire library.
-  Allows the demo2 function to be executed on its own instead of only
-  when the module is run as a script.
+- Fix turtle so that time.sleep is imported for the entire library. Allows
+  the demo2 function to be executed on its own instead of only when the
+  module is run as a script.
 
-- Bug #1565150: Fix subsecond processing for os.utime on Windows.
+- bpo-1565150: Fix subsecond processing for os.utime on Windows.
 
 - Support for MSVC 8 was added to bdist_wininst.
 
-- Bug #1446043: correctly raise a LookupError if an encoding name
-  given to encodings.search_function() contains a dot.
+- bpo-1446043: correctly raise a LookupError if an encoding name given to
+  encodings.search_function() contains a dot.
 
-- Bug #1560617: in pyclbr, return full module name not only for
-  classes, but also for functions.
+- bpo-1560617: in pyclbr, return full module name not only for classes, but
+  also for functions.
 
-- Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes
+- bpo-1457823: cgi.(Sv)FormContentDict's constructor now takes
   keep_blank_values and strict_parsing keyword arguments.
 
-- Bug #1566602: correct failure of posixpath unittest when $HOME ends
-  with a slash.
+- bpo-1566602: correct failure of posixpath unittest when $HOME ends with a
+  slash.
 
-- Bug #1565661: in webbrowser, split() the command for the default
-  GNOME browser in case it is a command with args.
+- bpo-1565661: in webbrowser, split() the command for the default GNOME
+  browser in case it is a command with args.
 
-- Made the error message for time.strptime when the data and
-  format do match be more clear.
+- Made the error message for time.strptime when the data and format do match
+  be more clear.
 
-- Fix a bug in traceback.format_exception_only() that led to an error
-  being raised when print_exc() was called without an exception set.
-  In version 2.4, this printed "None", restored that behavior.
+- Fix a bug in traceback.format_exception_only() that led to an error being
+  raised when print_exc() was called without an exception set. In version
+  2.4, this printed "None", restored that behavior.
 
-- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't
-  because the close_fds arg to subprocess.Popen is not supported).
+- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because the
+  close_fds arg to subprocess.Popen is not supported).
 
-- Reverted patch #1504333 to sgmllib because it introduced an infinite
+- bpo-1504333: Reverted change to sgmllib because it introduced an infinite
   loop.
 
-- Patch #1553314: Fix the inspect.py slowdown that was hurting IPython
-  & SAGE by adding smarter caching in inspect.getmodule()
+- bpo-1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE
+  by adding smarter caching in inspect.getmodule()
 
 - Fix missing import of the types module in logging.config.
 
-- Patch #1550886: Fix decimal module context management implementation
-  to match the localcontext() example from PEP 343.
+- bpo-1550886: Fix decimal module context management implementation to match
+  the localcontext() example from PEP 343.
 
-- Bug #1545341: The 'classifier' keyword argument to the Distutils
-  setup() function now accepts tuples as well as lists.
+- bpo-1545341: The 'classifier' keyword argument to the Distutils setup()
+  function now accepts tuples as well as lists.
 
-- Bug #1541863: uuid.uuid1 failed to generate unique identifiers on
-  systems with low clock resolution.
+- bpo-1541863: uuid.uuid1 failed to generate unique identifiers on systems
+  with low clock resolution.
 
-- Bug #1531862: Do not close standard file descriptors in subprocess.
+- bpo-1531862: Do not close standard file descriptors in subprocess.
 
-- Fix utf-8-sig incremental decoder, which didn't recognise a BOM when
-  the first chunk fed to the decoder started with a BOM, but was
-  longer than 3 bytes.
+- Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the
+  first chunk fed to the decoder started with a BOM, but was longer than 3
+  bytes.
 
-- The implementation of UnicodeError objects has been simplified
-  (start and end attributes are now stored directly as Py_ssize_t
-  members).
+- The implementation of UnicodeError objects has been simplified (start and
+  end attributes are now stored directly as Py_ssize_t members).
 
-- Issue #829951: In the smtplib module, SMTP.starttls() now complies
-  with RFC 3207 and forgets any knowledge obtained from the server not
-  obtained from the TLS negotiation itself.  Patch contributed by Bill
-  Fenner.
+- bpo-829951: In the smtplib module, SMTP.starttls() now complies with RFC
+  3207 and forgets any knowledge obtained from the server not obtained from
+  the TLS negotiation itself.  Patch contributed by Bill Fenner.
 
-- Issue #1339: The smtplib.SMTP class has been refactored a bit such
-  that the SMTP.starttls() caller no longer needs to call ehlo()
-  beforehand.  SMTP.starttls() now raises an exception of the server
-  does not claim to support starttls.  Adds the
-  SMTP.ehlo_or_helo_if_needed() method.  Patch contributed by Bill
-  Fenner.
+- bpo-1339: The smtplib.SMTP class has been refactored a bit such that the
+  SMTP.starttls() caller no longer needs to call ehlo() beforehand.
+  SMTP.starttls() now raises an exception of the server does not claim to
+  support starttls.  Adds the SMTP.ehlo_or_helo_if_needed() method.  Patch
+  contributed by Bill Fenner.
 
-- Patch #1089358: Add signal.siginterrupt, a wrapper around
-  siginterrupt(3).
+- bpo-1089358: Add signal.siginterrupt, a wrapper around siginterrupt(3).
 
-Extension Modules
------------------
+- bpo-1657: added select.epoll and select.kqueue.
 
-- Patch #1657: added select.epoll and select.kqueue.
+- bpo-1506171: added operator.methodcaller().
 
-- Patch #1506171: added operator.methodcaller().
+- bpo-1826: operator.attrgetter() now supports dotted attribute paths.
 
-- Patch #1826: operator.attrgetter() now supports dotted attribute paths.
+- bpo-1957: syslogmodule: Release GIL when calling syslog(3).
 
-- Patch #1957: syslogmodule: Release GIL when calling syslog(3).
+- bpo-2112: mmap.error is now a subclass of EnvironmentError and not a
+  direct EnvironmentError.
 
-- Bug #2112: mmap.error is now a subclass of EnvironmentError and not
-  a direct EnvironmentError.
-
-- Bug #2111: mmap segfaults when trying to write a block opened with
+- bpo-2111: mmap segfaults when trying to write a block opened with
   PROT_READ.
 
-- Bug #2063: correct order of utime and stime in os.times() result on
+- bpo-2063: correct order of utime and stime in os.times() result on
   Windows.
 
-- Patch #1736: Fix file name handling of _msi.FCICreate.
+- bpo-1736: Fix file name handling of _msi.FCICreate.
 
 - Updated ``big5hkscs`` codec to the HKSCS revision of 2004.
 
-- Issue #1940: make it possible to use curses.filter() before
-  curses.initscr() as the documentation says.
+- bpo-1940: make it possible to use curses.filter() before curses.initscr()
+  as the documentation says.
 
 - Backport of _fileio module from Python 3.0.
 
-- Patch #1087741: mmap.mmap is now a class, not a factory function. It
-  is also subclassable now.
+- bpo-1087741: mmap.mmap is now a class, not a factory function. It is also
+  subclassable now.
 
-- Patch #1648: added ``sys.getprofile()`` and ``sys.gettrace()``.
+- bpo-1648: added ``sys.getprofile()`` and ``sys.gettrace()``.
 
-- Patch #1663329: added ``os.closerange()`` function to quickly close
-  a range of file descriptors without considering errors.
+- bpo-1663329: added ``os.closerange()`` function to quickly close a range
+  of file descriptors without considering errors.
 
-- Patch #976880: ``mmap`` objects now have an ``rfind`` method that
-  works as expected.  ``mmap.find`` also takes an optional ``end``
-  parameter.
+- bpo-976880: ``mmap`` objects now have an ``rfind`` method that works as
+  expected. ``mmap.find`` also takes an optional ``end`` parameter.
 
-- _winreg's HKEY object has gained __enter__ and __exit__ methods to
-  support the context management protocol.  The _winreg module also
-  gained a new function ``ExpandEnvironmentStrings`` to expand
-  REG_EXPAND_SZ keys.
+- _winreg's HKEY object has gained __enter__ and __exit__ methods to support
+  the context management protocol.  The _winreg module also gained a new
+  function ``ExpandEnvironmentStrings`` to expand REG_EXPAND_SZ keys.
 
 - itertools.starmap() now accepts any iterable input. Previously, it
   required the function inputs to be tuples.
 
-- itertools.chain() now has an alternate constructor,
-  chain.from_iterable().
+- itertools.chain() now has an alternate constructor, chain.from_iterable().
 
-- Issue #1646: Make socket support TIPC. The socket module now has
-  support for TIPC under Linux, see http://tipc.sf.net/ for more
-  information.
+- bpo-1646: Make socket support TIPC. The socket module now has support for
+  TIPC under Linux, see http://tipc.sf.net/ for more information.
 
 - Added interface for Windows' WSAIoctl to socket object and added an
   example for a simple network sniffer.
 
-- Bug #1301: Bad assert in _tkinter fixed.
+- bpo-1301: Bad assert in _tkinter fixed.
 
 - Added bdist_wininst executable for VS 2008.
 
-- Bug #1604: collections.deque.__init__(iterable) now clears any prior
-  contents before adding elements from the iterable.  This fix brings
-  the behavior into line with that for list.__init__().
+- bpo-1604: collections.deque.__init__(iterable) now clears any prior
+  contents before adding elements from the iterable.  This fix brings the
+  behavior into line with that for list.__init__().
 
-- Added wide char functions to msvcrt module: getwch, getwche, putwch
-  and ungetwch. The functions accept or return unicode.
+- Added wide char functions to msvcrt module: getwch, getwche, putwch and
+  ungetwch. The functions accept or return unicode.
 
 - os.access now returns True on Windows for any existing directory.
 
@@ -12043,135 +12354,124 @@ Extension Modules
 
 - Marshal.dumps() now expects exact type matches for int, long, float,
   complex, tuple, list, dict, set, and frozenset.  Formerly, it would
-  silently miscode subclasses of those types.  Now, it raises a
-  ValueError instead.
+  silently miscode subclasses of those types.  Now, it raises a ValueError
+  instead.
 
-- Patch #1388440: Add set_completion_display_matches_hook and
+- bpo-1388440: Add set_completion_display_matches_hook and
   get_completion_type to readline.
 
-- Bug #1649098: Avoid declaration of zero-sized array declaration in
+- bpo-1649098: Avoid declaration of zero-sized array declaration in
   structure.
 
 - Removed the rgbimg module; been deprecated since Python 2.5.
 
-- Bug #1721309: prevent bsddb module from freeing random memory.
+- bpo-1721309: prevent bsddb module from freeing random memory.
 
-- Bug #1233: fix bsddb.dbshelve.DBShelf append method to work as
-  intended for RECNO databases.
+- bpo-1233: fix bsddb.dbshelve.DBShelf append method to work as intended for
+  RECNO databases.
 
-- pybsddb.sf.net Bug #477182: Load the database flags at database open
-  time so that opening a database previously created with the DB_DUP
-  or DB_DUPSORT flag set will keep the proper behavior on subsequent
-  opens.  Specifically: dictionary assignment to a DB object will
-  replace all values for a given key when the database allows
-  duplicate values.  DB users should use DB.put(k, v) when they want
-  to store duplicates; not DB[k] = v.
+- pybsddb.sf.net Bug #477182: Load the database flags at database open time
+  so that opening a database previously created with the DB_DUP or
+  DB_DUPSORT flag set will keep the proper behavior on subsequent opens.
+  Specifically: dictionary assignment to a DB object will replace all values
+  for a given key when the database allows duplicate values.  DB users
+  should use DB.put(k, v) when they want to store duplicates; not DB[k] = v.
 
 - Add the bsddb.db.DBEnv.lock_id_free method.
 
-- Bug #1686475: Support stat'ing open files on Windows again.
+- bpo-1686475: Support stat'ing open files on Windows again.
 
-- Patch #1185447: binascii.b2a_qp() now correctly quotes binary
-  characters with ASCII value less than 32. Also, it correctly quotes
-  dots only if they occur on a single line, as opposed to the previous
-  behavior of quoting dots if they are the second character of any
-  line.
+- bpo-1185447: binascii.b2a_qp() now correctly quotes binary characters with
+  ASCII value less than 32. Also, it correctly quotes dots only if they
+  occur on a single line, as opposed to the previous behavior of quoting
+  dots if they are the second character of any line.
 
-- Bug #1622896: fix a rare corner case where the bz2 module raised an
-  error in spite of a succesful compression.
+- bpo-1622896: fix a rare corner case where the bz2 module raised an error
+  in spite of a succesful compression.
 
-- Patch #1654417: make operator.{get,set,del}slice use the full range
-  of Py_ssize_t.
+- bpo-1654417: make operator.{get,set,del}slice use the full range of
+  Py_ssize_t.
 
-- Patch #1646728: datetime.fromtimestamp fails with negative
-  fractional times.  With unittest.
+- bpo-1646728: datetime.fromtimestamp fails with negative fractional times.
+  With unittest.
 
-- Patch #1490190: posixmodule now includes os.chflags() and
-  os.lchflags() functions on platforms where the underlying system
-  calls are available.
+- bpo-1490190: posixmodule now includes os.chflags() and os.lchflags()
+  functions on platforms where the underlying system calls are available.
 
-- Patch #1494140: Add documentation for the new struct.Struct object.
+- bpo-1494140: Add documentation for the new struct.Struct object.
 
-- Patch #1432399: Support the HCI protocol for bluetooth sockets
+- bpo-1432399: Support the HCI protocol for bluetooth sockets
 
-- Patch #1657276: Make NETLINK_DNRTMSG conditional.
+- bpo-1657276: Make NETLINK_DNRTMSG conditional.
 
-- Bug #1653736: Complain about keyword arguments to time.isoformat.
+- bpo-1653736: Complain about keyword arguments to time.isoformat.
 
-- Bug #1486663: don't reject keyword arguments for subclasses of
-  built-in types.
+- bpo-1486663: don't reject keyword arguments for subclasses of built-in
+  types.
 
-- Patch #1610575: The struct module now supports the 't' code, for C99
-  _Bool.
+- bpo-1610575: The struct module now supports the 't' code, for C99 _Bool.
 
-- Patch #1635058: ensure that htonl and friends never accept or return
-  negative numbers, per the underlying C implementation.
+- bpo-1635058: ensure that htonl and friends never accept or return negative
+  numbers, per the underlying C implementation.
 
-- Patch #1544279: Improve thread-safety of the socket module by moving
-  the sock_addr_t storage out of the socket object.
+- bpo-1544279: Improve thread-safety of the socket module by moving the
+  sock_addr_t storage out of the socket object.
 
-- Patch #1019808: fix bug that causes an incorrect error to be
-  returned when a socket timeout is set and a connection attempt
-  fails.
+- bpo-1019808: fix bug that causes an incorrect error to be returned when a
+  socket timeout is set and a connection attempt fails.
 
 - Speed up function calls into the math module.
 
-- Bug #1588217: don't parse "= " as a soft line break in binascii's
-  a2b_qp() function, instead leave it in the string as quopri.decode()
-  does.
+- bpo-1588217: don't parse "= " as a soft line break in binascii's a2b_qp()
+  function, instead leave it in the string as quopri.decode() does.
 
-- Bug #1599782: Fix segfault on bsddb.db.DB().type().
+- bpo-1599782: Fix segfault on bsddb.db.DB().type().
 
-- Bug #1567666: Emulate GetFileAttributesExA for Win95.
+- bpo-1567666: Emulate GetFileAttributesExA for Win95.
 
-- Patch #1576166: Support os.utime for directories on Windows NT+.
+- bpo-1576166: Support os.utime for directories on Windows NT+.
 
-- Patch #1572724: fix typo ('=' instead of '==') in _msi.c.
+- bpo-1572724: fix typo ('=' instead of '==') in _msi.c.
 
-- Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault
-  when encoding non-BMP unicode characters.
+- bpo-1572832: fix a bug in ISO-2022 codecs which may cause segfault when
+  encoding non-BMP unicode characters.
 
-- Bug #1556784: allow format strings longer than 127 characters in
-  datetime's strftime function.
+- bpo-1556784: allow format strings longer than 127 characters in datetime's
+  strftime function.
 
 - Fix itertools.count(n) to work with negative numbers again.
 
 - RLIMIT_SBSIZE was added to the resource module where available.
 
-- Bug #1551427: fix a wrong NULL pointer check in the win32 version of
+- bpo-1551427: fix a wrong NULL pointer check in the win32 version of
   os.urandom().
 
-- Bug #1548092: fix curses.tparm seg fault on invalid input.
+- bpo-1548092: fix curses.tparm seg fault on invalid input.
 
-- Patch #1114: fix curses module compilation on 64-bit AIX, & possibly
-  other 64-bit LP64 platforms where attr_t is not the same size as a
-  long.  (Contributed by Luke Mewburn.)
+- bpo-1114: fix curses module compilation on 64-bit AIX, & possibly other
+  64-bit LP64 platforms where attr_t is not the same size as a long.
+  (Contributed by Luke Mewburn.)
 
-- Bug #1550714: fix SystemError from itertools.tee on negative value
-  for n.
+- bpo-1550714: fix SystemError from itertools.tee on negative value for n.
 
-- Fixed a few bugs on cjkcodecs:
-  - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT
-    correctly.
-  - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312
-    codepoints to conform the standard.
-  - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2
-    codepoints now.
+- Fixed a few bugs on cjkcodecs: - gbk and gb18030 codec now handle U+30FB
+  KATAKANA MIDDLE DOT   correctly. - iso2022_jp_2 codec now encodes into G0
+  for KS X 1001, GB2312   codepoints to conform the standard. - iso2022_jp_3
+  and iso2022_jp_2004 codec can encode JIS X 0213:2   codepoints now.
 
-- Bug #1552726: in readline.c, avoid repeatedly polling in interactive
-  mode by only placing a timeout on the select() if an input hook has
-  been defined.  This prevents an interactive Python from waking up 10
-  times per second.  Patch by Richard Boulton.
+- bpo-1552726: in readline.c, avoid repeatedly polling in interactive mode
+  by only placing a timeout on the select() if an input hook has been
+  defined.  This prevents an interactive Python from waking up 10 times per
+  second.  Patch by Richard Boulton.
 
-- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments
-  were transposed.
+- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments were
+  transposed.
 
-- Added support for linking the bsddb module against BerkeleyDB 4.5.x,
-  4.6.x and 4.7.x.
+- Added support for linking the bsddb module against BerkeleyDB 4.5.x, 4.6.x
+  and 4.7.x.
 
-- Bug #1633621: if curses.resizeterm() or curses.resize_term() is
-  called, update _curses.LINES, _curses.COLS, curses.LINES and
-  curses.COLS.
+- bpo-1633621: if curses.resizeterm() or curses.resize_term() is called,
+  update _curses.LINES, _curses.COLS, curses.LINES and curses.COLS.
 
 - Fix an off-by-one bug in locale.strxfrm().
 
@@ -12179,88 +12479,86 @@ Extension Modules
 
 - Build using system ffi library on arm*-linux*.
 
-- Bug #1372: zlibmodule.c: int overflow in PyZlib_decompress
+- bpo-1372: zlibmodule.c: int overflow in PyZlib_decompress
 
-- bsddb module: Fix memory leak when using database cursors on
-  databases without a DBEnv.
+- bsddb module: Fix memory leak when using database cursors on databases
+  without a DBEnv.
 
 - The sqlite3 module was updated to pysqlite 2.4.1.
 
 IDLE
 ----
 
-- Bug #813342: Start the IDLE subprocess with -Qnew if the parent is
-  started with that option.
+- bpo-813342: Start the IDLE subprocess with -Qnew if the parent is started
+  with that option.
 
-- IDLE: Honor the "Cancel" action in the save dialog (Debian bug
-  #299092).
+- IDLE: Honor the "Cancel" action in the save dialog (Debian bug #299092).
 
 Tests
 -----
+
 - bpo-30357: test_thread: setUp() now uses support.threading_setup() and
-  support.threading_cleanup() to wait until threads complete to avoid
-  random side effects on following tests. Initial patch written by Grzegorz
+  support.threading_cleanup() to wait until threads complete to avoid random
+  side effects on following tests. Initial patch written by Grzegorz
   Grzywacz.
 
 - Refactor test_logging to use unittest.
 
-- Refactor test_profile and test_cprofile to use the same code to
-  profile.
+- Refactor test_profile and test_cprofile to use the same code to profile.
 
-- Make test_runpy reentrant by fixing _check_module to clear out any
-  module being tested.  Was causing an error by __import__ doing a
-  reload on the second run and thus suppressing bytecode recreation.
+- Make test_runpy reentrant by fixing _check_module to clear out any module
+  being tested.  Was causing an error by __import__ doing a reload on the
+  second run and thus suppressing bytecode recreation.
 
 - Capture socket connection resets and timeouts in test_socket_ssl and
   test_urllib2net and raise test.test_support.ResourceDenied.
 
-- Patch #1559413: Fix test_cmd_line if sys.executable contains a
-  space.
+- bpo-1559413: Fix test_cmd_line if sys.executable contains a space.
 
-- Added test.test_support.TransientResource which is a context manager
-  to surround calls to resources that are not guaranteed to work even
-  if test.test_support.requires says that the resource should exist.
+- Added test.test_support.TransientResource which is a context manager to
+  surround calls to resources that are not guaranteed to work even if
+  test.test_support.requires says that the resource should exist.
 
 - Added a test for slicing of an exception.
 
-- Added test.test_support.EnvironmentVarGuard.  It's a class that
-  provides a context manager so that one can temporarily set or unset
-  environment variables.
+- Added test.test_support.EnvironmentVarGuard.  It's a class that provides a
+  context manager so that one can temporarily set or unset environment
+  variables.
 
 - Added some tests for modulefinder.
 
 - Converted test_imp to use unittest.
 
-- Fix bsddb test_basics.test06_Transactions to check the version
-  number properly.
+- Fix bsddb test_basics.test06_Transactions to check the version number
+  properly.
 
-- test.test_support.catch_warning is a new context manager that can be
-  used to catch the warnings issued by the warning framework.
+- test.test_support.catch_warning is a new context manager that can be used
+  to catch the warnings issued by the warning framework.
 
-Tools
------
+Tools/Demos
+-----------
 
-- Tools/scripts/reindent.py now creates the backup file using
-  shutil.copy to preserve user/group and permissions. Added also a
-  --nobackup option to not create the backup if the user is concerned
-  regarding this.  Check issue #1050828 for more details.
+- Tools/scripts/reindent.py now creates the backup file using shutil.copy to
+  preserve user/group and permissions. Added also a --nobackup option to not
+  create the backup if the user is concerned regarding this.  Check issue
+  #1050828 for more details.
 
-- Tools/scripts/win_add2path.py was added. The simple script modifes
-  the PATH environment var of the HKCU tree and adds the python bin
-  and script directory.
+- Tools/scripts/win_add2path.py was added. The simple script modifes the
+  PATH environment var of the HKCU tree and adds the python bin and script
+  directory.
 
 - Tools/18n/pygettext.py was added to the list of scripts installed by
   Tools/scripts/setup.py (tracker item 642309).
 
-- Added IronPython and Jython support to pybench (part of which was
-  patch #1563844).
+- Added IronPython and Jython support to pybench (part of which was patch
+  #1563844).
 
-- Made some minor changes to pybench output to allow the user to see
-  which Python version is running pybench.
+- Made some minor changes to pybench output to allow the user to see which
+  Python version is running pybench.
 
 - Added support for the new platform module feature
-  platform.python_implementation(); this will now be saved in the
-  benchmark pickle.
+  platform.python_implementation(); this will now be saved in the benchmark
+  pickle.
 
 Documentation
 -------------
@@ -12268,133 +12566,126 @@ Documentation
 - RFE #1765140: Updated documentation on FileHandler and subclasses to
   include new optional delay argument.
 
-- Bug #932563: Added section on getting contextual information into
-  logging output, and added documentation for the new LoggerAdapter
-  class.
+- bpo-932563: Added section on getting contextual information into logging
+  output, and added documentation for the new LoggerAdapter class.
 
-- Bug #1295: Added information about caching of formatted exception
+- bpo-1295: Added information about caching of formatted exception
   information in the LogRecord by Formatter.format().
 
-- Bug #1637365: add subsection about "__name__ == __main__" to the
-  Python tutorial.
+- bpo-1637365: add subsection about "__name__ == __main__" to the Python
+  tutorial.
 
-- Patch #1698768: updated the "using Python on the Mac" intro.
+- bpo-1698768: updated the "using Python on the Mac" intro.
 
-- Bug #1569057: Document that calling file.next() when the file is
-  open for writing is undefined.
+- bpo-1569057: Document that calling file.next() when the file is open for
+  writing is undefined.
 
-- Patch #1489771: the syntax rules in Python Reference Manual were
-  updated to reflect the current Python syntax.
+- bpo-1489771: the syntax rules in Python Reference Manual were updated to
+  reflect the current Python syntax.
 
-- Patch #1686451: Fix return type for
-  PySequence_{Count,Index,Fast_GET_SIZE}.
+- bpo-1686451: Fix return type for PySequence_{Count,Index,Fast_GET_SIZE}.
 
-- Patch #1679379: add documentation for fnmatch.translate().
+- bpo-1679379: add documentation for fnmatch.translate().
 
-- Bug #1629566: clarify the docs on the return values of parsedate()
-  and parsedate_tz() in email.utils and rfc822.
+- bpo-1629566: clarify the docs on the return values of parsedate() and
+  parsedate_tz() in email.utils and rfc822.
 
-- Patch #1671450: add a section about subclassing built-in types to the
+- bpo-1671450: add a section about subclassing built-in types to the
   "extending and embedding" tutorial.
 
-- Bug #1629125: fix wrong data type (int -> Py_ssize_t) in PyDict_Next
-  docs.
+- bpo-1629125: fix wrong data type (int -> Py_ssize_t) in PyDict_Next docs.
 
-- Bug #1565919: document set types in the Language Reference.
+- bpo-1565919: document set types in the Language Reference.
 
-- Bug #1546052: clarify that PyString_FromString(AndSize) copies the
-  string pointed to by its parameter.
+- bpo-1546052: clarify that PyString_FromString(AndSize) copies the string
+  pointed to by its parameter.
 
-- Bug #1566663: remove obsolete example from datetime docs.
+- bpo-1566663: remove obsolete example from datetime docs.
 
-- Bug #1541682: Fix example in the "Refcount details" API docs.
-  Additionally, remove a faulty example showing PySequence_SetItem
-  applied to a newly created list object and add notes that this isn't
-  a good idea.
+- bpo-1541682: Fix example in the "Refcount details" API docs. Additionally,
+  remove a faulty example showing PySequence_SetItem applied to a newly
+  created list object and add notes that this isn't a good idea.
 
 Tools/Demos
 -----------
 
-- Patch #1552024: add decorator support to unparse.py demo script.
+- bpo-1552024: add decorator support to unparse.py demo script.
 
 - Make auto-generated python.vim file list built-ins and exceptions in
-  alphatbetical order.  Makes output more deterministic and easier to
-  tell if the file is stale or not.
+  alphatbetical order.  Makes output more deterministic and easier to tell
+  if the file is stale or not.
 
-- Bug #1546372: Fixed small bugglet in pybench that caused a missing
-  file not to get reported properly.
+- bpo-1546372: Fixed small bugglet in pybench that caused a missing file not
+  to get reported properly.
 
 Build
 -----
 
-- Have the search path for building extensions follow the declared
-  order in $CPPFLAGS and $LDFLAGS when adding directories from those
-  environment variables.
+- Have the search path for building extensions follow the declared order in
+  $CPPFLAGS and $LDFLAGS when adding directories from those environment
+  variables.
 
-- Bug #1983: Added a check to pyport to verify that sizeof(pid_t) is
-  smaller or equal sizeof(long).
+- bpo-1983: Added a check to pyport to verify that sizeof(pid_t) is smaller
+  or equal sizeof(long).
 
-- Bug #1234: Fixed semaphore errors on AIX 5.2
+- bpo-1234: Fixed semaphore errors on AIX 5.2
 
-- Issue #1726: Remove Python/atof.c from PCBuild/pythoncore.vcproj.
+- bpo-1726: Remove Python/atof.c from PCBuild/pythoncore.vcproj.
 
-- Removed PCbuild8/ directory and added a new build directory for VS
-  2005 based on the VS 2008 build directory to PC/VS8.0. The script
-  PCbuild/vs8to9.py was added to sync changes from PCbuild to
-  PC/VS8.0.
+- Removed PCbuild8/ directory and added a new build directory for VS 2005
+  based on the VS 2008 build directory to PC/VS8.0. The script
+  PCbuild/vs8to9.py was added to sync changes from PCbuild to PC/VS8.0.
 
-- Moved PCbuild/ directory for VS 2003 to PC/VS7.1 and renamed
-  PCBuild9/ directory to PCBuild/.
+- Moved PCbuild/ directory for VS 2003 to PC/VS7.1 and renamed PCBuild9/
+  directory to PCBuild/.
 
-- Bug #1699: Define _BSD_SOURCE only on OpenBSD.
+- bpo-1699: Define _BSD_SOURCE only on OpenBSD.
 
-- Bug #1608: use -fwrapv when GCC supports it.  This is important,
-  newer GCC versions may optimize away overflow buffer overflow checks
-  without this option!
+- bpo-1608: use -fwrapv when GCC supports it.  This is important, newer GCC
+  versions may optimize away overflow buffer overflow checks without this
+  option!
 
-- Patch #1418: Make the AC_REPLACE_FUNCS object files actually work.
+- bpo-1418: Make the AC_REPLACE_FUNCS object files actually work.
 
 - Add a FAST_LOOPS build option that speeds-up looping by trading away
-  periodic threadstate and signal checking in tight loops.  By
-  default, this option is turned-off.  It should only be enabled in
-  debugged, performance critical applications.
+  periodic threadstate and signal checking in tight loops.  By default, this
+  option is turned-off.  It should only be enabled in debugged, performance
+  critical applications.
 
-- Patch #786737: Allow building in a tree of symlinks pointing to a
-  readonly source.
+- bpo-786737: Allow building in a tree of symlinks pointing to a readonly
+  source.
 
-- Bug #1737210: Change Manufacturer of Windows installer to PSF.
+- bpo-1737210: Change Manufacturer of Windows installer to PSF.
 
-- Bug #1746880: Correctly install DLLs into system32 folder on Win64.
+- bpo-1746880: Correctly install DLLs into system32 folder on Win64.
 
-- Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD
-  4.1+.
+- Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+.
 
 - Stop supporting AtheOS and cause a build error in configure for the
   platform.
 
-- Bug #1655392: don't add -L/usr/lib/pythonX.Y/config to the LDFLAGS
-  returned by python-config if Python was built with --enable-shared
-  because that prevented the shared library from being used.
+- bpo-1655392: don't add -L/usr/lib/pythonX.Y/config to the LDFLAGS returned
+  by python- config if Python was built with --enable-shared because that
+  prevented the shared library from being used.
 
-- Patch #1569798: fix a bug in distutils when building Python from a
-  directory within sys.exec_prefix.
+- bpo-1569798: fix a bug in distutils when building Python from a directory
+  within sys.exec_prefix.
 
-- Bug #1675511: Use -Kpic instead of -xcode=pic32 on Solaris/x86.
+- bpo-1675511: Use -Kpic instead of -xcode=pic32 on Solaris/x86.
 
 - Disable _XOPEN_SOURCE on NetBSD 1.x.
 
-- configure now checks whether gcc supports the PyArg_ParseTuple
-  format attribute.
+- configure now checks whether gcc supports the PyArg_ParseTuple format
+  attribute.
 
-- Bug #1578513: Cross compilation was broken by a change to configure.
-  Repair so that it's back to how it was in 2.4.3.
+- bpo-1578513: Cross compilation was broken by a change to configure. Repair
+  so that it's back to how it was in 2.4.3.
 
-- Patch #1576954: Update VC6 build directory; remove redundant files
-  in VC7.
+- bpo-1576954: Update VC6 build directory; remove redundant files in VC7.
 
-- Bug #1568842: Fix test for uintptr_t.
+- bpo-1568842: Fix test for uintptr_t.
 
-- Patch #1540470: for OpenBSD 4.0.
+- bpo-1540470: for OpenBSD 4.0.
 
 - Fix build failure on kfreebsd and on the hurd.
 
@@ -12402,96 +12693,91 @@ Build
 
 - Allow Emacs 22 for building the documentation in info format.
 
-- Makefile.pre.in(buildbottest): Run an optional script
-  pybuildbot.identify to include some information about the build
-  environment.
+- Makefile.pre.in(buildbottest): Run an optional script pybuildbot.identify
+  to include some information about the build environment.
 
 C API
 -----
 
-- Unified naming convention for free lists and their limits. All free
-  lists in Object/ are named ``free_list``, the counter ``numfree``
-  and the upper limit is a macro ``PyName_MAXFREELIST`` inside an
-  #ifndef block.
+- Unified naming convention for free lists and their limits. All free lists
+  in Object/ are named ``free_list``, the counter ``numfree`` and the upper
+  limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
 
-- ``PySet_Add()`` can now modify a newly created frozenset.  Similarly
-  to ``PyTuple_SetItem``, it can be used to populate a brand new
-  frozenset; but it does not steal a reference to the added item.
+- ``PySet_Add()`` can now modify a newly created frozenset.  Similarly to
+  ``PyTuple_SetItem``, it can be used to populate a brand new frozenset; but
+  it does not steal a reference to the added item.
 
 - Added ``PySet_Check()`` and ``PyFrozenSet_Check()`` to the set API.
 
-- Backport of PyUnicode_FromString(), _FromStringAndSize(), _Format
-  and _FormatV from Python 3.0. Made PyLong_AsSsize_t and
-  PyLong_FromSsize_t public functions.
+- Backport of PyUnicode_FromString(), _FromStringAndSize(), _Format and
+  _FormatV from Python 3.0. Made PyLong_AsSsize_t and PyLong_FromSsize_t
+  public functions.
 
-- Patch #1720595: add T_BOOL to the range of structmember types.
+- bpo-1720595: add T_BOOL to the range of structmember types.
 
-- Issue #1534: Added ``PyFloat_GetMax()``, ``PyFloat_GetMin()`` and
+- bpo-1534: Added ``PyFloat_GetMax()``, ``PyFloat_GetMin()`` and
   ``PyFloat_GetInfo()`` to the float API.
 
-- Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t#
-  of w# format code incorrectly truncated the length to an int, even
-  when PY_SSIZE_T_CLEAN is set.  The str.decode method used to return
-  incorrect results with huge strings.
+- bpo-1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w#
+  format code incorrectly truncated the length to an int, even when
+  PY_SSIZE_T_CLEAN is set.  The str.decode method used to return incorrect
+  results with huge strings.
 
-- Issue #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE,
-  Py_TYPE and Py_REFCNT.
+- bpo-1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and
+  Py_REFCNT.
 
-- PEP 3123: Provide forward compatibility with Python 3.0, while
-  keeping backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size,
-  and PyVarObject_HEAD_INIT.
+- PEP 3123: Provide forward compatibility with Python 3.0, while keeping
+  backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
+  PyVarObject_HEAD_INIT.
 
-- Py_ssize_t fields work in structmember when HAVE_LONG_LONG is not
-  defined.
+- Py_ssize_t fields work in structmember when HAVE_LONG_LONG is not defined.
 
-- Patch #1733960: Allow T_LONGLONG to accept ints.
+- bpo-1733960: Allow T_LONGLONG to accept ints.
 
 - T_PYSSIZET can now be used in PyMemberDef lists for Py_ssize_t members.
 
 - Added a new API function ``PyImport_ImportModuleNoBlock``.
 
-- Bug #1637022: Prefix AST symbols with _Py_.
+- bpo-1637022: Prefix AST symbols with _Py_.
 
-- Fix some leftovers from the conversion from int to Py_ssize_t
-  (relevant to strings and sequences of more than 2**31 items).
+- Fix some leftovers from the conversion from int to Py_ssize_t (relevant to
+  strings and sequences of more than 2**31 items).
 
 - Make _PyGILState_NoteThreadState() static, it was not used anywhere
   outside of pystate.c and should not be necessary.
 
-- ``PyImport_Import`` and ``PyImport_ImportModule`` now always do
-  absolute imports. In earlier versions they might have used relative
-  imports under some conditions.
+- ``PyImport_Import`` and ``PyImport_ImportModule`` now always do absolute
+  imports. In earlier versions they might have used relative imports under
+  some conditions.
 
-- Added case insensitive comparison methods ``PyOS_stricmp(char*,
-  char*)`` and ``PyOS_strnicmp(char*, char*, Py_ssize_t)``.
+- Added case insensitive comparison methods ``PyOS_stricmp(char*, char*)``
+  and ``PyOS_strnicmp(char*, char*, Py_ssize_t)``.
 
-- Bug #1542693: remove semi-colon at end of PyImport_ImportModuleEx
-  macro so it can be used as an expression.
+- bpo-1542693: remove semi-colon at end of PyImport_ImportModuleEx macro so
+  it can be used as an expression.
 
 Windows
 -------
 
-- Patch #1706: Drop support for Win9x, WinME and NT4. Python now
-  requires Windows 2000 or greater. The _WINVER and NTDDI_VERSION
-  macros are set to Win2k for x86/32bit builds and WinXP for AMD64
-  builds.
+- bpo-1706: Drop support for Win9x, WinME and NT4. Python now requires
+  Windows 2000 or greater. The _WINVER and NTDDI_VERSION macros are set to
+  Win2k for x86/32bit builds and WinXP for AMD64 builds.
 
 - Conditionalize definition of _CRT_SECURE_NO_DEPRECATE and
   _CRT_NONSTDC_NO_DEPRECATE.
 
-- Bug #1216: Restore support for Visual Studio 2002.
+- bpo-1216: Restore support for Visual Studio 2002.
 
-Mac
----
+macOS
+-----
 
 - cfmfile now raises a DeprecationWarning.
 
 - buildtools now raises a DeprecationWarning.
 
-- Removed the macfs module.  It had been deprecated since Python 2.5.
-  This lead to the deprecation of macostools.touched() as it relied
-  solely on macfs and was a no-op under OS X.
+- Removed the macfs module.  It had been deprecated since Python 2.5. This
+  lead to the deprecation of macostools.touched() as it relied solely on
+  macfs and was a no-op under OS X.
 
-----
 
 **(For information about older versions, consult the HISTORY file.)**
diff --git a/Misc/NEWS.d/2.7.14rc1.rst b/Misc/NEWS.d/2.7.14rc1.rst
deleted file mode 100644 (file)
index 462c03a..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-.. bpo: 30947
-.. date: 2017-08-16-16-35-59
-.. nonce: iNMmm4
-.. release date: 2017-08-26
-.. section: Security
-
-Upgrade libexpat embedded copy from version 2.2.1 to 2.2.3 to get security
-fixes.
-
-..
-
-.. bpo: 30765
-.. date: 2017-06-26-14-29-50
-.. nonce: Q5iBmf
-.. section: Core and Builtins
-
-Avoid blocking in pthread_mutex_lock() when PyThread_acquire_lock() is asked
-not to block.
-
-..
-
-.. bpo: 31135
-.. date: 2017-08-08-14-59-26
-.. nonce: 9q1QdB
-.. section: Library
-
-ttk: Fix LabeledScale and OptionMenu destroy() method. Call the parent
-destroy() method even if the used attribute doesn't exist. The
-LabeledScale.destroy() method now also explicitly clears label and scale
-attributes to help the garbage collector to destroy all widgets.
-
-..
-
-.. bpo: 31107
-.. date: 2017-08-02-12-48-15
-.. nonce: 1t2hn5
-.. section: Library
-
-Fix `copy_reg._slotnames()` mangled attribute calculation for classes whose
-name begins with an underscore. Patch by Shane Harvey.
-
-..
-
-.. bpo: 29519
-.. date: 2017-07-31-19-32-57
-.. nonce: _j1awg
-.. section: Library
-
-Fix weakref spewing exceptions during interpreter shutdown when used with a
-rare combination of multiprocessing and custom codecs.
-
-..
-
-.. bpo: 30119
-.. date: 2017-07-26-22-02-07
-.. nonce: DZ6C_S
-.. section: Library
-
-ftplib.FTP.putline() now throws ValueError on commands that contains CR or
-LF. Patch by Dong-hee Na.
-
-..
-
-.. bpo: 30595
-.. date: 2017-07-26-04-46-12
-.. nonce: -zJ7d8
-.. section: Library
-
-multiprocessing.Queue.get() with a timeout now polls its reader in non-
-blocking mode if it succeeded to aquire the lock but the acquire took longer
-than the timeout.
-
-..
-
-.. bpo: 29902
-.. date: 2017-07-23-13-47-22
-.. nonce: CiuFdn
-.. section: Library
-
-Py3k deprecation warning now is emitted when pickling or copying some
-builtin and extension objects that don't support pickling explicitly and are
-pickled incorrectly by default (like memoryview or staticmethod).  This is a
-TypeError in Python 3.6.
-
-..
-
-.. bpo: 29854
-.. date: 2017-07-07-02-18-57
-.. nonce: J8wKb_
-.. section: Library
-
-Fix segfault in readline when using readline's history-size option.  Patch
-by Nir Soffer.
-
-..
-
-.. bpo: 30807
-.. date: 2017-06-29-22-04-44
-.. nonce: sLtjY-
-.. section: Library
-
-signal.setitimer() may disable the timer when passed a tiny value.
-
-Tiny values (such as 1e-6) are valid non-zero values for setitimer(), which
-is specified as taking microsecond-resolution intervals. However, on some
-platform, our conversion routine could convert 1e-6 into a zero interval,
-therefore disabling the timer instead of (re-)scheduling it.
-
-..
-
-.. bpo: 30715
-.. date: 2017-07-25-15-27-44
-.. nonce: Sp7bTF
-.. section: Tests
-
-Address ALPN callback changes for OpenSSL 1.1.0f. The latest version behaves
-like OpenSSL 1.0.2 and no longer aborts handshake.
-
-..
-
-.. bpo: 30822
-.. date: 2017-07-20-14-29-54
-.. nonce: X0wREo
-.. section: Tests
-
-Fix regrtest command line parser to allow passing -u extralargefile to run
-test_zipfile64.
-
-..
-
-.. bpo: 30283
-.. date: 2017-06-26-11-24-14
-.. nonce: qCQmlm
-.. section: Tests
-
-regrtest: Enhance regrtest and backport features from the master branch.
-
-Add options: --coverage, --testdir, --list-tests (list test files, don't run
-them), --list-cases (list test identifiers, don't run them, :issue:`30523`),
---matchfile (load a list of test filters from a text file, :issue:`30540`),
---slowest (alias to --slow).
-
-Enhance output: add timestamp, test result, currently running tests, "Tests
-result: xxx" summary with total duration, etc.
-
-Fix reference leak hunting in regrtest, --huntrleaks: regrtest now warms up
-caches, create explicitly all internal singletons which are created on
-demand to prevent false positives when checking for reference leaks.
-(:issue:`30675`).
diff --git a/Misc/NEWS.d/next/Build/README.rst b/Misc/NEWS.d/next/Build/README.rst
deleted file mode 100644 (file)
index 0d2d2c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Build* section in this directory.
diff --git a/Misc/NEWS.d/next/C API/README.rst b/Misc/NEWS.d/next/C API/README.rst
deleted file mode 100644 (file)
index 5a04f76..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *C API* section in this directory.
diff --git a/Misc/NEWS.d/next/Core and Builtins/README.rst b/Misc/NEWS.d/next/Core and Builtins/README.rst
deleted file mode 100644 (file)
index 52b8c3e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Core and Builtins* section in this directory.
diff --git a/Misc/NEWS.d/next/Documentation/README.rst b/Misc/NEWS.d/next/Documentation/README.rst
deleted file mode 100644 (file)
index 405f0ac..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Documentation* section in this directory.
diff --git a/Misc/NEWS.d/next/IDLE/README.rst b/Misc/NEWS.d/next/IDLE/README.rst
deleted file mode 100644 (file)
index 5475f7b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *IDLE* section in this directory.
diff --git a/Misc/NEWS.d/next/Library/2017-09-04-23-41-35.bpo-31170.QGmJ1t.rst b/Misc/NEWS.d/next/Library/2017-09-04-23-41-35.bpo-31170.QGmJ1t.rst
deleted file mode 100644 (file)
index 2505007..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-expat: Update libexpat from 2.2.3 to 2.2.4. Fix copying of partial
-characters for UTF-8 input (libexpat bug 115):
-https://github.com/libexpat/libexpat/issues/115
diff --git a/Misc/NEWS.d/next/Library/README.rst b/Misc/NEWS.d/next/Library/README.rst
deleted file mode 100644 (file)
index 6d2d30e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Library* section in this directory.
diff --git a/Misc/NEWS.d/next/Security/README.rst b/Misc/NEWS.d/next/Security/README.rst
deleted file mode 100644 (file)
index 84c1a3a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Security* section in this directory.
diff --git a/Misc/NEWS.d/next/Tests/README.rst b/Misc/NEWS.d/next/Tests/README.rst
deleted file mode 100644 (file)
index d2e50e4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Tests* section in this directory.
diff --git a/Misc/NEWS.d/next/Tools-Demos/README.rst b/Misc/NEWS.d/next/Tools-Demos/README.rst
deleted file mode 100644 (file)
index 357f828..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Tools/Demos* section in this directory.
diff --git a/Misc/NEWS.d/next/Windows/README.rst b/Misc/NEWS.d/next/Windows/README.rst
deleted file mode 100644 (file)
index 1e65de3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *Windows* section in this directory.
diff --git a/Misc/NEWS.d/next/macOS/README.rst b/Misc/NEWS.d/next/macOS/README.rst
deleted file mode 100644 (file)
index a3adb59..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Put news entry ``blurb`` files for the *macOS* section in this directory.
index 1dd4b998100572b40d6ae22bfc73708d4a10c694..2e4da4c211f88f4c5b2e9890df4f4d1a97420450 100644 (file)
@@ -1271,6 +1271,8 @@ dequeiter_traverse(dequeiterobject *dio, visitproc visit, void *arg)
 static void
 dequeiter_dealloc(dequeiterobject *dio)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    PyObject_GC_UnTrack(dio);
     Py_XDECREF(dio->deque);
     PyObject_GC_Del(dio);
 }
@@ -1556,6 +1558,8 @@ static PyMemberDef defdict_members[] = {
 static void
 defdict_dealloc(defdictobject *dd)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    PyObject_GC_UnTrack(dd);
     Py_CLEAR(dd->default_factory);
     PyDict_Type.tp_dealloc((PyObject *)dd);
 }
index 4e192fb3ad28187e7429457d698a82705eb68b43..25740ed771212c20308a183e7fdd2df9d112c6df 100644 (file)
@@ -128,6 +128,12 @@ bytes(cdata)
 #endif
 #include "ctypes.h"
 
+/* Definition matching cfield.c:724 */
+#ifndef HAVE_C99_BOOL
+#undef SIZEOF__BOOL
+#define SIZEOF__BOOL 1
+#endif
+
 PyObject *PyExc_ArgError;
 
 /* This dict maps ctypes types to POINTER types */
@@ -292,6 +298,71 @@ PyDict_GetItemProxy(PyObject *dict, PyObject *key)
 }
 
 /******************************************************************/
+
+/*
+  Allocate a memory block for a pep3118 format string, filled with
+  a suitable PEP 3118 type code corresponding to the given ctypes
+  type. Returns NULL on failure, with the error indicator set.
+
+  This produces type codes in the standard size mode (cf. struct module),
+  since the endianness may need to be swapped to a non-native one
+  later on.
+ */
+static char *
+_ctypes_alloc_format_string_for_type(char code, int big_endian)
+{
+    char *result;
+    char pep_code = '\0';
+
+    switch (code) {
+#if SIZEOF_INT == 2
+    case 'i': pep_code = 'h'; break;
+    case 'I': pep_code = 'H'; break;
+#elif SIZEOF_INT == 4
+    case 'i': pep_code = 'i'; break;
+    case 'I': pep_code = 'I'; break;
+#elif SIZEOF_INT == 8
+    case 'i': pep_code = 'q'; break;
+    case 'I': pep_code = 'Q'; break;
+#else
+# error SIZEOF_INT has an unexpected value
+#endif /* SIZEOF_INT */
+#if SIZEOF_LONG == 4
+    case 'l': pep_code = 'l'; break;
+    case 'L': pep_code = 'L'; break;
+#elif SIZEOF_LONG == 8
+    case 'l': pep_code = 'q'; break;
+    case 'L': pep_code = 'Q'; break;
+#else
+# error SIZEOF_LONG has an unexpected value
+#endif /* SIZEOF_LONG */
+#if SIZEOF__BOOL == 1
+    case '?': pep_code = '?'; break;
+#elif SIZEOF__BOOL == 2
+    case '?': pep_code = 'H'; break;
+#elif SIZEOF__BOOL == 4
+    case '?': pep_code = 'L'; break;
+#elif SIZEOF__BOOL == 8
+    case '?': pep_code = 'Q'; break;
+#else
+# error SIZEOF__BOOL has an unexpected value
+#endif /* SIZEOF__BOOL */
+    default:
+        /* The standard-size code is the same as the ctypes one */
+        pep_code = code;
+        break;
+    }
+
+    result = PyMem_Malloc(3);
+    if (result == NULL)
+        return NULL;
+
+    result[0] = big_endian ? '>' : '<';
+    result[1] = pep_code;
+    result[2] = '\0';
+    return result;
+}
+
 /*
   Allocate a memory block for a pep3118 format string, copy prefix (if
   non-null) and suffix into it.  Returns NULL on failure, with the error
@@ -965,6 +1036,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     if (proto) {
         StgDictObject *itemdict = PyType_stgdict(proto);
         const char *current_format;
+        /* PyCPointerType_SetProto has verified proto has a stgdict. */
         assert(itemdict);
         /* If itemdict->format is NULL, then this is a pointer to an
            incomplete type.  We create a generic format string
@@ -1011,7 +1083,11 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
     StgDictObject *dict;
 
     dict = PyType_stgdict((PyObject *)self);
-    assert(dict);
+    if (!dict) {
+        PyErr_SetString(PyExc_TypeError,
+                        "abstract class");
+        return NULL;
+    }
 
     if (-1 == PyCPointerType_SetProto(dict, type))
         return NULL;
@@ -1037,7 +1113,11 @@ PyCPointerType_from_param(PyObject *type, PyObject *value)
     }
 
     typedict = PyType_stgdict(type);
-    assert(typedict); /* Cannot be NULL for pointer types */
+    if (!typedict) {
+        PyErr_SetString(PyExc_TypeError,
+                        "abstract class");
+        return NULL;
+    }
 
     /* If we expect POINTER(<type>), but receive a <type> instance, accept
        it by calling byref(<type>).
@@ -1999,9 +2079,9 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     stgdict->setfunc = fmt->setfunc;
     stgdict->getfunc = fmt->getfunc;
 #ifdef WORDS_BIGENDIAN
-    stgdict->format = _ctypes_alloc_format_string(">", proto_str);
+    stgdict->format = _ctypes_alloc_format_string_for_type(proto_str[0], 1);
 #else
-    stgdict->format = _ctypes_alloc_format_string("<", proto_str);
+    stgdict->format = _ctypes_alloc_format_string_for_type(proto_str[0], 0);
 #endif
     if (stgdict->format == NULL) {
         Py_DECREF(result);
@@ -2155,7 +2235,11 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
     }
 
     dict = PyType_stgdict(type);
-    assert(dict);
+    if (!dict) {
+        PyErr_SetString(PyExc_TypeError,
+                        "abstract class");
+        return NULL;
+    }
 
     /* I think we can rely on this being a one-character string */
     fmt = PyString_AsString(dict->proto);
@@ -2715,6 +2799,16 @@ PyCData_setstate(PyObject *_self, PyObject *args)
         len = self->b_size;
     memmove(self->b_ptr, data, len);
     mydict = PyObject_GetAttrString(_self, "__dict__");
+    if (mydict == NULL) {
+        return NULL;
+    }
+    if (!PyDict_Check(mydict)) {
+        PyErr_Format(PyExc_TypeError,
+                     "%.200s.__dict__ must be a dictionary, not %.200s",
+                     Py_TYPE(_self)->tp_name, Py_TYPE(mydict)->tp_name);
+        Py_DECREF(mydict);
+        return NULL;
+    }
     res = PyDict_Update(mydict, dict);
     Py_DECREF(mydict);
     if (res == -1)
@@ -3266,7 +3360,11 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
     PyObject *argtypes;
 
     dict = PyType_stgdict((PyObject *)type);
-    assert(dict); /* Cannot be NULL. 'type' is a PyCFuncPtr type. */
+    if (!dict) {
+        PyErr_SetString(PyExc_TypeError,
+                        "abstract class");
+        return 0;
+    }
     argtypes = dict->argtypes;
 
     if (paramflags == NULL || dict->argtypes == NULL)
@@ -5009,7 +5107,7 @@ Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
     }
 
     stgdict = PyObject_stgdict((PyObject *)self);
-    assert(stgdict); /* Cannot be NULL fr pointer instances */
+    assert(stgdict); /* Cannot be NULL for pointer instances */
 
     proto = stgdict->proto;
     assert(proto);
@@ -5037,7 +5135,7 @@ Pointer_get_contents(CDataObject *self, void *closure)
     }
 
     stgdict = PyObject_stgdict((PyObject *)self);
-    assert(stgdict); /* Cannot be NULL fr pointer instances */
+    assert(stgdict); /* Cannot be NULL for pointer instances */
     return PyCData_FromBaseObj(stgdict->proto,
                              (PyObject *)self, 0,
                              *(void **)self->b_ptr);
@@ -5056,7 +5154,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
         return -1;
     }
     stgdict = PyObject_stgdict((PyObject *)self);
-    assert(stgdict); /* Cannot be NULL fr pointer instances */
+    assert(stgdict); /* Cannot be NULL for pointer instances */
     assert(stgdict->proto);
     if (!CDataObject_Check(value)) {
         int res = PyObject_IsInstance(value, stgdict->proto);
index e033cd5fffe58b21c47e1f10c5e80b0bb40dbc28..6f632d0a072893ad3561c5c6fa056b738486c040 100644 (file)
@@ -205,7 +205,11 @@ PyCField_set(CFieldObject *self, PyObject *inst, PyObject *value)
 {
     CDataObject *dst;
     char *ptr;
-    assert(CDataObject_Check(inst));
+    if (!CDataObject_Check(inst)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "not a ctype instance");
+        return -1;
+    }
     dst = (CDataObject *)inst;
     ptr = dst->b_ptr + self->offset;
     if (value == NULL) {
@@ -225,7 +229,11 @@ PyCField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
         Py_INCREF(self);
         return (PyObject *)self;
     }
-    assert(CDataObject_Check(inst));
+    if (!CDataObject_Check(inst)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "not a ctype instance");
+        return NULL;
+    }
     src = (CDataObject *)inst;
     return PyCData_get(self->proto, self->getfunc, inst,
                      self->index, self->size, src->b_ptr + self->offset);
index b21fe92b044233f2aada0404b2d5292ac0b29ee6..12b56c4342f9444237e45ca4584acb1b4f66ebc2 100644 (file)
@@ -108,7 +108,7 @@ typedef struct {
     ffi_type *atypes[1];
 } CThunkObject;
 extern PyTypeObject PyCThunk_Type;
-#define CThunk_CheckExact(v)        ((v)->ob_type == &PyCThunk_Type)
+#define CThunk_CheckExact(v)        (Py_TYPE(v) == &PyCThunk_Type)
 
 typedef struct {
     /* First part identical to tagCDataObject */
index 90ce3e581c7e51509fecef066329125a7495694f..d1be3ca93e570e9a38339eb737012d37b09ccd9b 100644 (file)
@@ -286,7 +286,15 @@ MakeAnonFields(PyObject *type)
             Py_DECREF(anon_names);
             return -1;
         }
-        assert(Py_TYPE(descr) == &PyCField_Type);
+        if (Py_TYPE(descr) != &PyCField_Type) {
+            PyErr_Format(PyExc_AttributeError,
+                         "an item in _anonymous_ (index %zd) is not "
+                         "specified in _fields_",
+                         i);
+            Py_DECREF(anon_names);
+            Py_DECREF(descr);
+            return -1;
+        }
         descr->anonymous = 1;
 
         /* descr is in the field descriptor. */
index 9eab741a01d37e43ba00e87cc46c19b3466e3c50..935712a0bed78f802468fed16c3652f8d94c4ca4 100644 (file)
@@ -113,13 +113,13 @@ char *PyCursesVersion = "2.2";
 #define CURSES_MODULE
 #include "py_curses.h"
 
-/*  These prototypes are in <term.h>, but including this header
-    #defines many common symbols (such as "lines") which breaks the
-    curses module in other ways.  So the code will just specify
-    explicit prototypes here. */
-extern int setupterm(char *,int,int *);
-#ifdef __sgi
+#if defined(HAVE_TERM_H) || defined(__sgi)
+/* For termname, longname, putp, tigetflag, tigetnum, tigetstr, tparm
+   which are not declared in SysV curses and for setupterm. */
 #include <term.h>
+/* Including <term.h> #defines many common symbols. */
+#undef lines
+#undef columns
 #endif
 
 #if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5))
@@ -314,7 +314,9 @@ Window_NoArgNoReturnVoidFunction(wclrtobot)
 Window_NoArgNoReturnVoidFunction(wclear)
 
 Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)")
+#ifdef HAVE_CURSES_IMMEDOK
 Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)")
+#endif
 Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay")
 
 Window_NoArg2TupleReturnFunction(getyx, int, "ii")
@@ -324,21 +326,15 @@ Window_NoArg2TupleReturnFunction(getparyx, int, "ii")
 
 Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)")
 Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)")
-#if defined(__NetBSD__)
-Window_OneArgNoReturnVoidFunction(keypad, int, "i;True(1) or False(0)")
-#else
 Window_OneArgNoReturnFunction(keypad, int, "i;True(1) or False(0)")
-#endif
 Window_OneArgNoReturnFunction(leaveok, int, "i;True(1) or False(0)")
-#if defined(__NetBSD__)
-Window_OneArgNoReturnVoidFunction(nodelay, int, "i;True(1) or False(0)")
-#else
 Window_OneArgNoReturnFunction(nodelay, int, "i;True(1) or False(0)")
-#endif
 Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)")
 Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)")
 Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines")
+#ifdef HAVE_CURSES_SYNCOK
 Window_OneArgNoReturnFunction(syncok, int, "i;True(1) or False(0)")
+#endif
 
 Window_TwoArgNoReturnFunction(mvwin, int, "ii;y,x")
 Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x")
@@ -643,12 +639,19 @@ PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args)
 static PyObject *
 PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args)
 {
+    PyObject *temp1, *temp2;
     chtype ch1=0,ch2=0;
     switch(PyTuple_Size(args)){
     case 0: break;
     default:
-        if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2))
+        if (!PyArg_ParseTuple(args,"OO;verch,horch", &temp1, &temp2))
             return NULL;
+        if (!PyCurses_ConvertToChtype(temp1, &ch1)) {
+            return NULL;
+        }
+        if (!PyCurses_ConvertToChtype(temp2, &ch2)) {
+            return NULL;
+        }
     }
     box(self->win,ch1,ch2);
     Py_INCREF(Py_None);
@@ -667,8 +670,14 @@ int py_mvwdelch(WINDOW *w, int y, int x)
 }
 #endif
 
-/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
+#if defined(HAVE_CURSES_IS_PAD)
+#define py_is_pad(win)      is_pad(win)
+#elif defined(WINDOW_HAS_FLAGS)
+#define py_is_pad(win)      ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
+#endif
 
+/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
+#ifdef HAVE_CURSES_WCHGAT
 static PyObject *
 PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
 {
@@ -721,7 +730,7 @@ PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
     }
     return PyCursesCheckERR(rtn, "chgat");
 }
-
+#endif
 
 static PyObject *
 PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
@@ -808,10 +817,11 @@ PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
         return NULL;
     }
 
-#ifdef WINDOW_HAS_FLAGS
-    if (self->win->_flags & _ISPAD)
+#ifdef py_is_pad
+    if (py_is_pad(self->win)) {
         return PyCursesCheckERR(pechochar(self->win, ch | attr),
                                 "echochar");
+    }
     else
 #endif
         return PyCursesCheckERR(wechochar(self->win, ch | attr),
@@ -894,12 +904,7 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
     } else if (rtn<=255) {
         return Py_BuildValue("c", rtn);
     } else {
-        const char *knp;
-#if defined(__NetBSD__)
-        knp = unctrl(rtn);
-#else
-        knp = keyname(rtn);
-#endif
+        const char *knp = keyname(rtn);
         return PyString_FromString((knp == NULL) ? "" : knp);
     }
 }
@@ -1044,7 +1049,7 @@ PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
         use_xy = TRUE;
         break;
     default:
-        PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments");
+        PyErr_SetString(PyExc_TypeError, "insch requires 1 to 4 arguments");
         return NULL;
     }
 
@@ -1077,7 +1082,7 @@ PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args)
         rtn = mvwinch(self->win,y,x);
         break;
     default:
-        PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments");
+        PyErr_SetString(PyExc_TypeError, "inch requires 0 to 2 arguments");
         return NULL;
     }
     return PyInt_FromLong((long) rtn);
@@ -1252,10 +1257,10 @@ PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args)
     int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
     int rtn;
 
-#ifndef WINDOW_HAS_FLAGS
+#ifndef py_is_pad
     if (0)
 #else
-        if (self->win->_flags & _ISPAD)
+        if (py_is_pad(self->win))
 #endif
         {
             switch(PyTuple_Size(args)) {
@@ -1395,10 +1400,10 @@ PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args)
     int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
     int rtn;
 
-#ifndef WINDOW_HAS_FLAGS
+#ifndef py_is_pad
     if (0)
 #else
-        if (self->win->_flags & _ISPAD)
+        if (py_is_pad(self->win))
 #endif
         {
             switch(PyTuple_Size(args)) {
@@ -1464,9 +1469,10 @@ PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args)
     }
 
     /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
-#ifdef WINDOW_HAS_FLAGS
-    if (self->win->_flags & _ISPAD)
+#ifdef py_is_pad
+    if (py_is_pad(self->win)) {
         win = subpad(self->win, nlines, ncols, begin_y, begin_x);
+    }
     else
 #endif
         win = subwin(self->win, nlines, ncols, begin_y, begin_x);
@@ -1570,7 +1576,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
     {"attron",          (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
     {"attrset",         (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
     {"bkgd",            (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
+#ifdef HAVE_CURSES_WCHGAT
     {"chgat",           (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
+#endif
     {"bkgdset",         (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
     {"border",          (PyCFunction)PyCursesWindow_Border, METH_VARARGS},
     {"box",             (PyCFunction)PyCursesWindow_Box, METH_VARARGS},
@@ -1598,7 +1606,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
     {"hline",           (PyCFunction)PyCursesWindow_Hline, METH_VARARGS},
     {"idcok",           (PyCFunction)PyCursesWindow_idcok, METH_VARARGS},
     {"idlok",           (PyCFunction)PyCursesWindow_idlok, METH_VARARGS},
+#ifdef HAVE_CURSES_IMMEDOK
     {"immedok",         (PyCFunction)PyCursesWindow_immedok, METH_VARARGS},
+#endif
     {"inch",            (PyCFunction)PyCursesWindow_InCh, METH_VARARGS},
     {"insch",           (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS},
     {"insdelln",        (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS},
@@ -1636,7 +1646,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
     {"subpad",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
     {"subwin",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
     {"syncdown",        (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS},
+#ifdef HAVE_CURSES_SYNCOK
     {"syncok",          (PyCFunction)PyCursesWindow_syncok, METH_VARARGS},
+#endif
     {"syncup",          (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS},
     {"timeout",         (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS},
     {"touchline",       (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS},
@@ -1710,6 +1722,7 @@ NoArgTrueFalseFunction(isendwin)
 NoArgNoReturnVoidFunction(flushinp)
 NoArgNoReturnVoidFunction(noqiflush)
 
+#ifdef HAVE_CURSES_FILTER
 static PyObject *
 PyCurses_filter(PyObject *self)
 {
@@ -1719,6 +1732,7 @@ PyCurses_filter(PyObject *self)
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 static PyObject *
 PyCurses_Color_Content(PyObject *self, PyObject *args)
@@ -1790,6 +1804,7 @@ PyCurses_EraseChar(PyObject *self)
     return PyString_FromStringAndSize(&ch, 1);
 }
 
+#ifdef getsyx
 static PyObject *
 PyCurses_getsyx(PyObject *self)
 {
@@ -1802,6 +1817,7 @@ PyCurses_getsyx(PyObject *self)
 
     return Py_BuildValue("(ii)", y, x);
 }
+#endif
 
 #ifdef NCURSES_MOUSE_VERSION
 static PyObject *
@@ -1817,24 +1833,30 @@ PyCurses_GetMouse(PyObject *self)
         PyErr_SetString(PyCursesError, "getmouse() returned ERR");
         return NULL;
     }
-    return Py_BuildValue("(hiiil)",
+    return Py_BuildValue("(hiiik)",
                          (short)event.id,
-                         event.x, event.y, event.z,
-                         (long) event.bstate);
+                         (int)event.x, (int)event.y, (int)event.z,
+                         (unsigned long) event.bstate);
 }
 
 static PyObject *
 PyCurses_UngetMouse(PyObject *self, PyObject *args)
 {
     MEVENT event;
+    short id;
+    int x, y, z;
+    unsigned long bstate;
 
     PyCursesInitialised;
-    if (!PyArg_ParseTuple(args, "hiiil",
-                          &event.id,
-                          &event.x, &event.y, &event.z,
-                          (int *) &event.bstate))
+    if (!PyArg_ParseTuple(args, "hiiik",
+                          &id, &x, &y, &z, &bstate))
         return NULL;
 
+    event.id = id;
+    event.x = x;
+    event.y = y;
+    event.z = z;
+    event.bstate = bstate;
     return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
 }
 #endif
@@ -1873,9 +1895,9 @@ PyCurses_HalfDelay(PyObject *self, PyObject *args)
     return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
 }
 
-#ifndef STRICT_SYSV_CURSES
-/* No has_key! */
-static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
+#ifdef HAVE_CURSES_HAS_KEY
+static PyObject *
+PyCurses_has_key(PyObject *self, PyObject *args)
 {
     int ch;
 
@@ -1890,7 +1912,7 @@ static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
     Py_INCREF(Py_True);
     return Py_True;
 }
-#endif /* STRICT_SYSV_CURSES */
+#endif
 
 static PyObject *
 PyCurses_Init_Color(PyObject *self, PyObject *args)
@@ -2128,7 +2150,6 @@ PyCurses_Is_Term_Resized(PyObject *self, PyObject *args)
 }
 #endif /* HAVE_CURSES_IS_TERM_RESIZED */
 
-#if !defined(__NetBSD__)
 static PyObject *
 PyCurses_KeyName(PyObject *self, PyObject *args)
 {
@@ -2147,7 +2168,6 @@ PyCurses_KeyName(PyObject *self, PyObject *args)
 
     return PyString_FromString((knp == NULL) ? "" : (char *)knp);
 }
-#endif
 
 static PyObject *
 PyCurses_KillChar(PyObject *self)
@@ -2193,14 +2213,15 @@ PyCurses_MouseInterval(PyObject *self, PyObject *args)
 static PyObject *
 PyCurses_MouseMask(PyObject *self, PyObject *args)
 {
-    int newmask;
+    unsigned long newmask;
     mmask_t oldmask, availmask;
 
     PyCursesInitialised;
-    if (!PyArg_ParseTuple(args,"i;mousemask",&newmask))
+    if (!PyArg_ParseTuple(args,"k;mousemask",&newmask))
         return NULL;
-    availmask = mousemask(newmask, &oldmask);
-    return Py_BuildValue("(ll)", (long)availmask, (long)oldmask);
+    availmask = mousemask((mmask_t)newmask, &oldmask);
+    return Py_BuildValue("(kk)",
+                         (unsigned long)availmask, (unsigned long)oldmask);
 }
 #endif
 
@@ -2443,6 +2464,7 @@ PyCurses_Resize_Term(PyObject *self, PyObject *args)
 }
 #endif /* HAVE_CURSES_RESIZE_TERM */
 
+#ifdef getsyx
 static PyObject *
 PyCurses_setsyx(PyObject *self, PyObject *args)
 {
@@ -2462,6 +2484,7 @@ PyCurses_setsyx(PyObject *self, PyObject *args)
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 static PyObject *
 PyCurses_Start_Color(PyObject *self)
@@ -2556,6 +2579,7 @@ PyCurses_tparm(PyObject *self, PyObject *args)
     return PyString_FromString(result);
 }
 
+#ifdef HAVE_CURSES_TYPEAHEAD
 static PyObject *
 PyCurses_TypeAhead(PyObject *self, PyObject *args)
 {
@@ -2567,6 +2591,7 @@ PyCurses_TypeAhead(PyObject *self, PyObject *args)
 
     return PyCursesCheckERR(typeahead( fd ), "typeahead");
 }
+#endif
 
 static PyObject *
 PyCurses_UnCtrl(PyObject *self, PyObject *args)
@@ -2618,6 +2643,7 @@ PyCurses_UngetCh(PyObject *self, PyObject *args)
     return PyCursesCheckERR(ungetch(ch), "ungetch");
 }
 
+#ifdef HAVE_CURSES_TYPEAHEAD
 static PyObject *
 PyCurses_Use_Env(PyObject *self, PyObject *args)
 {
@@ -2636,6 +2662,7 @@ PyCurses_Use_Env(PyObject *self, PyObject *args)
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 #ifndef STRICT_SYSV_CURSES
 static PyObject *
@@ -2674,19 +2701,23 @@ static PyMethodDef PyCurses_methods[] = {
     {"echo",                (PyCFunction)PyCurses_echo, METH_VARARGS},
     {"endwin",              (PyCFunction)PyCurses_endwin, METH_NOARGS},
     {"erasechar",           (PyCFunction)PyCurses_EraseChar, METH_NOARGS},
+#ifdef HAVE_CURSES_FILTER
     {"filter",              (PyCFunction)PyCurses_filter, METH_NOARGS},
+#endif
     {"flash",               (PyCFunction)PyCurses_flash, METH_NOARGS},
     {"flushinp",            (PyCFunction)PyCurses_flushinp, METH_NOARGS},
 #ifdef NCURSES_MOUSE_VERSION
     {"getmouse",            (PyCFunction)PyCurses_GetMouse, METH_NOARGS},
     {"ungetmouse",          (PyCFunction)PyCurses_UngetMouse, METH_VARARGS},
 #endif
+#ifdef getsyx
     {"getsyx",              (PyCFunction)PyCurses_getsyx, METH_NOARGS},
+#endif
     {"getwin",              (PyCFunction)PyCurses_GetWin, METH_O},
     {"has_colors",          (PyCFunction)PyCurses_has_colors, METH_NOARGS},
     {"has_ic",              (PyCFunction)PyCurses_has_ic, METH_NOARGS},
     {"has_il",              (PyCFunction)PyCurses_has_il, METH_NOARGS},
-#ifndef STRICT_SYSV_CURSES
+#ifdef HAVE_CURSES_HAS_KEY
     {"has_key",             (PyCFunction)PyCurses_has_key, METH_VARARGS},
 #endif
     {"halfdelay",           (PyCFunction)PyCurses_HalfDelay, METH_VARARGS},
@@ -2698,9 +2729,7 @@ static PyMethodDef PyCurses_methods[] = {
 #ifdef HAVE_CURSES_IS_TERM_RESIZED
     {"is_term_resized",     (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS},
 #endif
-#if !defined(__NetBSD__)
     {"keyname",             (PyCFunction)PyCurses_KeyName, METH_VARARGS},
-#endif
     {"killchar",            (PyCFunction)PyCurses_KillChar, METH_NOARGS},
     {"longname",            (PyCFunction)PyCurses_longname, METH_NOARGS},
     {"meta",                (PyCFunction)PyCurses_Meta, METH_VARARGS},
@@ -2732,7 +2761,9 @@ static PyMethodDef PyCurses_methods[] = {
     {"resize_term",         (PyCFunction)PyCurses_Resize_Term, METH_VARARGS},
 #endif
     {"savetty",             (PyCFunction)PyCurses_savetty, METH_NOARGS},
+#ifdef getsyx
     {"setsyx",              (PyCFunction)PyCurses_setsyx, METH_VARARGS},
+#endif
     {"setupterm",           (PyCFunction)PyCurses_setupterm,
      METH_VARARGS|METH_KEYWORDS},
     {"start_color",         (PyCFunction)PyCurses_Start_Color, METH_NOARGS},
@@ -2742,10 +2773,14 @@ static PyMethodDef PyCurses_methods[] = {
     {"tigetnum",            (PyCFunction)PyCurses_tigetnum, METH_VARARGS},
     {"tigetstr",            (PyCFunction)PyCurses_tigetstr, METH_VARARGS},
     {"tparm",               (PyCFunction)PyCurses_tparm, METH_VARARGS},
+#ifdef HAVE_CURSES_TYPEAHEAD
     {"typeahead",           (PyCFunction)PyCurses_TypeAhead, METH_VARARGS},
+#endif
     {"unctrl",              (PyCFunction)PyCurses_UnCtrl, METH_VARARGS},
     {"ungetch",             (PyCFunction)PyCurses_UngetCh, METH_VARARGS},
+#ifdef HAVE_CURSES_USE_ENV
     {"use_env",             (PyCFunction)PyCurses_Use_Env, METH_VARARGS},
+#endif
 #ifndef STRICT_SYSV_CURSES
     {"use_default_colors",  (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS},
 #endif
@@ -2809,9 +2844,7 @@ init_curses(void)
     SetDictInt("A_DIM",                 A_DIM);
     SetDictInt("A_BOLD",                A_BOLD);
     SetDictInt("A_ALTCHARSET",          A_ALTCHARSET);
-#if !defined(__NetBSD__)
     SetDictInt("A_INVIS",           A_INVIS);
-#endif
     SetDictInt("A_PROTECT",         A_PROTECT);
     SetDictInt("A_CHARTEXT",        A_CHARTEXT);
     SetDictInt("A_COLOR",           A_COLOR);
@@ -2883,7 +2916,6 @@ init_curses(void)
         int key;
         char *key_n;
         char *key_n2;
-#if !defined(__NetBSD__)
         for (key=KEY_MIN;key < KEY_MAX; key++) {
             key_n = (char *)keyname(key);
             if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0)
@@ -2911,7 +2943,6 @@ init_curses(void)
             if (key_n2 != key_n)
                 free(key_n2);
         }
-#endif
         SetDictInt("KEY_MIN", KEY_MIN);
         SetDictInt("KEY_MAX", KEY_MAX);
     }
index 929616f3e2e5b7dbcc3c97b5cfc9d7ed490af5a0..1d316a1c91d24b0836a436b616a74fb2ab12ca8c 100644 (file)
@@ -131,6 +131,15 @@ static PyObject* elementpath_obj;
 
 /* helpers */
 
+/* Py_SETREF for a PyObject* that uses a join flag. */
+Py_LOCAL_INLINE(void)
+_set_joined_ptr(PyObject **p, PyObject *new_joined_ptr)
+{
+    PyObject *tmp = JOIN_OBJ(*p);
+    *p = new_joined_ptr;
+    Py_DECREF(tmp);
+}
+
 LOCAL(PyObject*)
 deepcopy(PyObject* object, PyObject* memo)
 {
@@ -585,12 +594,10 @@ element_clear(ElementObject* self, PyObject* args)
     }
 
     Py_INCREF(Py_None);
-    Py_DECREF(JOIN_OBJ(self->text));
-    self->text = Py_None;
+    _set_joined_ptr(&self->text, Py_None);
 
     Py_INCREF(Py_None);
-    Py_DECREF(JOIN_OBJ(self->tail));
-    self->tail = Py_None;
+    _set_joined_ptr(&self->tail, Py_None);
 
     Py_RETURN_NONE;
 }
@@ -610,13 +617,11 @@ element_copy(ElementObject* self, PyObject* args)
     if (!element)
         return NULL;
 
-    Py_DECREF(JOIN_OBJ(element->text));
-    element->text = self->text;
-    Py_INCREF(JOIN_OBJ(element->text));
+    Py_INCREF(JOIN_OBJ(self->text));
+    _set_joined_ptr(&element->text, self->text);
 
-    Py_DECREF(JOIN_OBJ(element->tail));
-    element->tail = self->tail;
-    Py_INCREF(JOIN_OBJ(element->tail));
+    Py_INCREF(JOIN_OBJ(self->tail));
+    _set_joined_ptr(&element->tail, self->tail);
 
     if (self->extra) {
         
@@ -678,14 +683,12 @@ element_deepcopy(ElementObject* self, PyObject* args)
     text = deepcopy(JOIN_OBJ(self->text), memo);
     if (!text)
         goto error;
-    Py_DECREF(element->text);
-    element->text = JOIN_SET(text, JOIN_GET(self->text));
+    _set_joined_ptr(&element->text, JOIN_SET(text, JOIN_GET(self->text)));
 
     tail = deepcopy(JOIN_OBJ(self->tail), memo);
     if (!tail)
         goto error;
-    Py_DECREF(element->tail);
-    element->tail = JOIN_SET(tail, JOIN_GET(self->tail));
+    _set_joined_ptr(&element->tail, JOIN_SET(tail, JOIN_GET(self->tail)));
 
     if (self->extra) {
         
@@ -1624,13 +1627,11 @@ element_setattr(ElementObject* self, const char* name, PyObject* value)
         Py_INCREF(value);
         Py_SETREF(self->tag, value);
     } else if (strcmp(name, "text") == 0) {
-        Py_DECREF(JOIN_OBJ(self->text));
-        self->text = value;
-        Py_INCREF(self->text);
+        Py_INCREF(value);
+        _set_joined_ptr(&self->text, value);
     } else if (strcmp(name, "tail") == 0) {
-        Py_DECREF(JOIN_OBJ(self->tail));
-        self->tail = value;
-        Py_INCREF(self->tail);
+        Py_INCREF(value);
+        _set_joined_ptr(&self->tail, value);
     } else if (strcmp(name, "attrib") == 0) {
         if (!self->extra)
             element_new_extra(self, NULL);
@@ -1661,8 +1662,8 @@ static PyMappingMethods element_as_mapping = {
 };
 
 statichere PyTypeObject Element_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0, "Element", sizeof(ElementObject), 0,
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "Element", sizeof(ElementObject), 0,
     /* methods */
     (destructor)element_dealloc, /* tp_dealloc */
     0, /* tp_print */
@@ -2031,8 +2032,8 @@ treebuilder_getattr(TreeBuilderObject* self, char* name)
 }
 
 statichere PyTypeObject TreeBuilder_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0, "TreeBuilder", sizeof(TreeBuilderObject), 0,
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "TreeBuilder", sizeof(TreeBuilderObject), 0,
     /* methods */
     (destructor)treebuilder_dealloc, /* tp_dealloc */
     0, /* tp_print */
@@ -2509,6 +2510,18 @@ expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
 /* -------------------------------------------------------------------- */
 /* constructor and destructor */
 
+static int
+ignore_attribute_error(PyObject *value)
+{
+    if (value == NULL) {
+        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+            return -1;
+        }
+        PyErr_Clear();
+    }
+    return 0;
+}
+
 static PyObject*
 xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
 {
@@ -2562,14 +2575,24 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
         return NULL;
     }
 
+    ALLOC(sizeof(XMLParserObject), "create expatparser");
+
+    /* Init to NULL to keep the error handling below manageable. */
+    self->target =
+        self->handle_xml =
+        self->handle_start =
+        self->handle_data =
+        self->handle_end =
+        self->handle_comment =
+        self->handle_pi =
+        self->handle_close =
+        NULL;
+
     /* setup target handlers */
     if (!target) {
         target = treebuilder_new();
         if (!target) {
-            EXPAT(ParserFree)(self->parser);
-            PyObject_Del(self->names);
-            PyObject_Del(self->entity);
-            PyObject_Del(self);
+            Py_DECREF(self);
             return NULL;
         }
     } else
@@ -2577,14 +2600,40 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
     self->target = target;
 
     self->handle_xml = PyObject_GetAttrString(target, "xml");
+    if (ignore_attribute_error(self->handle_xml)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_start = PyObject_GetAttrString(target, "start");
+    if (ignore_attribute_error(self->handle_start)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_data = PyObject_GetAttrString(target, "data");
+    if (ignore_attribute_error(self->handle_data)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_end = PyObject_GetAttrString(target, "end");
+    if (ignore_attribute_error(self->handle_end)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_comment = PyObject_GetAttrString(target, "comment");
+    if (ignore_attribute_error(self->handle_comment)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_pi = PyObject_GetAttrString(target, "pi");
+    if (ignore_attribute_error(self->handle_pi)) {
+        Py_DECREF(self);
+        return NULL;
+    }
     self->handle_close = PyObject_GetAttrString(target, "close");
-
-    PyErr_Clear();
+    if (ignore_attribute_error(self->handle_close)) {
+        Py_DECREF(self);
+        return NULL;
+    }
 
     /* configure parser */
     EXPAT(SetUserData)(self->parser, self);
@@ -2618,8 +2667,6 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
         );
 #endif
 
-    ALLOC(sizeof(XMLParserObject), "create expatparser");
-
     return (PyObject*) self;
 }
 
@@ -2897,8 +2944,8 @@ xmlparser_getattr(XMLParserObject* self, char* name)
 }
 
 statichere PyTypeObject XMLParser_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0, "XMLParser", sizeof(XMLParserObject), 0,
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "XMLParser", sizeof(XMLParserObject), 0,
     /* methods */
     (destructor)xmlparser_dealloc, /* tp_dealloc */
     0, /* tp_print */
index e0781a98d5e5b0ffe5aad2fd3ee27dc18689639e..e9e89331b993e5c73faebeac7a79d985d642ab6f 100644 (file)
@@ -143,6 +143,7 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 static void
 partial_dealloc(partialobject *pto)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
     PyObject_GC_UnTrack(pto);
     if (pto->weakreflist != NULL)
         PyObject_ClearWeakRefs((PyObject *) pto);
index 75b3a3d3b6c5d41faaa95b1672e23ecf1e8be770..de69f6fcd037669e3c96fbd3b89e5ce03a82c08f 100644 (file)
@@ -899,8 +899,11 @@ init_hashlib(void)
 {
     PyObject *m, *openssl_md_meth_names;
 
-    OpenSSL_add_all_digests();
+#ifndef OPENSSL_VERSION_1_1
+    /* Load all digest algorithms and initialize cpuid */
+    OPENSSL_add_all_algorithms_noconf();
     ERR_load_crypto_strings();
+#endif
 
     /* TODO build EVP_functions openssl_* entries dynamically based
      * on what hashes are supported rather than listing many
index 1335ae89032260ba7f807ba39174f418639b23bc..0ee4b80434c8043b0e5740f8d3a6ed8939ec2e61 100644 (file)
@@ -745,6 +745,7 @@ bytesio_setstate(bytesio *self, PyObject *state)
 static void
 bytesio_dealloc(bytesio *self)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
     _PyObject_GC_UNTRACK(self);
     if (self->buf != NULL) {
         PyMem_Free(self->buf);
index 4a71a57ec0dea4cd1a4f24762f63a7db1d2762aa..2b40ada195a1f5fd982772e5b4861826e50ac512 100644 (file)
@@ -146,9 +146,15 @@ dircheck(fileio* self, PyObject *nameobj)
 {
 #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
     struct stat buf;
+    int res;
     if (self->fd < 0)
         return 0;
-    if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) {
+
+    Py_BEGIN_ALLOW_THREADS
+    res = fstat(self->fd, &buf);
+    Py_END_ALLOW_THREADS
+
+    if (res == 0 && S_ISDIR(buf.st_mode)) {
         errno = EISDIR;
         PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj);
         return -1;
@@ -162,17 +168,34 @@ check_fd(int fd)
 {
 #if defined(HAVE_FSTAT)
     struct stat buf;
-    if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) {
-        PyObject *exc;
-        char *msg = strerror(EBADF);
-        exc = PyObject_CallFunction(PyExc_OSError, "(is)",
-                                    EBADF, msg);
-        PyErr_SetObject(PyExc_OSError, exc);
-        Py_XDECREF(exc);
-        return -1;
+    int res;
+    PyObject *exc;
+    char *msg;
+
+    if (!_PyVerify_fd(fd)) {
+        goto badfd;
     }
-#endif
+
+    Py_BEGIN_ALLOW_THREADS
+    res = fstat(fd, &buf);
+    Py_END_ALLOW_THREADS
+
+    if (res < 0 && errno == EBADF) {
+        goto badfd;
+    }
+
     return 0;
+
+badfd:
+    msg = strerror(EBADF);
+    exc = PyObject_CallFunction(PyExc_OSError, "(is)",
+                                EBADF, msg);
+    PyErr_SetObject(PyExc_OSError, exc);
+    Py_XDECREF(exc);
+    return -1;
+#else
+    return 0;
+#endif
 }
 
 
@@ -519,9 +542,19 @@ new_buffersize(fileio *self, size_t currentsize)
 #ifdef HAVE_FSTAT
     off_t pos, end;
     struct stat st;
-    if (fstat(self->fd, &st) == 0) {
+    int res;
+
+    Py_BEGIN_ALLOW_THREADS
+    res = fstat(self->fd, &st);
+    Py_END_ALLOW_THREADS
+
+    if (res == 0) {
         end = st.st_size;
+
+        Py_BEGIN_ALLOW_THREADS
         pos = lseek(self->fd, 0L, SEEK_CUR);
+        Py_END_ALLOW_THREADS
+
         /* Files claiming a size smaller than SMALLCHUNK may
            actually be streaming pseudo-files. In this case, we
            apply the more aggressive algorithm below.
index f13dcb4366e06f78fbd6e3d32119101e0d01eecf..bf37f72bd11f26a788fc4310e5afd9cbecf4f7fc 100644 (file)
@@ -907,6 +907,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
     else {
         PyErr_SetString(PyExc_IOError,
                         "could not determine default encoding");
+        goto error;
     }
 
     /* Check we have been asked for a real text encoding */
@@ -1416,7 +1417,7 @@ textiowrapper_read_chunk(textio *self)
         /* Given this, we know there was a valid snapshot point
          * len(dec_buffer) bytes ago with decoder state (b'', dec_flags).
          */
-        if (PyArg_Parse(state, "(OO)", &dec_buffer, &dec_flags) < 0) {
+        if (!PyArg_Parse(state, "(OO)", &dec_buffer, &dec_flags)) {
             Py_DECREF(state);
             return -1;
         }
index 42c93aba1e22a28a6e17b46e29ad44b75991f13a..39ec467b093ec2602e27f9a20d4dde6fa208ff45 100644 (file)
@@ -840,7 +840,8 @@ py_encode_basestring_ascii(PyObject* self UNUSED, PyObject *pystr)
 static void
 scanner_dealloc(PyObject *self)
 {
-    /* Deallocate scanner object */
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    PyObject_GC_UnTrack(self);
     scanner_clear(self);
     Py_TYPE(self)->tp_free(self);
 }
@@ -1766,8 +1767,7 @@ PyDoc_STRVAR(scanner_doc, "JSON scanner object");
 
 static
 PyTypeObject PyScannerType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                    /* tp_internal */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "_json.Scanner",       /* tp_name */
     sizeof(PyScannerObject), /* tp_basicsize */
     0,                    /* tp_itemsize */
@@ -2298,7 +2298,8 @@ bail:
 static void
 encoder_dealloc(PyObject *self)
 {
-    /* Deallocate Encoder */
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    PyObject_GC_UnTrack(self);
     encoder_clear(self);
     Py_TYPE(self)->tp_free(self);
 }
@@ -2342,8 +2343,7 @@ PyDoc_STRVAR(encoder_doc, "_iterencode(obj, _current_indent_level) -> iterable")
 
 static
 PyTypeObject PyEncoderType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                    /* tp_internal */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "_json.Encoder",       /* tp_name */
     sizeof(PyEncoderObject), /* tp_basicsize */
     0,                    /* tp_itemsize */
index 049c94db393812a75bf9c14358e3e81f1a472efe..6090c7dd23655648c9c147a35a595d39ae165026 100644 (file)
@@ -817,8 +817,7 @@ Profiler(custom_timer=None, time_unit=None, subcalls=True, builtins=True)\n\
 ");
 
 statichere PyTypeObject PyProfiler_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                      /* ob_size */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "_lsprof.Profiler",                     /* tp_name */
     sizeof(ProfilerObject),                 /* tp_basicsize */
     0,                                      /* tp_itemsize */
index 852b810ae21955788be157935564010c0d41098d..2e49db6ef7379a16e56286376452785188cf79be 100644 (file)
@@ -230,9 +230,15 @@ random_seed(RandomObject *self, PyObject *args)
     }
     /* If the arg is an int or long, use its absolute value; else use
      * the absolute value of its hash code.
+     * Calling int.__abs__() or long.__abs__() prevents calling arg.__abs__(),
+     * which might return an invalid value. See issue #31478.
      */
-    if (PyInt_Check(arg) || PyLong_Check(arg))
-        n = PyNumber_Absolute(arg);
+    if (PyInt_Check(arg)) {
+        n = PyInt_Type.tp_as_number->nb_absolute(arg);
+    }
+    else if (PyLong_Check(arg)) {
+        n = PyLong_Type.tp_as_number->nb_absolute(arg);
+    }
     else {
         long hash = PyObject_Hash(arg);
         if (hash == -1)
index 237d6e419a975c737a446d242fec3f4d871d6777..0603b4307b174c5063a7725ac5738bc968b48738 100644 (file)
@@ -293,7 +293,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
     Py_XDECREF(self->statements);
     Py_XDECREF(self->cursors);
 
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 /*
@@ -1106,8 +1106,8 @@ int pysqlite_check_thread(pysqlite_Connection* self)
     if (self->check_same_thread) {
         if (PyThread_get_thread_ident() != self->thread_ident) {
             PyErr_Format(pysqlite_ProgrammingError,
-                        "SQLite objects created in a thread can only be used in that same thread."
-                        "The object was created in thread id %ld and this is thread id %ld",
+                        "SQLite objects created in a thread can only be used in that same thread. "
+                        "The object was created in thread id %ld and this is thread id %ld.",
                         self->thread_ident, PyThread_get_thread_ident());
             return 0;
         }
index db360040e44770b69d1f70e2007eea6b59b754b0..b7c2d798da5950a807ecff4389d32daec04e2ba3 100644 (file)
@@ -78,21 +78,20 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
     }
 
     Py_INCREF(connection);
-    self->connection = connection;
-    self->statement = NULL;
-    self->next_row = NULL;
-    self->in_weakreflist = NULL;
+    Py_XSETREF(self->connection, connection);
+    Py_CLEAR(self->statement);
+    Py_CLEAR(self->next_row);
 
-    self->row_cast_map = PyList_New(0);
+    Py_XSETREF(self->row_cast_map, PyList_New(0));
     if (!self->row_cast_map) {
         return -1;
     }
 
     Py_INCREF(Py_None);
-    self->description = Py_None;
+    Py_XSETREF(self->description, Py_None);
 
     Py_INCREF(Py_None);
-    self->lastrowid= Py_None;
+    Py_XSETREF(self->lastrowid, Py_None);
 
     self->arraysize = 1;
     self->closed = 0;
@@ -101,7 +100,7 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
     self->rowcount = -1L;
 
     Py_INCREF(Py_None);
-    self->row_factory = Py_None;
+    Py_XSETREF(self->row_factory, Py_None);
 
     if (!pysqlite_check_thread(self->connection)) {
         return -1;
@@ -135,7 +134,7 @@ static void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
         PyObject_ClearWeakRefs((PyObject*)self);
     }
 
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject* _pysqlite_get_converter(PyObject* key)
@@ -1015,6 +1014,11 @@ PyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args)
 
 PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args)
 {
+    if (!self->connection) {
+        PyErr_SetString(pysqlite_ProgrammingError,
+                        "Base Cursor.__init__ not called.");
+        return NULL;
+    }
     if (!pysqlite_check_thread(self->connection) || !pysqlite_check_connection(self->connection)) {
         return NULL;
     }
index 6fd3affb09ab43f0a8bb1c2c1ecd762839d945df..94b3d5089cee107a7248452b8ed9fabcb64fb632 100644 (file)
@@ -2712,8 +2712,8 @@ static PyMemberDef pattern_members[] = {
 };
 
 statichere PyTypeObject Pattern_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0, "_" SRE_MODULE ".SRE_Pattern",
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "_" SRE_MODULE ".SRE_Pattern",
     sizeof(PatternObject), sizeof(SRE_CODE),
     (destructor)pattern_dealloc, /*tp_dealloc*/
     0,                                  /* tp_print */
@@ -3952,8 +3952,8 @@ static PyMemberDef scanner_members[] = {
 };
 
 statichere PyTypeObject Scanner_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0, "_" SRE_MODULE ".SRE_Scanner",
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "_" SRE_MODULE ".SRE_Scanner",
     sizeof(ScannerObject), 0,
     (destructor)scanner_dealloc, /*tp_dealloc*/
     0,                         /* tp_print */
index 45a1d0123109eba71fe2638bdcffa29402c4cb1c..d0ce913d3d899282709da55774e571ca9811274d 100644 (file)
 #include <sys/poll.h>
 #endif
 
+#ifndef MS_WINDOWS
+/* inet_pton */
+#include <arpa/inet.h>
+#endif
+
 /* Don't warn about deprecated functions */
 #ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -97,6 +102,12 @@ struct py_ssl_library_code {
 
 #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
 #  define OPENSSL_VERSION_1_1 1
+#  define PY_OPENSSL_1_1_API 1
+#endif
+
+/* LibreSSL 2.7.0 provides necessary OpenSSL 1.1.0 APIs */
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070000fL
+#  define PY_OPENSSL_1_1_API 1
 #endif
 
 /* Openssl comes with TLSv1.1 and TLSv1.2 between 1.0.0h and 1.0.1
@@ -118,24 +129,44 @@ struct py_ssl_library_code {
 #endif
 
 /* ALPN added in OpenSSL 1.0.2 */
-#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT)
-# define HAVE_ALPN
+#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
+# define HAVE_ALPN 1
+#else
+# define HAVE_ALPN 0
+#endif
+
+/* We cannot rely on OPENSSL_NO_NEXTPROTONEG because LibreSSL 2.6.1 dropped
+ * NPN support but did not set OPENSSL_NO_NEXTPROTONEG for compatibility
+ * reasons. The check for TLSEXT_TYPE_next_proto_neg works with
+ * OpenSSL 1.0.1+ and LibreSSL.
+ * OpenSSL 1.1.1-pre1 dropped NPN but still has TLSEXT_TYPE_next_proto_neg.
+ */
+#ifdef OPENSSL_NO_NEXTPROTONEG
+# define HAVE_NPN 0
+#elif (OPENSSL_VERSION_NUMBER >= 0x10101000L) && !defined(LIBRESSL_VERSION_NUMBER)
+# define HAVE_NPN 0
+#elif defined(TLSEXT_TYPE_next_proto_neg)
+# define HAVE_NPN 1
+#else
+# define HAVE_NPN 0
 #endif
 
 #ifndef INVALID_SOCKET /* MS defines this */
 #define INVALID_SOCKET (-1)
 #endif
 
-#ifdef OPENSSL_VERSION_1_1
-/* OpenSSL 1.1.0+ */
-#ifndef OPENSSL_NO_SSL2
-#define OPENSSL_NO_SSL2
-#endif
-#else /* OpenSSL < 1.1.0 */
-#if defined(WITH_THREAD)
+/* OpenSSL 1.0.2 and LibreSSL needs extra code for locking */
+#if !defined(OPENSSL_VERSION_1_1) && defined(WITH_THREAD)
 #define HAVE_OPENSSL_CRYPTO_LOCK
 #endif
 
+#if defined(OPENSSL_VERSION_1_1) && !defined(OPENSSL_NO_SSL2)
+#define OPENSSL_NO_SSL2
+#endif
+
+#ifndef PY_OPENSSL_1_1_API
+/* OpenSSL 1.1 API shims for OpenSSL < 1.1.0 and LibreSSL < 2.7.0 */
+
 #define TLS_method SSLv23_method
 
 static int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne)
@@ -178,7 +209,7 @@ static X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *store)
 {
     return store->param;
 }
-#endif /* OpenSSL < 1.1.0 or LibreSSL */
+#endif /* OpenSSL < 1.1.0 or LibreSSL < 2.7.0 */
 
 
 enum py_ssl_error {
@@ -280,11 +311,11 @@ static unsigned int _ssl_locks_count = 0;
 typedef struct {
     PyObject_HEAD
     SSL_CTX *ctx;
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN
     unsigned char *npn_protocols;
     int npn_protocols_len;
 #endif
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     unsigned char *alpn_protocols;
     int alpn_protocols_len;
 #endif
@@ -575,8 +606,42 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
     SSL_set_mode(self->ssl, mode);
 
 #if HAVE_SNI
-    if (server_hostname != NULL)
-        SSL_set_tlsext_host_name(self->ssl, server_hostname);
+    if (server_hostname != NULL) {
+/* Don't send SNI for IP addresses. We cannot simply use inet_aton() and
+ * inet_pton() here. inet_aton() may be linked weakly and inet_pton() isn't
+ * available on all platforms. Use OpenSSL's IP address parser. It's
+ * available since 1.0.2 and LibreSSL since at least 2.3.0. */
+        int send_sni = 1;
+#if OPENSSL_VERSION_NUMBER >= 0x10200000L
+        ASN1_OCTET_STRING *ip = a2i_IPADDRESS(server_hostname);
+        if (ip == NULL) {
+            send_sni = 1;
+            ERR_clear_error();
+        } else {
+            send_sni = 0;
+            ASN1_OCTET_STRING_free(ip);
+        }
+#elif defined(HAVE_INET_PTON)
+#ifdef ENABLE_IPV6
+       #define PySSL_MAX(x, y) (((x) > (y)) ? (x) : (y))
+        char packed[PySSL_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
+#else
+        char packed[sizeof(struct in_addr)];
+#endif /* ENABLE_IPV6 */
+        if (inet_pton(AF_INET, server_hostname, packed)) {
+            send_sni = 0;
+#ifdef ENABLE_IPV6
+        } else if(inet_pton(AF_INET6, server_hostname, packed)) {
+            send_sni = 0;
+#endif /* ENABLE_IPV6 */
+        } else {
+            send_sni = 1;
+        }
+#endif /* HAVE_INET_PTON */
+        if (send_sni) {
+            SSL_set_tlsext_host_name(self->ssl, server_hostname);
+        }
+    }
 #endif
 
     /* If the socket is in non-blocking mode or timeout mode, set the BIO
@@ -676,49 +741,67 @@ error:
 }
 
 static PyObject *
-_create_tuple_for_attribute (ASN1_OBJECT *name, ASN1_STRING *value) {
-
-    char namebuf[X509_NAME_MAXLEN];
+_asn1obj2py(const ASN1_OBJECT *name, int no_name)
+{
+    char buf[X509_NAME_MAXLEN];
+    char *namebuf = buf;
     int buflen;
-    PyObject *name_obj;
-    PyObject *value_obj;
-    PyObject *attr;
-    unsigned char *valuebuf = NULL;
+    PyObject *name_obj = NULL;
 
-    buflen = OBJ_obj2txt(namebuf, sizeof(namebuf), name, 0);
+    buflen = OBJ_obj2txt(namebuf, X509_NAME_MAXLEN, name, no_name);
     if (buflen < 0) {
         _setSSLError(NULL, 0, __FILE__, __LINE__);
-        goto fail;
+        return NULL;
     }
-    name_obj = PyString_FromStringAndSize(namebuf, buflen);
-    if (name_obj == NULL)
-        goto fail;
+    /* initial buffer is too small for oid + terminating null byte */
+    if (buflen > X509_NAME_MAXLEN - 1) {
+        /* make OBJ_obj2txt() calculate the required buflen */
+        buflen = OBJ_obj2txt(NULL, 0, name, no_name);
+        /* allocate len + 1 for terminating NULL byte */
+        namebuf = PyMem_Malloc(buflen + 1);
+        if (namebuf == NULL) {
+            PyErr_NoMemory();
+            return NULL;
+        }
+        buflen = OBJ_obj2txt(namebuf, buflen + 1, name, no_name);
+        if (buflen < 0) {
+            _setSSLError(NULL, 0, __FILE__, __LINE__);
+            goto done;
+        }
+    }
+    if (!buflen && no_name) {
+        Py_INCREF(Py_None);
+        name_obj = Py_None;
+    }
+    else {
+        name_obj = PyString_FromStringAndSize(namebuf, buflen);
+    }
+
+  done:
+    if (buf != namebuf) {
+        PyMem_Free(namebuf);
+    }
+    return name_obj;
+}
+
+static PyObject *
+_create_tuple_for_attribute(ASN1_OBJECT *name, ASN1_STRING *value)
+{
+    Py_ssize_t buflen;
+    unsigned char *valuebuf = NULL;
+    PyObject *attr, *value_obj;
 
     buflen = ASN1_STRING_to_UTF8(&valuebuf, value);
     if (buflen < 0) {
         _setSSLError(NULL, 0, __FILE__, __LINE__);
-        Py_DECREF(name_obj);
-        goto fail;
+        return NULL;
     }
     value_obj = PyUnicode_DecodeUTF8((char *) valuebuf,
                                      buflen, "strict");
+
+    attr = Py_BuildValue("NN", _asn1obj2py(name, 0), value_obj);
     OPENSSL_free(valuebuf);
-    if (value_obj == NULL) {
-        Py_DECREF(name_obj);
-        goto fail;
-    }
-    attr = PyTuple_New(2);
-    if (attr == NULL) {
-        Py_DECREF(name_obj);
-        Py_DECREF(value_obj);
-        goto fail;
-    }
-    PyTuple_SET_ITEM(attr, 0, name_obj);
-    PyTuple_SET_ITEM(attr, 1, value_obj);
     return attr;
-
-  fail:
-    return NULL;
 }
 
 static PyObject *
@@ -1502,7 +1585,7 @@ static PyObject *PySSL_version(PySSLSocket *self)
     return PyUnicode_FromString(version);
 }
 
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
 static PyObject *PySSL_selected_npn_protocol(PySSLSocket *self) {
     const unsigned char *out;
     unsigned int outlen;
@@ -1516,7 +1599,7 @@ static PyObject *PySSL_selected_npn_protocol(PySSLSocket *self) {
 }
 #endif
 
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
 static PyObject *PySSL_selected_alpn_protocol(PySSLSocket *self) {
     const unsigned char *out;
     unsigned int outlen;
@@ -2033,7 +2116,7 @@ static PyMethodDef PySSLMethods[] = {
 #ifdef OPENSSL_NPN_NEGOTIATED
     {"selected_npn_protocol", (PyCFunction)PySSL_selected_npn_protocol, METH_NOARGS},
 #endif
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     {"selected_alpn_protocol", (PyCFunction)PySSL_selected_alpn_protocol, METH_NOARGS},
 #endif
     {"compression", (PyCFunction)PySSL_compression, METH_NOARGS},
@@ -2128,8 +2211,7 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         return NULL;
     }
     if (ctx == NULL) {
-        PyErr_SetString(PySSLErrorObject,
-                        "failed to allocate SSL context");
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
         return NULL;
     }
 
@@ -2140,10 +2222,10 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         return NULL;
     }
     self->ctx = ctx;
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN
     self->npn_protocols = NULL;
 #endif
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     self->alpn_protocols = NULL;
 #endif
 #ifndef OPENSSL_NO_TLSEXT
@@ -2214,12 +2296,14 @@ context_clear(PySSLContext *self)
 static void
 context_dealloc(PySSLContext *self)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    PyObject_GC_UnTrack(self);
     context_clear(self);
     SSL_CTX_free(self->ctx);
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN
     PyMem_FREE(self->npn_protocols);
 #endif
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     PyMem_FREE(self->alpn_protocols);
 #endif
     Py_TYPE(self)->tp_free(self);
@@ -2246,7 +2330,7 @@ set_ciphers(PySSLContext *self, PyObject *args)
     Py_RETURN_NONE;
 }
 
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN || HAVE_ALPN
 static int
 do_protocol_selection(int alpn, unsigned char **out, unsigned char *outlen,
                       const unsigned char *server_protocols, unsigned int server_protocols_len,
@@ -2270,7 +2354,9 @@ do_protocol_selection(int alpn, unsigned char **out, unsigned char *outlen,
 
     return SSL_TLSEXT_ERR_OK;
 }
+#endif
 
+#if HAVE_NPN
 /* this callback gets passed to SSL_CTX_set_next_protos_advertise_cb */
 static int
 _advertiseNPN_cb(SSL *s,
@@ -2305,7 +2391,7 @@ _selectNPN_cb(SSL *s,
 static PyObject *
 _set_npn_protocols(PySSLContext *self, PyObject *args)
 {
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN
     Py_buffer protos;
 
     if (!PyArg_ParseTuple(args, "s*:set_npn_protocols", &protos))
@@ -2341,7 +2427,7 @@ _set_npn_protocols(PySSLContext *self, PyObject *args)
 #endif
 }
 
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
 static int
 _selectALPN_cb(SSL *s,
               const unsigned char **out, unsigned char *outlen,
@@ -2358,7 +2444,7 @@ _selectALPN_cb(SSL *s,
 static PyObject *
 _set_alpn_protocols(PySSLContext *self, PyObject *args)
 {
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     Py_buffer protos;
 
     if (!PyArg_ParseTuple(args, "s*:set_npn_protocols", &protos))
@@ -2962,13 +3048,25 @@ load_dh_params(PySSLContext *self, PyObject *filepath)
 {
     BIO *bio;
     DH *dh;
-    char *path = PyBytes_AsString(filepath);
-    if (!path) {
-        return NULL;
+    PyObject *filepath_bytes = NULL;
+
+    if (PyString_Check(filepath)) {
+        Py_INCREF(filepath);
+        filepath_bytes = filepath;
+    } else {
+        PyObject *u = PyUnicode_FromObject(filepath);
+        if (!u)
+            return NULL;
+        filepath_bytes = PyUnicode_AsEncodedString(
+            u, Py_FileSystemDefaultEncoding, NULL);
+        Py_DECREF(u);
+        if (!filepath_bytes)
+            return NULL;
     }
 
-    bio = BIO_new_file(path, "r");
+    bio = BIO_new_file(PyBytes_AS_STRING(filepath_bytes), "r");
     if (bio == NULL) {
+        Py_DECREF(filepath_bytes);
         ERR_clear_error();
         PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, filepath);
         return NULL;
@@ -2977,6 +3075,7 @@ load_dh_params(PySSLContext *self, PyObject *filepath)
     PySSL_BEGIN_ALLOW_THREADS
     dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
     BIO_free(bio);
+    Py_DECREF(filepath_bytes);
     PySSL_END_ALLOW_THREADS
     if (dh == NULL) {
         if (errno != 0) {
@@ -3572,8 +3671,6 @@ asn1obj2py(ASN1_OBJECT *obj)
 {
     int nid;
     const char *ln, *sn;
-    char buf[100];
-    Py_ssize_t buflen;
 
     nid = OBJ_obj2nid(obj);
     if (nid == NID_undef) {
@@ -3582,16 +3679,7 @@ asn1obj2py(ASN1_OBJECT *obj)
     }
     sn = OBJ_nid2sn(nid);
     ln = OBJ_nid2ln(nid);
-    buflen = OBJ_obj2txt(buf, sizeof(buf), obj, 1);
-    if (buflen < 0) {
-        _setSSLError(NULL, 0, __FILE__, __LINE__);
-        return NULL;
-    }
-    if (buflen) {
-        return Py_BuildValue("isss#", nid, sn, ln, buf, buflen);
-    } else {
-        return Py_BuildValue("issO", nid, sn, ln, Py_None);
-    }
+    return Py_BuildValue("issN", nid, sn, ln, _asn1obj2py(obj, 1));
 }
 
 PyDoc_STRVAR(PySSL_txt2obj_doc,
@@ -4080,9 +4168,14 @@ init_ssl(void)
     if (PySocketModule_ImportModuleAndAPI())
         return;
 
+#ifndef OPENSSL_VERSION_1_1
+    /* Load all algorithms and initialize cpuid */
+    OPENSSL_add_all_algorithms_noconf();
     /* Init OpenSSL */
     SSL_load_error_strings();
     SSL_library_init();
+#endif
+
 #ifdef WITH_THREAD
 #ifdef HAVE_OPENSSL_CRYPTO_LOCK
     /* note that this will start threading if not already started */
@@ -4094,7 +4187,6 @@ init_ssl(void)
     _ssl_locks_count++;
 #endif
 #endif  /* WITH_THREAD */
-    OpenSSL_add_all_algorithms();
 
     /* Add symbols to module dict */
     PySSLErrorObject = PyErr_NewExceptionWithDoc(
@@ -4267,6 +4359,11 @@ init_ssl(void)
 #if HAVE_TLSv1_2
     PyModule_AddIntConstant(m, "OP_NO_TLSv1_1", SSL_OP_NO_TLSv1_1);
     PyModule_AddIntConstant(m, "OP_NO_TLSv1_2", SSL_OP_NO_TLSv1_2);
+#endif
+#ifdef SSL_OP_NO_TLSv1_3
+    PyModule_AddIntConstant(m, "OP_NO_TLSv1_3", SSL_OP_NO_TLSv1_3);
+#else
+    PyModule_AddIntConstant(m, "OP_NO_TLSv1_3", 0);
 #endif
     PyModule_AddIntConstant(m, "OP_CIPHER_SERVER_PREFERENCE",
                             SSL_OP_CIPHER_SERVER_PREFERENCE);
@@ -4303,7 +4400,7 @@ init_ssl(void)
     Py_INCREF(r);
     PyModule_AddObject(m, "HAS_ECDH", r);
 
-#ifdef OPENSSL_NPN_NEGOTIATED
+#if HAVE_NPN
     r = Py_True;
 #else
     r = Py_False;
@@ -4311,7 +4408,7 @@ init_ssl(void)
     Py_INCREF(r);
     PyModule_AddObject(m, "HAS_NPN", r);
 
-#ifdef HAVE_ALPN
+#if HAVE_ALPN
     r = Py_True;
 #else
     r = Py_False;
@@ -4319,6 +4416,14 @@ init_ssl(void)
     Py_INCREF(r);
     PyModule_AddObject(m, "HAS_ALPN", r);
 
+#if defined(TLS1_3_VERSION) && !defined(OPENSSL_NO_TLS1_3)
+    r = Py_True;
+#else
+    r = Py_False;
+#endif
+    Py_INCREF(r);
+    PyModule_AddObject(m, "HAS_TLSv1_3", r);
+
     /* Mappings for error codes */
     err_codes_to_names = PyDict_New();
     err_names_to_codes = PyDict_New();
index a5e3f07667d07ace3304c5d8dbe468642a78ff8b..5902de078230de071656f824b78ae77e561cee5b 100644 (file)
@@ -187,8 +187,7 @@ test_dict_iteration(PyObject* self)
  *   PyType_Ready if it hasn't already been called
  */
 static PyTypeObject _HashInheritanceTester_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                          /* Number of items for varobject */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "hashinheritancetester",            /* Name of this type */
     sizeof(PyObject),           /* Basic object size */
     0,                          /* Item size for varobject */
@@ -315,8 +314,7 @@ static PyBufferProcs memoryviewtester_as_buffer = {
 };
 
 static PyTypeObject _MemoryViewTester_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                          /* Number of items for varobject */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "memoryviewtester",         /* Name of this type */
     sizeof(PyObject),           /* Basic object size */
     0,                          /* Item size for varobject */
@@ -911,8 +909,9 @@ test_L_code(PyObject *self)
     PyTuple_SET_ITEM(tuple, 0, num);
 
     value = -1;
-    if (PyArg_ParseTuple(tuple, "L:test_L_code", &value) < 0)
+    if (!PyArg_ParseTuple(tuple, "L:test_L_code", &value)) {
         return NULL;
+    }
     if (value != 42)
         return raiseTestError("test_L_code",
             "L code returned wrong value for long 42");
@@ -925,8 +924,9 @@ test_L_code(PyObject *self)
     PyTuple_SET_ITEM(tuple, 0, num);
 
     value = -1;
-    if (PyArg_ParseTuple(tuple, "L:test_L_code", &value) < 0)
+    if (!PyArg_ParseTuple(tuple, "L:test_L_code", &value)) {
         return NULL;
+    }
     if (value != 42)
         return raiseTestError("test_L_code",
             "L code returned wrong value for int 42");
@@ -1207,8 +1207,9 @@ test_k_code(PyObject *self)
     PyTuple_SET_ITEM(tuple, 0, num);
 
     value = 0;
-    if (PyArg_ParseTuple(tuple, "k:test_k_code", &value) < 0)
+    if (!PyArg_ParseTuple(tuple, "k:test_k_code", &value)) {
         return NULL;
+    }
     if (value != ULONG_MAX)
         return raiseTestError("test_k_code",
             "k code returned wrong value for long 0xFFF...FFF");
@@ -1226,8 +1227,9 @@ test_k_code(PyObject *self)
     PyTuple_SET_ITEM(tuple, 0, num);
 
     value = 0;
-    if (PyArg_ParseTuple(tuple, "k:test_k_code", &value) < 0)
+    if (!PyArg_ParseTuple(tuple, "k:test_k_code", &value)) {
         return NULL;
+    }
     if (value != (unsigned long)-0x42)
         return raiseTestError("test_k_code",
             "k code returned wrong value for long -0xFFF..000042");
@@ -1587,14 +1589,16 @@ test_u_code(PyObject *self)
     PyTuple_SET_ITEM(tuple, 0, obj);
 
     value = 0;
-    if (PyArg_ParseTuple(tuple, "u:test_u_code", &value) < 0)
+    if (!PyArg_ParseTuple(tuple, "u:test_u_code", &value)) {
         return NULL;
+    }
     if (value != PyUnicode_AS_UNICODE(obj))
         return raiseTestError("test_u_code",
             "u code returned wrong value for u'test'");
     value = 0;
-    if (PyArg_ParseTuple(tuple, "u#:test_u_code", &value, &len) < 0)
+    if (!PyArg_ParseTuple(tuple, "u#:test_u_code", &value, &len)) {
         return NULL;
+    }
     if (value != PyUnicode_AS_UNICODE(obj) ||
         len != PyUnicode_GET_SIZE(obj))
         return raiseTestError("test_u_code",
@@ -1692,8 +1696,9 @@ test_empty_argparse(PyObject *self)
     tuple = PyTuple_New(0);
     if (!tuple)
         return NULL;
-    if ((result = PyArg_ParseTuple(tuple, "|:test_empty_argparse")) < 0)
+    if (!(result = PyArg_ParseTuple(tuple, "|:test_empty_argparse"))) {
         goto done;
+    }
     dict = PyDict_New();
     if (!dict)
         goto done;
@@ -1701,8 +1706,9 @@ test_empty_argparse(PyObject *self)
   done:
     Py_DECREF(tuple);
     Py_XDECREF(dict);
-    if (result < 0)
+    if (!result) {
         return NULL;
+    }
     else {
         Py_RETURN_NONE;
     }
@@ -2494,8 +2500,9 @@ test_raise_signal(PyObject* self, PyObject *args)
 {
     int signum, err;
 
-    if (PyArg_ParseTuple(args, "i:raise_signal", &signum) < 0)
+    if (!PyArg_ParseTuple(args, "i:raise_signal", &signum)) {
         return NULL;
+    }
 
     err = raise(signum);
     if (err)
@@ -2559,6 +2566,22 @@ py_w_stopcode(PyObject *self, PyObject *args)
 #endif
 
 
+/* Read memory from NULL (address 0) to raise a SIGSEGV or SIGBUS signal
+   depending on the platform. This function is used by
+   test.support._crash_python() to "crash" Python. */
+static PyObject *
+read_null(PyObject *self, PyObject *args)
+{
+    volatile int *x;
+    volatile int y;
+
+    x = NULL;
+    y = *x;
+    return PyLong_FromLong(y);
+
+}
+
+
 static PyMethodDef TestMethods[] = {
     {"raise_exception",         raise_exception,                 METH_VARARGS},
     {"set_errno",               set_errno,                       METH_VARARGS},
@@ -2678,6 +2701,7 @@ static PyMethodDef TestMethods[] = {
 #ifdef W_STOPCODE
     {"W_STOPCODE", py_w_stopcode, METH_VARARGS},
 #endif
+    {"_read_null", (PyCFunction)read_null, METH_NOARGS},
     {NULL, NULL} /* sentinel */
 };
 
index 6053e4bde44473fc0ad296944fbfe23999a90c42..444c268c0b4738a10617146f555ba280bc7a9401 100644 (file)
@@ -2332,7 +2332,11 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
         return NULL;
 
-    CHECK_STRING_LENGTH(list);
+    if (strlen(list) >= INT_MAX) {
+        PyErr_SetString(PyExc_OverflowError, "string is too long");
+        PyMem_Free(list);
+        return NULL;
+    }
     if (Tcl_SplitList(Tkapp_Interp(self), list,
                       &argc, &argv) == TCL_ERROR)  {
         PyMem_Free(list);
@@ -2394,7 +2398,11 @@ Tkapp_Split(PyObject *self, PyObject *args)
 
     if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list))
         return NULL;
-    CHECK_STRING_LENGTH(list);
+    if (strlen(list) >= INT_MAX) {
+        PyErr_SetString(PyExc_OverflowError, "string is too long");
+        PyMem_Free(list);
+        return NULL;
+    }
     v = Split(list);
     PyMem_Free(list);
     return v;
index f6f597a046cdcf33fd9077576f3d05c9089dd797..5bd3a42f009d1f30f5a325b659ab6a8f526e12a5 100644 (file)
@@ -1292,9 +1292,9 @@ array_tofile(arrayobject *self, PyObject *f)
         PyErr_SetString(PyExc_TypeError, "arg must be open file");
         return NULL;
     }
-    if (self->ob_size > 0) {
+    if (Py_SIZE(self) > 0) {
         if (fwrite(self->ob_item, self->ob_descr->itemsize,
-                   self->ob_size, fp) != (size_t)self->ob_size) {
+                   Py_SIZE(self), fp) != (size_t)Py_SIZE(self)) {
             PyErr_SetFromErrno(PyExc_IOError);
             clearerr(fp);
             return NULL;
@@ -1348,7 +1348,7 @@ array_fromlist(arrayobject *self, PyObject *list)
             if ((*self->ob_descr->setitem)(self,
                             Py_SIZE(self) - n + i, v) != 0) {
                 Py_SIZE(self) -= n;
-                if (itemsize && (self->ob_size > PY_SSIZE_T_MAX / itemsize)) {
+                if (itemsize && (Py_SIZE(self) > PY_SSIZE_T_MAX / itemsize)) {
                     return PyErr_NoMemory();
                 }
                 PyMem_RESIZE(item, char,
@@ -1444,7 +1444,7 @@ values,as if it had been read from a file using the fromfile() method).");
 static PyObject *
 array_tostring(arrayobject *self, PyObject *unused)
 {
-    if (self->ob_size <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) {
+    if (Py_SIZE(self) <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) {
         return PyString_FromStringAndSize(self->ob_item,
                             Py_SIZE(self) * self->ob_descr->itemsize);
     } else {
@@ -2289,8 +2289,8 @@ initarray(void)
 {
     PyObject *m;
 
-    Arraytype.ob_type = &PyType_Type;
-    PyArrayIter_Type.ob_type = &PyType_Type;
+    Py_TYPE(&Arraytype) = &PyType_Type;
+    Py_TYPE(&PyArrayIter_Type) = &PyType_Type;
     m = Py_InitModule3("array", a_methods, module_doc);
     if (m == NULL)
         return;
index a4d13753b6185a20098e25573952afca5b8bad2c..ad7336c7f9ec8748c2be25e2462fa9aeee152095 100644 (file)
@@ -1086,7 +1086,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
     char *cp, *ncp;
     int len, size, nchannels, inrate, outrate, weightA, weightB;
     int chan, d, *prev_i, *cur_i, cur_o;
-    PyObject *state, *samps, *str, *rv = NULL;
+    PyObject *state, *samps, *str, *rv = NULL, *channel;
     int bytes_per_frame;
 
     weightA = 1;
@@ -1152,6 +1152,10 @@ audioop_ratecv(PyObject *self, PyObject *args)
             prev_i[chan] = cur_i[chan] = 0;
     }
     else {
+        if (!PyTuple_Check(state)) {
+            PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
+            goto exit;
+        }
         if (!PyArg_ParseTuple(state,
                         "iO!;audioop.ratecv: illegal state argument",
                         &d, &PyTuple_Type, &samps))
@@ -1162,7 +1166,13 @@ audioop_ratecv(PyObject *self, PyObject *args)
             goto exit;
         }
         for (chan = 0; chan < nchannels; chan++) {
-            if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
+            channel = PyTuple_GetItem(samps, chan);
+            if (!PyTuple_Check(channel)) {
+                PyErr_SetString(PyExc_TypeError,
+                                "ratecv(): illegal state argument");
+                goto exit;
+            }
+            if (!PyArg_ParseTuple(channel,
                                   "ii:ratecv", &prev_i[chan],
                                                &cur_i[chan]))
                 goto exit;
index 45736376d14c36a114ffa3153a05473fa412f426..e818c5cfdc4d2fa8c035ca4e22cf161dc3c9614d 100644 (file)
@@ -1537,6 +1537,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
     if (x2 == NULL)
         goto Done;
     result = PyNumber_Add(x1, x2);
+    assert(result == NULL || PyInt_CheckExact(result) || PyLong_CheckExact(result));
 
 Done:
     Py_XDECREF(x1);
@@ -1559,6 +1560,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
     PyObject *num = NULL;
     PyObject *result = NULL;
 
+    assert(PyInt_CheckExact(pyus) || PyLong_CheckExact(pyus));
     tuple = PyNumber_Divmod(pyus, us_per_second);
     if (tuple == NULL)
         goto Done;
@@ -1851,11 +1853,13 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
     assert(num != NULL);
 
     if (PyInt_Check(num) || PyLong_Check(num)) {
-        prod = PyNumber_Multiply(num, factor);
+        prod = PyNumber_Multiply(factor, num);
         if (prod == NULL)
             return NULL;
+        assert(PyInt_CheckExact(prod) || PyLong_CheckExact(prod));
         sum = PyNumber_Add(sofar, prod);
         Py_DECREF(prod);
+        assert(sum == NULL || PyInt_CheckExact(sum) || PyLong_CheckExact(sum));
         return sum;
     }
 
@@ -1898,7 +1902,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
          * fractional part requires float arithmetic, and may
          * lose a little info.
          */
-        assert(PyInt_Check(factor) || PyLong_Check(factor));
+        assert(PyInt_CheckExact(factor) || PyLong_CheckExact(factor));
         if (PyInt_Check(factor))
             dnum = (double)PyInt_AsLong(factor);
         else
@@ -1916,6 +1920,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
         Py_DECREF(sum);
         Py_DECREF(x);
         *leftover += fracpart;
+        assert(y == NULL || PyInt_CheckExact(y) || PyLong_CheckExact(y));
         return y;
     }
 
@@ -3039,8 +3044,7 @@ static char tzinfo_doc[] =
 PyDoc_STR("Abstract base class for time zone info objects.");
 
 statichere PyTypeObject PyDateTime_TZInfoType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                          /* ob_size */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "datetime.tzinfo",                          /* tp_name */
     sizeof(PyDateTime_TZInfo),                  /* tp_basicsize */
     0,                                          /* tp_itemsize */
@@ -3564,8 +3568,7 @@ static PyNumberMethods time_as_number = {
 };
 
 statichere PyTypeObject PyDateTime_TimeType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                          /* ob_size */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "datetime.time",                            /* tp_name */
     sizeof(PyDateTime_Time),                    /* tp_basicsize */
     0,                                          /* tp_itemsize */
@@ -4692,8 +4695,7 @@ static PyNumberMethods datetime_as_number = {
 };
 
 statichere PyTypeObject PyDateTime_DateTimeType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                                          /* ob_size */
+    PyVarObject_HEAD_INIT(NULL, 0)
     "datetime.datetime",                        /* tp_name */
     sizeof(PyDateTime_DateTime),                /* tp_basicsize */
     0,                                          /* tp_itemsize */
index cf3aadfd3e07128e2afecc9cdbe1b10e9752f2d0..47db7affb0598288d96edc8801e55120e9172c9e 100644 (file)
@@ -71,10 +71,37 @@ groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg)
     return 0;
 }
 
+Py_LOCAL_INLINE(int)
+groupby_step(groupbyobject *gbo)
+{
+    PyObject *newvalue, *newkey, *oldvalue;
+
+    newvalue = PyIter_Next(gbo->it);
+    if (newvalue == NULL)
+        return -1;
+
+    if (gbo->keyfunc == Py_None) {
+        newkey = newvalue;
+        Py_INCREF(newvalue);
+    } else {
+        newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL);
+        if (newkey == NULL) {
+            Py_DECREF(newvalue);
+            return -1;
+        }
+    }
+
+    oldvalue = gbo->currvalue;
+    gbo->currvalue = newvalue;
+    Py_XSETREF(gbo->currkey, newkey);
+    Py_XDECREF(oldvalue);
+    return 0;
+}
+
 static PyObject *
 groupby_next(groupbyobject *gbo)
 {
-    PyObject *newvalue, *newkey, *r, *grouper, *tmp;
+    PyObject *r, *grouper;
 
     /* skip to next iteration group */
     for (;;) {
@@ -93,35 +120,11 @@ groupby_next(groupbyobject *gbo)
                 break;
         }
 
-        newvalue = PyIter_Next(gbo->it);
-        if (newvalue == NULL)
+        if (groupby_step(gbo) < 0)
             return NULL;
-
-        if (gbo->keyfunc == Py_None) {
-            newkey = newvalue;
-            Py_INCREF(newvalue);
-        } else {
-            newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc,
-                                                  newvalue, NULL);
-            if (newkey == NULL) {
-                Py_DECREF(newvalue);
-                return NULL;
-            }
-        }
-
-        tmp = gbo->currkey;
-        gbo->currkey = newkey;
-        Py_XDECREF(tmp);
-
-        tmp = gbo->currvalue;
-        gbo->currvalue = newvalue;
-        Py_XDECREF(tmp);
     }
-
     Py_INCREF(gbo->currkey);
-    tmp = gbo->tgtkey;
-    gbo->tgtkey = gbo->currkey;
-    Py_XDECREF(tmp);
+    Py_XSETREF(gbo->tgtkey, gbo->currkey);
 
     grouper = _grouper_create(gbo, gbo->tgtkey);
     if (grouper == NULL)
@@ -229,29 +232,12 @@ static PyObject *
 _grouper_next(_grouperobject *igo)
 {
     groupbyobject *gbo = (groupbyobject *)igo->parent;
-    PyObject *newvalue, *newkey, *r;
+    PyObject *r;
     int rcmp;
 
     if (gbo->currvalue == NULL) {
-        newvalue = PyIter_Next(gbo->it);
-        if (newvalue == NULL)
+        if (groupby_step(gbo) < 0)
             return NULL;
-
-        if (gbo->keyfunc == Py_None) {
-            newkey = newvalue;
-            Py_INCREF(newvalue);
-        } else {
-            newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc,
-                                                  newvalue, NULL);
-            if (newkey == NULL) {
-                Py_DECREF(newvalue);
-                return NULL;
-            }
-        }
-
-        assert(gbo->currkey == NULL);
-        gbo->currkey = newkey;
-        gbo->currvalue = newvalue;
     }
 
     assert(gbo->currkey != NULL);
index 5532c4484db2f6eb364fd8dedb7add6f4a988198..2ae52c7b28df79bbad4b0f265efc3d6473df7340 100644 (file)
@@ -1114,7 +1114,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
         return NULL;
     if (map_size < 0) {
         PyErr_SetString(PyExc_OverflowError,
-                        "memory mapped length must be postiive");
+                        "memory mapped length must be positive");
         return NULL;
     }
     if (offset < 0) {
@@ -1300,7 +1300,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
 
     if (map_size < 0) {
         PyErr_SetString(PyExc_OverflowError,
-                        "memory mapped length must be postiive");
+                        "memory mapped length must be positive");
         return NULL;
     }
     if (offset < 0) {
index a06c56e0691f35e456a32eeb30f6faeaafa82c89..2baf9202c303c06e02fb92f2ef79678b6f2603a8 100644 (file)
@@ -65,6 +65,11 @@ corresponding Unix manual entries for more information on calls.");
 #include "osdefs.h"
 #endif
 
+#ifdef HAVE_SYS_SYSMACROS_H
+/* GNU C Library: major(), minor(), makedev() */
+#include <sys/sysmacros.h>
+#endif
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif /* HAVE_SYS_TYPES_H */
@@ -979,6 +984,7 @@ win32_wchdir(LPCWSTR path)
     wchar_t _new_path[MAX_PATH+1], *new_path = _new_path;
     int result;
     wchar_t env[4] = L"=x:";
+    int is_unc_like_path;
 
     if(!SetCurrentDirectoryW(path))
         return FALSE;
@@ -997,15 +1003,15 @@ win32_wchdir(LPCWSTR path)
             return FALSE;
         }
     }
-    if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
-        wcsncmp(new_path, L"//", 2) == 0)
-        /* UNC path, nothing to do. */
-        return TRUE;
-    env[1] = new_path[0];
-    result = SetEnvironmentVariableW(env, new_path);
+    is_unc_like_path = (wcsncmp(new_path, L"\\\\", 2) == 0 ||
+                        wcsncmp(new_path, L"//", 2) == 0);
+    if (!is_unc_like_path) {
+        env[1] = new_path[0];
+        result = SetEnvironmentVariableW(env, new_path);
+    }
     if (new_path != _new_path)
         free(new_path);
-    return result;
+    return result ? TRUE : FALSE;
 }
 #endif
 
@@ -2380,7 +2386,7 @@ posix_listdir(PyObject *self, PyObject *args)
     if (len > 0) {
         char ch = namebuf[len-1];
         if (ch != SEP && ch != ALTSEP && ch != ':')
-            namebuf[len++] = '/';
+            namebuf[len++] = SEP;
         strcpy(namebuf + len, "*.*");
     }
 
@@ -3931,7 +3937,7 @@ posix_fork(PyObject *self, PyObject *noargs)
 #ifdef HAVE_STROPTS_H
 #include <stropts.h>
 #endif
-#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX */
+#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX) */
 
 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
 PyDoc_STRVAR(posix_openpty__doc__,
index da03366bb91602a89fad86338b33790eaeb50821..1dec6a120d05163cdb5bc4e659b28d642b792234 100644 (file)
@@ -530,6 +530,17 @@ poll_poll(pollObject *self, PyObject *args)
             return NULL;
     }
 
+    /* On some OSes, typically BSD-based ones, the timeout parameter of the
+       poll() syscall, when negative, must be exactly INFTIM, where defined,
+       or -1. See issue 31334. */
+    if (timeout < 0) {
+#ifdef INFTIM
+        timeout = INFTIM;
+#else
+        timeout = -1;
+#endif
+    }
+
     /* Avoid concurrent poll() invocation, issue 8865 */
     if (self->poll_running) {
         PyErr_SetString(PyExc_RuntimeError,
@@ -1210,43 +1221,76 @@ static PyTypeObject kqueue_queue_Type;
 
 #if (SIZEOF_UINTPTR_T != SIZEOF_VOID_P)
 #   error uintptr_t does not match void *!
-#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG)
+#elif defined(HAVE_LONG_LONG) && (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG)
 #   define T_UINTPTRT         T_ULONGLONG
 #   define T_INTPTRT          T_LONGLONG
-#   define PyLong_AsUintptr_t PyLong_AsUnsignedLongLong
 #   define UINTPTRT_FMT_UNIT  "K"
 #   define INTPTRT_FMT_UNIT   "L"
 #elif (SIZEOF_UINTPTR_T == SIZEOF_LONG)
 #   define T_UINTPTRT         T_ULONG
 #   define T_INTPTRT          T_LONG
-#   define PyLong_AsUintptr_t PyLong_AsUnsignedLong
 #   define UINTPTRT_FMT_UNIT  "k"
 #   define INTPTRT_FMT_UNIT   "l"
 #elif (SIZEOF_UINTPTR_T == SIZEOF_INT)
 #   define T_UINTPTRT         T_UINT
 #   define T_INTPTRT          T_INT
-#   define PyLong_AsUintptr_t PyLong_AsUnsignedLong
 #   define UINTPTRT_FMT_UNIT  "I"
 #   define INTPTRT_FMT_UNIT   "i"
 #else
 #   error uintptr_t does not match int, long, or long long!
 #endif
 
+#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
+#   define T_INT64          T_LONGLONG
+#   define INT64_FMT_UNIT   "L"
+#elif SIZEOF_LONG == 8
+#   define T_INT64          T_LONG
+#   define INT64_FMT_UNIT   "l"
+#elif SIZEOF_INT == 8
+#   define T_INT64          T_INT
+#   define INT64_FMT_UNIT   "i"
+#else
+#   define INT64_FMT_UNIT   "_"
+#endif
+
+#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 4
+#   define T_UINT32         T_ULONGLONG
+#   define UINT32_FMT_UNIT  "K"
+#elif SIZEOF_LONG == 4
+#   define T_UINT32         T_ULONG
+#   define UINT32_FMT_UNIT  "k"
+#elif SIZEOF_INT == 4
+#   define T_UINT32         T_UINT
+#   define UINT32_FMT_UNIT  "I"
+#else
+#   define UINT32_FMT_UNIT  "_"
+#endif
+
 /*
  * kevent is not standard and its members vary across BSDs.
  */
-#if !defined(__OpenBSD__)
-#   define IDENT_TYPE  T_UINTPTRT
-#   define IDENT_CAST  Py_intptr_t
-#   define DATA_TYPE   T_INTPTRT
-#   define DATA_FMT_UNIT INTPTRT_FMT_UNIT
-#   define IDENT_AsType        PyLong_AsUintptr_t
+#ifdef __NetBSD__
+#   define FILTER_TYPE      T_UINT32
+#   define FILTER_FMT_UNIT  UINT32_FMT_UNIT
+#   define FLAGS_TYPE       T_UINT32
+#   define FLAGS_FMT_UNIT   UINT32_FMT_UNIT
+#   define FFLAGS_TYPE      T_UINT32
+#   define FFLAGS_FMT_UNIT  UINT32_FMT_UNIT
+#else
+#   define FILTER_TYPE      T_SHORT
+#   define FILTER_FMT_UNIT  "h"
+#   define FLAGS_TYPE       T_USHORT
+#   define FLAGS_FMT_UNIT   "H"
+#   define FFLAGS_TYPE      T_UINT
+#   define FFLAGS_FMT_UNIT  "I"
+#endif
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#   define DATA_TYPE        T_INT64
+#   define DATA_FMT_UNIT    INT64_FMT_UNIT
 #else
-#   define IDENT_TYPE  T_UINT
-#   define IDENT_CAST  int
-#   define DATA_TYPE   T_INT
-#   define DATA_FMT_UNIT "i"
-#   define IDENT_AsType        PyLong_AsUnsignedLong
+#   define DATA_TYPE        T_INTPTRT
+#   define DATA_FMT_UNIT    INTPTRT_FMT_UNIT
 #endif
 
 /* Unfortunately, we can't store python objects in udata, because
@@ -1256,9 +1300,9 @@ static PyTypeObject kqueue_queue_Type;
 
 #define KQ_OFF(x) offsetof(kqueue_event_Object, x)
 static struct PyMemberDef kqueue_event_members[] = {
-    {"ident",           IDENT_TYPE,     KQ_OFF(e.ident)},
-    {"filter",          T_SHORT,        KQ_OFF(e.filter)},
-    {"flags",           T_USHORT,       KQ_OFF(e.flags)},
+    {"ident",           T_UINTPTRT,     KQ_OFF(e.ident)},
+    {"filter",          FILTER_TYPE,    KQ_OFF(e.filter)},
+    {"flags",           FLAGS_TYPE,     KQ_OFF(e.flags)},
     {"fflags",          T_UINT,         KQ_OFF(e.fflags)},
     {"data",            DATA_TYPE,      KQ_OFF(e.data)},
     {"udata",           T_UINTPTRT,     KQ_OFF(e.udata)},
@@ -1273,10 +1317,17 @@ kqueue_event_repr(kqueue_event_Object *s)
     char buf[1024];
     PyOS_snprintf(
         buf, sizeof(buf),
+#ifdef HAVE_LONG_LONG
+        "<select.kevent ident=%zu filter=%d flags=0x%x fflags=0x%x "
+        "data=0x%llx udata=%p>",
+        (size_t)(s->e.ident), (int)s->e.filter, (unsigned int)s->e.flags,
+        (unsigned int)s->e.fflags, (long long)(s->e.data), (void *)s->e.udata);
+#else
         "<select.kevent ident=%zu filter=%d flags=0x%x fflags=0x%x "
-        "data=0x%zd udata=%p>",
-        (size_t)(s->e.ident), s->e.filter, s->e.flags,
-        s->e.fflags, (Py_ssize_t)(s->e.data), s->e.udata);
+        "data=0x%llx udata=%p>",
+        (size_t)(s->e.ident), (int)s->e.filter, (unsigned int)s->e.flags,
+        (unsigned int)s->e.fflags, (long)(s->e.data), (void *)s->e.udata);
+#endif
     return PyString_FromString(buf);
 }
 
@@ -1286,7 +1337,9 @@ kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds)
     PyObject *pfd;
     static char *kwlist[] = {"ident", "filter", "flags", "fflags",
                              "data", "udata", NULL};
-    static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
+    static const char fmt[] = "O|"
+                FILTER_FMT_UNIT FLAGS_FMT_UNIT FFLAGS_FMT_UNIT DATA_FMT_UNIT
+                UINTPTRT_FMT_UNIT ":kevent";
 
     EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */
 
@@ -1296,12 +1349,15 @@ kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds)
         return -1;
     }
 
-    if (PyLong_Check(pfd)
-#if IDENT_TYPE == T_UINT
-        && PyLong_AsUnsignedLong(pfd) <= UINT_MAX
+    if (PyInt_Check(pfd)) {
+        self->e.ident = PyInt_AsUnsignedLongMask(pfd);
+    }
+    else if (PyLong_Check(pfd)) {
+#if defined(HAVE_LONG_LONG) && (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG)
+        self->e.ident = PyLong_AsUnsignedLongLongMask(pfd);
+#else
+        self->e.ident = PyLong_AsUnsignedLongMask(pfd);
 #endif
-    ) {
-        self->e.ident = IDENT_AsType(pfd);
     }
     else {
         self->e.ident = PyObject_AsFileDescriptor(pfd);
@@ -1316,29 +1372,23 @@ static PyObject *
 kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o,
                          int op)
 {
-    Py_intptr_t result = 0;
+    int result;
 
     if (!kqueue_event_Check(o)) {
-        if (op == Py_EQ || op == Py_NE) {
-            PyObject *res = op == Py_EQ ? Py_False : Py_True;
-            Py_INCREF(res);
-            return res;
-        }
-        PyErr_Format(PyExc_TypeError,
-            "can't compare %.200s to %.200s",
-            Py_TYPE(s)->tp_name, Py_TYPE(o)->tp_name);
-        return NULL;
-    }
-    if (((result = (IDENT_CAST)(s->e.ident - o->e.ident)) == 0) &&
-        ((result = s->e.filter - o->e.filter) == 0) &&
-        ((result = s->e.flags - o->e.flags) == 0) &&
-        ((result = (int)(s->e.fflags - o->e.fflags)) == 0) &&
-        ((result = s->e.data - o->e.data) == 0) &&
-        ((result = s->e.udata - o->e.udata) == 0)
-       ) {
-        result = 0;
+        Py_INCREF(Py_NotImplemented);
+        return Py_NotImplemented;
     }
 
+#define CMP(a, b) ((a) != (b)) ? ((a) < (b) ? -1 : 1)
+    result = CMP(s->e.ident, o->e.ident)
+           : CMP(s->e.filter, o->e.filter)
+           : CMP(s->e.flags, o->e.flags)
+           : CMP(s->e.fflags, o->e.fflags)
+           : CMP(s->e.data, o->e.data)
+           : CMP((Py_intptr_t)s->e.udata, (Py_intptr_t)o->e.udata)
+           : 0;
+#undef CMP
+
     switch (op) {
         case Py_EQ:
         result = (result == 0);
@@ -1537,7 +1587,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
     int i = 0;
     PyObject *otimeout = NULL;
     PyObject *ch = NULL;
-    PyObject *it = NULL, *ei = NULL;
+    PyObject *seq = NULL, *ei = NULL;
     PyObject *result = NULL;
     struct kevent *evl = NULL;
     struct kevent *chl = NULL;
@@ -1593,37 +1643,34 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
     }
 
     if (ch != NULL && ch != Py_None) {
-        it = PyObject_GetIter(ch);
-        if (it == NULL) {
-            PyErr_SetString(PyExc_TypeError,
-                            "changelist is not iterable");
+        seq = PySequence_Fast(ch, "changelist is not iterable");
+        if (seq == NULL) {
             return NULL;
         }
-        nchanges = PyObject_Size(ch);
-        if (nchanges < 0) {
+        if (PySequence_Fast_GET_SIZE(seq) > INT_MAX) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "changelist is too long");
             goto error;
         }
+        nchanges = (int)PySequence_Fast_GET_SIZE(seq);
 
         chl = PyMem_New(struct kevent, nchanges);
         if (chl == NULL) {
             PyErr_NoMemory();
             goto error;
         }
-        i = 0;
-        while ((ei = PyIter_Next(it)) != NULL) {
+        for (i = 0; i < nchanges; ++i) {
+            ei = PySequence_Fast_GET_ITEM(seq, i);
             if (!kqueue_event_Check(ei)) {
-                Py_DECREF(ei);
                 PyErr_SetString(PyExc_TypeError,
                     "changelist must be an iterable of "
                     "select.kevent objects");
                 goto error;
-            } else {
-                chl[i++] = ((kqueue_event_Object *)ei)->e;
             }
-            Py_DECREF(ei);
+            chl[i] = ((kqueue_event_Object *)ei)->e;
         }
+        Py_CLEAR(seq);
     }
-    Py_CLEAR(it);
 
     /* event list */
     if (nevents) {
@@ -1667,7 +1714,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
     PyMem_Free(chl);
     PyMem_Free(evl);
     Py_XDECREF(result);
-    Py_XDECREF(it);
+    Py_XDECREF(seq);
     return NULL;
 }
 
@@ -1675,7 +1722,7 @@ PyDoc_STRVAR(kqueue_queue_control_doc,
 "control(changelist, max_events[, timeout=None]) -> eventlist\n\
 \n\
 Calls the kernel kevent function.\n\
-- changelist must be a list of kevent objects describing the changes\n\
+- changelist must be an iterable of kevent objects describing the changes\n\
   to be made to the kernel's watch list or None.\n\
 - max_events lets you specify the maximum number of events that the\n\
   kernel will return.\n\
index c7bf1f0853438076b6fc3c662f5e6c50de76f088..ef70d10bb1840e98bc66828dade44b3b78dc6b7a 100644 (file)
@@ -317,12 +317,15 @@ signal_signal(PyObject *self, PyObject *args)
     }
     else
         func = signal_handler;
+    /* Check for pending signals before changing signal handler */
+    if (PyErr_CheckSignals()) {
+        return NULL;
+    }
     if (PyOS_setsig(sig_num, func) == SIG_ERR) {
         PyErr_SetFromErrno(PyExc_RuntimeError);
         return NULL;
     }
     old_handler = Handlers[sig_num].func;
-    Handlers[sig_num].tripped = 0;
     Py_INCREF(obj);
     Handlers[sig_num].func = obj;
     if (old_handler != NULL)
index 3e3c05f540794943baa765210ababb80c178353e..8d3670529e856ef111ba83ace198f0d44c7df381 100644 (file)
@@ -1005,7 +1005,7 @@ makeipaddr(struct sockaddr *addr, int addrlen)
    an error occurred. */
 
 static int
-setbdaddr(char *name, bdaddr_t *bdaddr)
+setbdaddr(const char *name, bdaddr_t *bdaddr)
 {
     unsigned int b0, b1, b2, b3, b4, b5;
     char ch;
@@ -1062,7 +1062,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
 #ifdef __BEOS__
     /* XXX: BeOS version of accept() doesn't set family correctly */
     addr->sa_family = AF_INET;
-#endif
+#endif /* __BEOS__ */
 
     switch (addr->sa_family) {
 
@@ -1123,7 +1123,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
         }
         return ret;
     }
-#endif
+#endif /* ENABLE_IPV6 */
 
 #ifdef USE_BLUETOOTH
     case AF_BLUETOOTH:
@@ -1162,11 +1162,11 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
             struct sockaddr_hci *a = (struct sockaddr_hci *) addr;
 #if defined(__NetBSD__) || defined(__DragonFly__)
             return makebdaddr(&_BT_HCI_MEMB(a, bdaddr));
-#else
+#else /* __NetBSD__ || __DragonFly__ */
             PyObject *ret = NULL;
             ret = Py_BuildValue("i", _BT_HCI_MEMB(a, dev));
             return ret;
-#endif
+#endif /* !(__NetBSD__ || __DragonFly__) */
         }
 
 #if !defined(__FreeBSD__)
@@ -1175,20 +1175,20 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
             struct sockaddr_sco *a = (struct sockaddr_sco *) addr;
             return makebdaddr(&_BT_SCO_MEMB(a, bdaddr));
         }
-#endif
+#endif /* !__FreeBSD__ */
 
         default:
             PyErr_SetString(PyExc_ValueError,
                             "Unknown Bluetooth protocol");
             return NULL;
         }
-#endif
+#endif /* USE_BLUETOOTH */
 
 #if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFNAME)
     case AF_PACKET:
     {
         struct sockaddr_ll *a = (struct sockaddr_ll *)addr;
-        char *ifname = "";
+        const char *ifname = "";
         struct ifreq ifr;
         /* need to look up interface name give index */
         if (a->sll_ifindex) {
@@ -1204,7 +1204,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
                              a->sll_addr,
                              a->sll_halen);
     }
-#endif
+#endif /* HAVE_NETPACKET_PACKET_H && SIOCGIFNAME */
 
 #ifdef HAVE_LINUX_TIPC_H
     case AF_TIPC:
@@ -1237,7 +1237,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
             return NULL;
         }
     }
-#endif
+#endif /* HAVE_LINUX_TIPC_H */
 
     /* More cases here... */
 
@@ -1298,9 +1298,9 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         memcpy(addr->sun_path, path, len);
 #if defined(PYOS_OS2)
         *len_ret = sizeof(*addr);
-#else
+#else /* PYOS_OS2 */
         *len_ret = len + offsetof(struct sockaddr_un, sun_path);
-#endif
+#endif /* !PYOS_OS2 */
         return 1;
     }
 #endif /* AF_UNIX */
@@ -1327,7 +1327,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         *len_ret = sizeof(*addr);
         return 1;
     }
-#endif
+#endif /* AF_NETLINK */
 
     case AF_INET:
     {
@@ -1409,7 +1409,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         *len_ret = sizeof *addr;
         return 1;
     }
-#endif
+#endif /* ENABLE_IPV6 */
 
 #ifdef USE_BLUETOOTH
     case AF_BLUETOOTH:
@@ -1418,7 +1418,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         case BTPROTO_L2CAP:
         {
             struct sockaddr_l2 *addr;
-            char *straddr;
+            const char *straddr;
 
             addr = (struct sockaddr_l2 *)addr_ret;
             memset(addr, 0, sizeof(struct sockaddr_l2));
@@ -1438,7 +1438,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         case BTPROTO_RFCOMM:
         {
             struct sockaddr_rc *addr;
-            char *straddr;
+            const char *straddr;
 
             addr = (struct sockaddr_rc *)addr_ret;
             _BT_RC_MEMB(addr, family) = AF_BLUETOOTH;
@@ -1458,24 +1458,24 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         {
             struct sockaddr_hci *addr = (struct sockaddr_hci *)addr_ret;
 #if defined(__NetBSD__) || defined(__DragonFly__)
-                       char *straddr = PyBytes_AS_STRING(args);
-
-                       _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
-            if (straddr == NULL) {
-                PyErr_SetString(socket_error, "getsockaddrarg: "
+            const char *straddr;
+            _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
+            if (!PyBytes_Check(args)) {
+                PyErr_SetString(PyExc_OSError, "getsockaddrarg: "
                     "wrong format");
                 return 0;
             }
+            straddr = PyBytes_AS_STRING(args);
             if (setbdaddr(straddr, &_BT_HCI_MEMB(addr, bdaddr)) < 0)
                 return 0;
-#else
+#else  /* __NetBSD__ || __DragonFly__ */
             _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
             if (!PyArg_ParseTuple(args, "i", &_BT_HCI_MEMB(addr, dev))) {
                 PyErr_SetString(socket_error, "getsockaddrarg: "
                                 "wrong format");
                 return 0;
             }
-#endif
+#endif /* !(__NetBSD__ || __DragonFly__) */
             *len_ret = sizeof *addr;
             return 1;
         }
@@ -1483,7 +1483,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         case BTPROTO_SCO:
         {
             struct sockaddr_sco *addr;
-            char *straddr;
+            const char *straddr;
 
             addr = (struct sockaddr_sco *)addr_ret;
             _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH;
@@ -1499,20 +1499,20 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
             *len_ret = sizeof *addr;
             return 1;
         }
-#endif
+#endif /* !__FreeBSD__ */
         default:
             PyErr_SetString(socket_error, "getsockaddrarg: unknown Bluetooth protocol");
             return 0;
         }
     }
-#endif
+#endif /* USE_BLUETOOTH */
 
 #if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFINDEX)
     case AF_PACKET:
     {
         struct sockaddr_ll* addr;
         struct ifreq ifr;
-        char *interfaceName;
+        const char *interfaceName;
         int protoNumber;
         int hatype = 0;
         int pkttype = 0;
@@ -1561,7 +1561,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         *len_ret = sizeof *addr;
         return 1;
     }
-#endif
+#endif /* HAVE_NETPACKET_PACKET_H && SIOCGIFINDEX */
 
 #ifdef HAVE_LINUX_TIPC_H
     case AF_TIPC:
@@ -1611,7 +1611,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
 
         return 1;
     }
-#endif
+#endif /* HAVE_LINUX_TIPC_H */
 
     /* More cases here... */
 
@@ -1646,7 +1646,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
         *len_ret = sizeof (struct sockaddr_nl);
         return 1;
     }
-#endif
+#endif /* AF_NETLINK */
 
     case AF_INET:
     {
@@ -1660,7 +1660,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
         *len_ret = sizeof (struct sockaddr_in6);
         return 1;
     }
-#endif
+#endif /* ENABLE_IPV6 */
 
 #ifdef USE_BLUETOOTH
     case AF_BLUETOOTH:
@@ -1681,7 +1681,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
         case BTPROTO_SCO:
             *len_ret = sizeof (struct sockaddr_sco);
             return 1;
-#endif
+#endif /* !__FreeBSD__ */
         default:
             PyErr_SetString(socket_error, "getsockaddrlen: "
                             "unknown BT protocol");
@@ -1689,7 +1689,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
 
         }
     }
-#endif
+#endif /* USE_BLUETOOTH */
 
 #ifdef HAVE_NETPACKET_PACKET_H
     case AF_PACKET:
@@ -1697,7 +1697,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
         *len_ret = sizeof (struct sockaddr_ll);
         return 1;
     }
-#endif
+#endif /* HAVE_NETPACKET_PACKET_H */
 
 #ifdef HAVE_LINUX_TIPC_H
     case AF_TIPC:
@@ -1705,7 +1705,7 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
         *len_ret = sizeof (struct sockaddr_tipc);
         return 1;
     }
-#endif
+#endif /* HAVE_LINUX_TIPC_H */
 
     /* More cases here... */
 
@@ -3554,7 +3554,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
     int result;
 #endif
 #endif /* HAVE_GETHOSTBYNAME_R */
-    char *ap;
+    const char *ap;
     int al;
     int af;
 
@@ -3623,7 +3623,7 @@ for a host.  The host argument is a string giving a host name or IP number.");
 static PyObject *
 socket_getservbyname(PyObject *self, PyObject *args)
 {
-    char *name, *proto=NULL;
+    const char *name, *proto=NULL;
     struct servent *sp;
     if (!PyArg_ParseTuple(args, "s|s:getservbyname", &name, &proto))
         return NULL;
@@ -3654,7 +3654,7 @@ static PyObject *
 socket_getservbyport(PyObject *self, PyObject *args)
 {
     int port;
-    char *proto=NULL;
+    const char *proto=NULL;
     struct servent *sp;
     if (!PyArg_ParseTuple(args, "i|s:getservbyport", &port, &proto))
         return NULL;
@@ -3689,7 +3689,7 @@ otherwise any protocol will match.");
 static PyObject *
 socket_getprotobyname(PyObject *self, PyObject *args)
 {
-    char *name;
+    const char *name;
     struct protoent *sp;
 #ifdef __BEOS__
 /* Not available in BeOS yet. - [cjh] */
@@ -3964,7 +3964,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
     /* Have to use inet_addr() instead */
     unsigned int packed_addr;
 #endif
-    char *ip_addr;
+    const char *ip_addr;
 
     if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr))
         return NULL;
@@ -4054,7 +4054,7 @@ static PyObject *
 socket_inet_pton(PyObject *self, PyObject *args)
 {
     int af;
-    char* ip;
+    const char* ip;
     int retval;
 #ifdef ENABLE_IPV6
     char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
@@ -4280,7 +4280,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
 {
     PyObject *sa = (PyObject *)NULL;
     int flags;
-    char *hostp;
+    const char *hostp;
     int port;
     unsigned int flowinfo, scope_id;
     char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
index 12c43b08fe4a814dfb3388cc8d950afed310da9a..61b8d612a4ae0a67c41e0028676d0b767491a588 100644 (file)
@@ -388,6 +388,76 @@ gettmarg(PyObject *args, struct tm *p)
     return 1;
 }
 
+/* Check values of the struct tm fields before it is passed to strftime() and
+ * asctime().  Return 1 if all values are valid, otherwise set an exception
+ * and returns 0.
+ */
+static int
+checktm(struct tm* buf)
+{
+    /* Checks added to make sure strftime() and asctime() does not crash Python by
+       indexing blindly into some array for a textual representation
+       by some bad index (fixes bug #897625 and #6608).
+
+       Also support values of zero from Python code for arguments in which
+       that is out of range by forcing that value to the lowest value that
+       is valid (fixed bug #1520914).
+
+       Valid ranges based on what is allowed in struct tm:
+
+       - tm_year: [0, max(int)] (1)
+       - tm_mon: [0, 11] (2)
+       - tm_mday: [1, 31]
+       - tm_hour: [0, 23]
+       - tm_min: [0, 59]
+       - tm_sec: [0, 60]
+       - tm_wday: [0, 6] (1)
+       - tm_yday: [0, 365] (2)
+       - tm_isdst: [-max(int), max(int)]
+
+       (1) gettmarg() handles bounds-checking.
+       (2) Python's acceptable range is one greater than the range in C,
+       thus need to check against automatic decrement by gettmarg().
+    */
+    if (buf->tm_mon == -1)
+        buf->tm_mon = 0;
+    else if (buf->tm_mon < 0 || buf->tm_mon > 11) {
+        PyErr_SetString(PyExc_ValueError, "month out of range");
+        return 0;
+    }
+    if (buf->tm_mday == 0)
+        buf->tm_mday = 1;
+    else if (buf->tm_mday < 0 || buf->tm_mday > 31) {
+        PyErr_SetString(PyExc_ValueError, "day of month out of range");
+        return 0;
+    }
+    if (buf->tm_hour < 0 || buf->tm_hour > 23) {
+        PyErr_SetString(PyExc_ValueError, "hour out of range");
+        return 0;
+    }
+    if (buf->tm_min < 0 || buf->tm_min > 59) {
+        PyErr_SetString(PyExc_ValueError, "minute out of range");
+        return 0;
+    }
+    if (buf->tm_sec < 0 || buf->tm_sec > 61) {
+        PyErr_SetString(PyExc_ValueError, "seconds out of range");
+        return 0;
+    }
+    /* tm_wday does not need checking of its upper-bound since taking
+    ``% 7`` in gettmarg() automatically restricts the range. */
+    if (buf->tm_wday < 0) {
+        PyErr_SetString(PyExc_ValueError, "day of week out of range");
+        return 0;
+    }
+    if (buf->tm_yday == -1)
+        buf->tm_yday = 0;
+    else if (buf->tm_yday < 0 || buf->tm_yday > 365) {
+        PyErr_SetString(PyExc_ValueError, "day of year out of range");
+        return 0;
+    }
+    return 1;
+}
+
 #ifdef HAVE_STRFTIME
 static PyObject *
 time_strftime(PyObject *self, PyObject *args)
@@ -407,8 +477,10 @@ time_strftime(PyObject *self, PyObject *args)
     if (tup == NULL) {
         time_t tt = time(NULL);
         buf = *localtime(&tt);
-    } else if (!gettmarg(tup, &buf))
+    } else if (!gettmarg(tup, &buf)
+               || !checktm(&buf)) {
         return NULL;
+    }
 
     /* Checks added to make sure strftime() does not crash Python by
        indexing blindly into some array for a textual representation
@@ -558,27 +630,51 @@ Parse a string to a time tuple according to a format specification.\n\
 See the library reference manual for formatting codes (same as strftime()).");
 
 
+static PyObject *
+_asctime(struct tm *timeptr)
+{
+    /* Inspired by Open Group reference implementation available at
+     * http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html */
+    static const char wday_name[7][4] = {
+        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+    };
+    static const char mon_name[12][4] = {
+        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+    };
+    PyObject *unicode, *str;
+    /* PyString_FromString() cannot be used because it doesn't support %3d */
+    unicode = PyUnicode_FromFormat(
+        "%s %s%3d %.2d:%.2d:%.2d %d",
+        wday_name[timeptr->tm_wday],
+        mon_name[timeptr->tm_mon],
+        timeptr->tm_mday, timeptr->tm_hour,
+        timeptr->tm_min, timeptr->tm_sec,
+        1900 + timeptr->tm_year);
+    if (unicode == NULL) {
+        return NULL;
+    }
+
+    str = PyUnicode_AsASCIIString(unicode);
+    Py_DECREF(unicode);
+    return str;
+}
+
 static PyObject *
 time_asctime(PyObject *self, PyObject *args)
 {
     PyObject *tup = NULL;
     struct tm buf;
-    char *p;
     if (!PyArg_UnpackTuple(args, "asctime", 0, 1, &tup))
         return NULL;
     if (tup == NULL) {
         time_t tt = time(NULL);
         buf = *localtime(&tt);
-    } else if (!gettmarg(tup, &buf))
-        return NULL;
-    p = asctime(&buf);
-    if (p == NULL) {
-        PyErr_SetString(PyExc_ValueError, "invalid time");
+    } else if (!gettmarg(tup, &buf)
+               || !checktm(&buf)) {
         return NULL;
     }
-    if (p[24] == '\n')
-        p[24] = '\0';
-    return PyString_FromString(p);
+    return _asctime(&buf);
 }
 
 PyDoc_STRVAR(asctime_doc,
@@ -593,7 +689,7 @@ time_ctime(PyObject *self, PyObject *args)
 {
     PyObject *ot = NULL;
     time_t tt;
-    char *p;
+    struct tm *buf;
 
     if (!PyArg_UnpackTuple(args, "ctime", 0, 1, &ot))
         return NULL;
@@ -607,14 +703,16 @@ time_ctime(PyObject *self, PyObject *args)
         if (tt == (time_t)-1 && PyErr_Occurred())
             return NULL;
     }
-    p = ctime(&tt);
-    if (p == NULL) {
-        PyErr_SetString(PyExc_ValueError, "unconvertible time");
-        return NULL;
+    buf = localtime(&tt);
+    if (buf == NULL) {
+#ifdef EINVAL
+        if (errno == 0) {
+            errno = EINVAL;
+        }
+#endif
+        return PyErr_SetFromErrno(PyExc_ValueError);
     }
-    if (p[24] == '\n')
-        p[24] = '\0';
-    return PyString_FromString(p);
+    return _asctime(buf);
 }
 
 PyDoc_STRVAR(ctime_doc,
index 65857bf0b396a14895be806feee11cd4b4d50b28..d2297f306f44d0ae64ac3d26e6a42fd32378b038 100644 (file)
@@ -34,7 +34,7 @@ get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size,
     else {
         Py_ssize_t count, offset;
         readbufferproc proc = 0;
-        PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer;
+        PyBufferProcs *bp = Py_TYPE(self->b_base)->tp_as_buffer;
         if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) {
             PyErr_SetString(PyExc_TypeError,
                 "single-segment buffer object expected");
@@ -47,7 +47,7 @@ get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size,
             (buffer_type == ANY_BUFFER))
             proc = (readbufferproc)bp->bf_getwritebuffer;
         else if (buffer_type == CHAR_BUFFER) {
-            if (!PyType_HasFeature(self->ob_type,
+            if (!PyType_HasFeature(Py_TYPE(self),
                         Py_TPFLAGS_HAVE_GETCHARBUFFER)) {
             PyErr_SetString(PyExc_TypeError,
                 "Py_TPFLAGS_HAVE_GETCHARBUFFER needed");
index 72f2ad8eea39797891e87a60417e395607dbafd6..04c25061ef52d21676297a1e007a107d451934b4 100644 (file)
@@ -164,6 +164,26 @@ PyByteArray_FromObject(PyObject *input)
                                         input, NULL);
 }
 
+static PyObject *
+_PyByteArray_FromBufferObject(PyObject *obj)
+{
+    PyObject *result;
+    Py_buffer view;
+
+    if (PyObject_GetBuffer(obj, &view, PyBUF_FULL_RO) < 0) {
+        return NULL;
+    }
+    result = PyByteArray_FromStringAndSize(NULL, view.len);
+    if (result != NULL &&
+        PyBuffer_ToContiguous(PyByteArray_AS_STRING(result),
+                              &view, view.len, 'C') < 0)
+    {
+        Py_CLEAR(result);
+    }
+    PyBuffer_Release(&view);
+    return result;
+}
+
 PyObject *
 PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size)
 {
@@ -483,7 +503,8 @@ bytearray_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi,
     if (values == (PyObject *)self) {
         /* Make a copy and call this function recursively */
         int err;
-        values = PyByteArray_FromObject(values);
+        values = PyByteArray_FromStringAndSize(PyByteArray_AS_STRING(values),
+                                               PyByteArray_GET_SIZE(values));
         if (values == NULL)
             return -1;
         err = bytearray_setslice(self, lo, hi, values);
@@ -2098,7 +2119,7 @@ bytearray_partition(PyByteArrayObject *self, PyObject *sep_obj)
 {
     PyObject *bytesep, *result;
 
-    bytesep = PyByteArray_FromObject(sep_obj);
+    bytesep = _PyByteArray_FromBufferObject(sep_obj);
     if (! bytesep)
         return NULL;
 
@@ -2126,7 +2147,7 @@ bytearray_rpartition(PyByteArrayObject *self, PyObject *sep_obj)
 {
     PyObject *bytesep, *result;
 
-    bytesep = PyByteArray_FromObject(sep_obj);
+    bytesep = _PyByteArray_FromBufferObject(sep_obj);
     if (! bytesep)
         return NULL;
 
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
new file mode 100644 (file)
index 0000000..7ba90aa
--- /dev/null
@@ -0,0 +1,3432 @@
+/* bytes object implementation */
+
+#define PY_SSIZE_T_CLEAN
+
+#include "Python.h"
+#include "internal/mem.h"
+#include "internal/pystate.h"
+
+#include "bytes_methods.h"
+#include "pystrhex.h"
+#include <stddef.h>
+
+/*[clinic input]
+class bytes "PyBytesObject *" "&PyBytes_Type"
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7a238f965d64892b]*/
+
+#include "clinic/bytesobject.c.h"
+
+#ifdef COUNT_ALLOCS
+Py_ssize_t null_strings, one_strings;
+#endif
+
+static PyBytesObject *characters[UCHAR_MAX + 1];
+static PyBytesObject *nullstring;
+
+/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
+   for a string of length n should request PyBytesObject_SIZE + n bytes.
+
+   Using PyBytesObject_SIZE instead of sizeof(PyBytesObject) saves
+   3 bytes per string allocation on a typical system.
+*/
+#define PyBytesObject_SIZE (offsetof(PyBytesObject, ob_sval) + 1)
+
+/* Forward declaration */
+Py_LOCAL_INLINE(Py_ssize_t) _PyBytesWriter_GetSize(_PyBytesWriter *writer,
+                                                   char *str);
+
+/*
+   For PyBytes_FromString(), the parameter `str' points to a null-terminated
+   string containing exactly `size' bytes.
+
+   For PyBytes_FromStringAndSize(), the parameter `str' is
+   either NULL or else points to a string containing at least `size' bytes.
+   For PyBytes_FromStringAndSize(), the string in the `str' parameter does
+   not have to be null-terminated.  (Therefore it is safe to construct a
+   substring by calling `PyBytes_FromStringAndSize(origstring, substrlen)'.)
+   If `str' is NULL then PyBytes_FromStringAndSize() will allocate `size+1'
+   bytes (setting the last byte to the null terminating character) and you can
+   fill in the data yourself.  If `str' is non-NULL then the resulting
+   PyBytes object must be treated as immutable and you must not fill in nor
+   alter the data yourself, since the strings may be shared.
+
+   The PyObject member `op->ob_size', which denotes the number of "extra
+   items" in a variable-size object, will contain the number of bytes
+   allocated for string data, not counting the null terminating character.
+   It is therefore equal to the `size' parameter (for
+   PyBytes_FromStringAndSize()) or the length of the string in the `str'
+   parameter (for PyBytes_FromString()).
+*/
+static PyObject *
+_PyBytes_FromSize(Py_ssize_t size, int use_calloc)
+{
+    PyBytesObject *op;
+    assert(size >= 0);
+
+    if (size == 0 && (op = nullstring) != NULL) {
+#ifdef COUNT_ALLOCS
+        null_strings++;
+#endif
+        Py_INCREF(op);
+        return (PyObject *)op;
+    }
+
+    if ((size_t)size > (size_t)PY_SSIZE_T_MAX - PyBytesObject_SIZE) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "byte string is too large");
+        return NULL;
+    }
+
+    /* Inline PyObject_NewVar */
+    if (use_calloc)
+        op = (PyBytesObject *)PyObject_Calloc(1, PyBytesObject_SIZE + size);
+    else
+        op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size);
+    if (op == NULL)
+        return PyErr_NoMemory();
+    (void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
+    op->ob_shash = -1;
+    if (!use_calloc)
+        op->ob_sval[size] = '\0';
+    /* empty byte string singleton */
+    if (size == 0) {
+        nullstring = op;
+        Py_INCREF(op);
+    }
+    return (PyObject *) op;
+}
+
+PyObject *
+PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
+{
+    PyBytesObject *op;
+    if (size < 0) {
+        PyErr_SetString(PyExc_SystemError,
+            "Negative size passed to PyBytes_FromStringAndSize");
+        return NULL;
+    }
+    if (size == 1 && str != NULL &&
+        (op = characters[*str & UCHAR_MAX]) != NULL)
+    {
+#ifdef COUNT_ALLOCS
+        one_strings++;
+#endif
+        Py_INCREF(op);
+        return (PyObject *)op;
+    }
+
+    op = (PyBytesObject *)_PyBytes_FromSize(size, 0);
+    if (op == NULL)
+        return NULL;
+    if (str == NULL)
+        return (PyObject *) op;
+
+    memcpy(op->ob_sval, str, size);
+    /* share short strings */
+    if (size == 1) {
+        characters[*str & UCHAR_MAX] = op;
+        Py_INCREF(op);
+    }
+    return (PyObject *) op;
+}
+
+PyObject *
+PyBytes_FromString(const char *str)
+{
+    size_t size;
+    PyBytesObject *op;
+
+    assert(str != NULL);
+    size = strlen(str);
+    if (size > PY_SSIZE_T_MAX - PyBytesObject_SIZE) {
+        PyErr_SetString(PyExc_OverflowError,
+            "byte string is too long");
+        return NULL;
+    }
+    if (size == 0 && (op = nullstring) != NULL) {
+#ifdef COUNT_ALLOCS
+        null_strings++;
+#endif
+        Py_INCREF(op);
+        return (PyObject *)op;
+    }
+    if (size == 1 && (op = characters[*str & UCHAR_MAX]) != NULL) {
+#ifdef COUNT_ALLOCS
+        one_strings++;
+#endif
+        Py_INCREF(op);
+        return (PyObject *)op;
+    }
+
+    /* Inline PyObject_NewVar */
+    op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
+    if (op == NULL)
+        return PyErr_NoMemory();
+    (void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
+    op->ob_shash = -1;
+    memcpy(op->ob_sval, str, size+1);
+    /* share short strings */
+    if (size == 0) {
+        nullstring = op;
+        Py_INCREF(op);
+    } else if (size == 1) {
+        characters[*str & UCHAR_MAX] = op;
+        Py_INCREF(op);
+    }
+    return (PyObject *) op;
+}
+
+PyObject *
+PyBytes_FromFormatV(const char *format, va_list vargs)
+{
+    char *s;
+    const char *f;
+    const char *p;
+    Py_ssize_t prec;
+    int longflag;
+    int size_tflag;
+    /* Longest 64-bit formatted numbers:
+       - "18446744073709551615\0" (21 bytes)
+       - "-9223372036854775808\0" (21 bytes)
+       Decimal takes the most space (it isn't enough for octal.)
+
+       Longest 64-bit pointer representation:
+       "0xffffffffffffffff\0" (19 bytes). */
+    char buffer[21];
+    _PyBytesWriter writer;
+
+    _PyBytesWriter_Init(&writer);
+
+    s = _PyBytesWriter_Alloc(&writer, strlen(format));
+    if (s == NULL)
+        return NULL;
+    writer.overallocate = 1;
+
+#define WRITE_BYTES(str) \
+    do { \
+        s = _PyBytesWriter_WriteBytes(&writer, s, (str), strlen(str)); \
+        if (s == NULL) \
+            goto error; \
+    } while (0)
+
+    for (f = format; *f; f++) {
+        if (*f != '%') {
+            *s++ = *f;
+            continue;
+        }
+
+        p = f++;
+
+        /* ignore the width (ex: 10 in "%10s") */
+        while (Py_ISDIGIT(*f))
+            f++;
+
+        /* parse the precision (ex: 10 in "%.10s") */
+        prec = 0;
+        if (*f == '.') {
+            f++;
+            for (; Py_ISDIGIT(*f); f++) {
+                prec = (prec * 10) + (*f - '0');
+            }
+        }
+
+        while (*f && *f != '%' && !Py_ISALPHA(*f))
+            f++;
+
+        /* handle the long flag ('l'), but only for %ld and %lu.
+           others can be added when necessary. */
+        longflag = 0;
+        if (*f == 'l' && (f[1] == 'd' || f[1] == 'u')) {
+            longflag = 1;
+            ++f;
+        }
+
+        /* handle the size_t flag ('z'). */
+        size_tflag = 0;
+        if (*f == 'z' && (f[1] == 'd' || f[1] == 'u')) {
+            size_tflag = 1;
+            ++f;
+        }
+
+        /* subtract bytes preallocated for the format string
+           (ex: 2 for "%s") */
+        writer.min_size -= (f - p + 1);
+
+        switch (*f) {
+        case 'c':
+        {
+            int c = va_arg(vargs, int);
+            if (c < 0 || c > 255) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "PyBytes_FromFormatV(): %c format "
+                                "expects an integer in range [0; 255]");
+                goto error;
+            }
+            writer.min_size++;
+            *s++ = (unsigned char)c;
+            break;
+        }
+
+        case 'd':
+            if (longflag)
+                sprintf(buffer, "%ld", va_arg(vargs, long));
+            else if (size_tflag)
+                sprintf(buffer, "%" PY_FORMAT_SIZE_T "d",
+                    va_arg(vargs, Py_ssize_t));
+            else
+                sprintf(buffer, "%d", va_arg(vargs, int));
+            assert(strlen(buffer) < sizeof(buffer));
+            WRITE_BYTES(buffer);
+            break;
+
+        case 'u':
+            if (longflag)
+                sprintf(buffer, "%lu",
+                    va_arg(vargs, unsigned long));
+            else if (size_tflag)
+                sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
+                    va_arg(vargs, size_t));
+            else
+                sprintf(buffer, "%u",
+                    va_arg(vargs, unsigned int));
+            assert(strlen(buffer) < sizeof(buffer));
+            WRITE_BYTES(buffer);
+            break;
+
+        case 'i':
+            sprintf(buffer, "%i", va_arg(vargs, int));
+            assert(strlen(buffer) < sizeof(buffer));
+            WRITE_BYTES(buffer);
+            break;
+
+        case 'x':
+            sprintf(buffer, "%x", va_arg(vargs, int));
+            assert(strlen(buffer) < sizeof(buffer));
+            WRITE_BYTES(buffer);
+            break;
+
+        case 's':
+        {
+            Py_ssize_t i;
+
+            p = va_arg(vargs, const char*);
+            i = strlen(p);
+            if (prec > 0 && i > prec)
+                i = prec;
+            s = _PyBytesWriter_WriteBytes(&writer, s, p, i);
+            if (s == NULL)
+                goto error;
+            break;
+        }
+
+        case 'p':
+            sprintf(buffer, "%p", va_arg(vargs, void*));
+            assert(strlen(buffer) < sizeof(buffer));
+            /* %p is ill-defined:  ensure leading 0x. */
+            if (buffer[1] == 'X')
+                buffer[1] = 'x';
+            else if (buffer[1] != 'x') {
+                memmove(buffer+2, buffer, strlen(buffer)+1);
+                buffer[0] = '0';
+                buffer[1] = 'x';
+            }
+            WRITE_BYTES(buffer);
+            break;
+
+        case '%':
+            writer.min_size++;
+            *s++ = '%';
+            break;
+
+        default:
+            if (*f == 0) {
+                /* fix min_size if we reached the end of the format string */
+                writer.min_size++;
+            }
+
+            /* invalid format string: copy unformatted string and exit */
+            WRITE_BYTES(p);
+            return _PyBytesWriter_Finish(&writer, s);
+        }
+    }
+
+#undef WRITE_BYTES
+
+    return _PyBytesWriter_Finish(&writer, s);
+
+ error:
+    _PyBytesWriter_Dealloc(&writer);
+    return NULL;
+}
+
+PyObject *
+PyBytes_FromFormat(const char *format, ...)
+{
+    PyObject* ret;
+    va_list vargs;
+
+#ifdef HAVE_STDARG_PROTOTYPES
+    va_start(vargs, format);
+#else
+    va_start(vargs);
+#endif
+    ret = PyBytes_FromFormatV(format, vargs);
+    va_end(vargs);
+    return ret;
+}
+
+/* Helpers for formatstring */
+
+Py_LOCAL_INLINE(PyObject *)
+getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx)
+{
+    Py_ssize_t argidx = *p_argidx;
+    if (argidx < arglen) {
+        (*p_argidx)++;
+        if (arglen < 0)
+            return args;
+        else
+            return PyTuple_GetItem(args, argidx);
+    }
+    PyErr_SetString(PyExc_TypeError,
+                    "not enough arguments for format string");
+    return NULL;
+}
+
+/* Format codes
+ * F_LJUST      '-'
+ * F_SIGN       '+'
+ * F_BLANK      ' '
+ * F_ALT        '#'
+ * F_ZERO       '0'
+ */
+#define F_LJUST (1<<0)
+#define F_SIGN  (1<<1)
+#define F_BLANK (1<<2)
+#define F_ALT   (1<<3)
+#define F_ZERO  (1<<4)
+
+/* Returns a new reference to a PyBytes object, or NULL on failure. */
+
+static char*
+formatfloat(PyObject *v, int flags, int prec, int type,
+            PyObject **p_result, _PyBytesWriter *writer, char *str)
+{
+    char *p;
+    PyObject *result;
+    double x;
+    size_t len;
+
+    x = PyFloat_AsDouble(v);
+    if (x == -1.0 && PyErr_Occurred()) {
+        PyErr_Format(PyExc_TypeError, "float argument required, "
+                     "not %.200s", Py_TYPE(v)->tp_name);
+        return NULL;
+    }
+
+    if (prec < 0)
+        prec = 6;
+
+    p = PyOS_double_to_string(x, type, prec,
+                              (flags & F_ALT) ? Py_DTSF_ALT : 0, NULL);
+
+    if (p == NULL)
+        return NULL;
+
+    len = strlen(p);
+    if (writer != NULL) {
+        str = _PyBytesWriter_Prepare(writer, str, len);
+        if (str == NULL)
+            return NULL;
+        memcpy(str, p, len);
+        PyMem_Free(p);
+        str += len;
+        return str;
+    }
+
+    result = PyBytes_FromStringAndSize(p, len);
+    PyMem_Free(p);
+    *p_result = result;
+    return str;
+}
+
+static PyObject *
+formatlong(PyObject *v, int flags, int prec, int type)
+{
+    PyObject *result, *iobj;
+    if (type == 'i')
+        type = 'd';
+    if (PyLong_Check(v))
+        return _PyUnicode_FormatLong(v, flags & F_ALT, prec, type);
+    if (PyNumber_Check(v)) {
+        /* make sure number is a type of integer for o, x, and X */
+        if (type == 'o' || type == 'x' || type == 'X')
+            iobj = PyNumber_Index(v);
+        else
+            iobj = PyNumber_Long(v);
+        if (iobj == NULL) {
+            if (!PyErr_ExceptionMatches(PyExc_TypeError))
+                return NULL;
+        }
+        else if (!PyLong_Check(iobj))
+            Py_CLEAR(iobj);
+        if (iobj != NULL) {
+            result = _PyUnicode_FormatLong(iobj, flags & F_ALT, prec, type);
+            Py_DECREF(iobj);
+            return result;
+        }
+    }
+    PyErr_Format(PyExc_TypeError,
+        "%%%c format: %s is required, not %.200s", type,
+        (type == 'o' || type == 'x' || type == 'X') ? "an integer"
+                                                    : "a number",
+        Py_TYPE(v)->tp_name);
+    return NULL;
+}
+
+static int
+byte_converter(PyObject *arg, char *p)
+{
+    if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
+        *p = PyBytes_AS_STRING(arg)[0];
+        return 1;
+    }
+    else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
+        *p = PyByteArray_AS_STRING(arg)[0];
+        return 1;
+    }
+    else {
+        PyObject *iobj;
+        long ival;
+        int overflow;
+        /* make sure number is a type of integer */
+        if (PyLong_Check(arg)) {
+            ival = PyLong_AsLongAndOverflow(arg, &overflow);
+        }
+        else {
+            iobj = PyNumber_Index(arg);
+            if (iobj == NULL) {
+                if (!PyErr_ExceptionMatches(PyExc_TypeError))
+                    return 0;
+                goto onError;
+            }
+            ival = PyLong_AsLongAndOverflow(iobj, &overflow);
+            Py_DECREF(iobj);
+        }
+        if (!overflow && ival == -1 && PyErr_Occurred())
+            goto onError;
+        if (overflow || !(0 <= ival && ival <= 255)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "%c arg not in range(256)");
+            return 0;
+        }
+        *p = (char)ival;
+        return 1;
+    }
+  onError:
+    PyErr_SetString(PyExc_TypeError,
+        "%c requires an integer in range(256) or a single byte");
+    return 0;
+}
+
+static PyObject *_PyBytes_FromBuffer(PyObject *x);
+
+static PyObject *
+format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
+{
+    PyObject *func, *result;
+    _Py_IDENTIFIER(__bytes__);
+    /* is it a bytes object? */
+    if (PyBytes_Check(v)) {
+        *pbuf = PyBytes_AS_STRING(v);
+        *plen = PyBytes_GET_SIZE(v);
+        Py_INCREF(v);
+        return v;
+    }
+    if (PyByteArray_Check(v)) {
+        *pbuf = PyByteArray_AS_STRING(v);
+        *plen = PyByteArray_GET_SIZE(v);
+        Py_INCREF(v);
+        return v;
+    }
+    /* does it support __bytes__? */
+    func = _PyObject_LookupSpecial(v, &PyId___bytes__);
+    if (func != NULL) {
+        result = _PyObject_CallNoArg(func);
+        Py_DECREF(func);
+        if (result == NULL)
+            return NULL;
+        if (!PyBytes_Check(result)) {
+            PyErr_Format(PyExc_TypeError,
+                         "__bytes__ returned non-bytes (type %.200s)",
+                         Py_TYPE(result)->tp_name);
+            Py_DECREF(result);
+            return NULL;
+        }
+        *pbuf = PyBytes_AS_STRING(result);
+        *plen = PyBytes_GET_SIZE(result);
+        return result;
+    }
+    /* does it support buffer protocol? */
+    if (PyObject_CheckBuffer(v)) {
+        /* maybe we can avoid making a copy of the buffer object here? */
+        result = _PyBytes_FromBuffer(v);
+        if (result == NULL)
+            return NULL;
+        *pbuf = PyBytes_AS_STRING(result);
+        *plen = PyBytes_GET_SIZE(result);
+        return result;
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "%%b requires a bytes-like object, "
+                 "or an object that implements __bytes__, not '%.100s'",
+                 Py_TYPE(v)->tp_name);
+    return NULL;
+}
+
+/* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) */
+
+PyObject *
+_PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
+                  PyObject *args, int use_bytearray)
+{
+    const char *fmt;
+    char *res;
+    Py_ssize_t arglen, argidx;
+    Py_ssize_t fmtcnt;
+    int args_owned = 0;
+    PyObject *dict = NULL;
+    _PyBytesWriter writer;
+
+    if (args == NULL) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+    fmt = format;
+    fmtcnt = format_len;
+
+    _PyBytesWriter_Init(&writer);
+    writer.use_bytearray = use_bytearray;
+
+    res = _PyBytesWriter_Alloc(&writer, fmtcnt);
+    if (res == NULL)
+        return NULL;
+    if (!use_bytearray)
+        writer.overallocate = 1;
+
+    if (PyTuple_Check(args)) {
+        arglen = PyTuple_GET_SIZE(args);
+        argidx = 0;
+    }
+    else {
+        arglen = -1;
+        argidx = -2;
+    }
+    if (Py_TYPE(args)->tp_as_mapping && Py_TYPE(args)->tp_as_mapping->mp_subscript &&
+        !PyTuple_Check(args) && !PyBytes_Check(args) && !PyUnicode_Check(args) &&
+        !PyByteArray_Check(args)) {
+            dict = args;
+    }
+
+    while (--fmtcnt >= 0) {
+        if (*fmt != '%') {
+            Py_ssize_t len;
+            char *pos;
+
+            pos = (char *)memchr(fmt + 1, '%', fmtcnt);
+            if (pos != NULL)
+                len = pos - fmt;
+            else
+                len = fmtcnt + 1;
+            assert(len != 0);
+
+            memcpy(res, fmt, len);
+            res += len;
+            fmt += len;
+            fmtcnt -= (len - 1);
+        }
+        else {
+            /* Got a format specifier */
+            int flags = 0;
+            Py_ssize_t width = -1;
+            int prec = -1;
+            int c = '\0';
+            int fill;
+            PyObject *v = NULL;
+            PyObject *temp = NULL;
+            const char *pbuf = NULL;
+            int sign;
+            Py_ssize_t len = 0;
+            char onechar; /* For byte_converter() */
+            Py_ssize_t alloc;
+#ifdef Py_DEBUG
+            char *before;
+#endif
+
+            fmt++;
+            if (*fmt == '%') {
+                *res++ = '%';
+                fmt++;
+                fmtcnt--;
+                continue;
+            }
+            if (*fmt == '(') {
+                const char *keystart;
+                Py_ssize_t keylen;
+                PyObject *key;
+                int pcount = 1;
+
+                if (dict == NULL) {
+                    PyErr_SetString(PyExc_TypeError,
+                             "format requires a mapping");
+                    goto error;
+                }
+                ++fmt;
+                --fmtcnt;
+                keystart = fmt;
+                /* Skip over balanced parentheses */
+                while (pcount > 0 && --fmtcnt >= 0) {
+                    if (*fmt == ')')
+                        --pcount;
+                    else if (*fmt == '(')
+                        ++pcount;
+                    fmt++;
+                }
+                keylen = fmt - keystart - 1;
+                if (fmtcnt < 0 || pcount > 0) {
+                    PyErr_SetString(PyExc_ValueError,
+                               "incomplete format key");
+                    goto error;
+                }
+                key = PyBytes_FromStringAndSize(keystart,
+                                                 keylen);
+                if (key == NULL)
+                    goto error;
+                if (args_owned) {
+                    Py_DECREF(args);
+                    args_owned = 0;
+                }
+                args = PyObject_GetItem(dict, key);
+                Py_DECREF(key);
+                if (args == NULL) {
+                    goto error;
+                }
+                args_owned = 1;
+                arglen = -1;
+                argidx = -2;
+            }
+
+            /* Parse flags. Example: "%+i" => flags=F_SIGN. */
+            while (--fmtcnt >= 0) {
+                switch (c = *fmt++) {
+                case '-': flags |= F_LJUST; continue;
+                case '+': flags |= F_SIGN; continue;
+                case ' ': flags |= F_BLANK; continue;
+                case '#': flags |= F_ALT; continue;
+                case '0': flags |= F_ZERO; continue;
+                }
+                break;
+            }
+
+            /* Parse width. Example: "%10s" => width=10 */
+            if (c == '*') {
+                v = getnextarg(args, arglen, &argidx);
+                if (v == NULL)
+                    goto error;
+                if (!PyLong_Check(v)) {
+                    PyErr_SetString(PyExc_TypeError,
+                                    "* wants int");
+                    goto error;
+                }
+                width = PyLong_AsSsize_t(v);
+                if (width == -1 && PyErr_Occurred())
+                    goto error;
+                if (width < 0) {
+                    flags |= F_LJUST;
+                    width = -width;
+                }
+                if (--fmtcnt >= 0)
+                    c = *fmt++;
+            }
+            else if (c >= 0 && isdigit(c)) {
+                width = c - '0';
+                while (--fmtcnt >= 0) {
+                    c = Py_CHARMASK(*fmt++);
+                    if (!isdigit(c))
+                        break;
+                    if (width > (PY_SSIZE_T_MAX - ((int)c - '0')) / 10) {
+                        PyErr_SetString(
+                            PyExc_ValueError,
+                            "width too big");
+                        goto error;
+                    }
+                    width = width*10 + (c - '0');
+                }
+            }
+
+            /* Parse precision. Example: "%.3f" => prec=3 */
+            if (c == '.') {
+                prec = 0;
+                if (--fmtcnt >= 0)
+                    c = *fmt++;
+                if (c == '*') {
+                    v = getnextarg(args, arglen, &argidx);
+                    if (v == NULL)
+                        goto error;
+                    if (!PyLong_Check(v)) {
+                        PyErr_SetString(
+                            PyExc_TypeError,
+                            "* wants int");
+                        goto error;
+                    }
+                    prec = _PyLong_AsInt(v);
+                    if (prec == -1 && PyErr_Occurred())
+                        goto error;
+                    if (prec < 0)
+                        prec = 0;
+                    if (--fmtcnt >= 0)
+                        c = *fmt++;
+                }
+                else if (c >= 0 && isdigit(c)) {
+                    prec = c - '0';
+                    while (--fmtcnt >= 0) {
+                        c = Py_CHARMASK(*fmt++);
+                        if (!isdigit(c))
+                            break;
+                        if (prec > (INT_MAX - ((int)c - '0')) / 10) {
+                            PyErr_SetString(
+                                PyExc_ValueError,
+                                "prec too big");
+                            goto error;
+                        }
+                        prec = prec*10 + (c - '0');
+                    }
+                }
+            } /* prec */
+            if (fmtcnt >= 0) {
+                if (c == 'h' || c == 'l' || c == 'L') {
+                    if (--fmtcnt >= 0)
+                        c = *fmt++;
+                }
+            }
+            if (fmtcnt < 0) {
+                PyErr_SetString(PyExc_ValueError,
+                                "incomplete format");
+                goto error;
+            }
+            v = getnextarg(args, arglen, &argidx);
+            if (v == NULL)
+                goto error;
+
+            if (fmtcnt < 0) {
+                /* last writer: disable writer overallocation */
+                writer.overallocate = 0;
+            }
+
+            sign = 0;
+            fill = ' ';
+            switch (c) {
+            case 'r':
+                // %r is only for 2/3 code; 3 only code should use %a
+            case 'a':
+                temp = PyObject_ASCII(v);
+                if (temp == NULL)
+                    goto error;
+                assert(PyUnicode_IS_ASCII(temp));
+                pbuf = (const char *)PyUnicode_1BYTE_DATA(temp);
+                len = PyUnicode_GET_LENGTH(temp);
+                if (prec >= 0 && len > prec)
+                    len = prec;
+                break;
+
+            case 's':
+                // %s is only for 2/3 code; 3 only code should use %b
+            case 'b':
+                temp = format_obj(v, &pbuf, &len);
+                if (temp == NULL)
+                    goto error;
+                if (prec >= 0 && len > prec)
+                    len = prec;
+                break;
+
+            case 'i':
+            case 'd':
+            case 'u':
+            case 'o':
+            case 'x':
+            case 'X':
+                if (PyLong_CheckExact(v)
+                    && width == -1 && prec == -1
+                    && !(flags & (F_SIGN | F_BLANK))
+                    && c != 'X')
+                {
+                    /* Fast path */
+                    int alternate = flags & F_ALT;
+                    int base;
+
+                    switch(c)
+                    {
+                        default:
+                            Py_UNREACHABLE();
+                        case 'd':
+                        case 'i':
+                        case 'u':
+                            base = 10;
+                            break;
+                        case 'o':
+                            base = 8;
+                            break;
+                        case 'x':
+                        case 'X':
+                            base = 16;
+                            break;
+                    }
+
+                    /* Fast path */
+                    writer.min_size -= 2; /* size preallocated for "%d" */
+                    res = _PyLong_FormatBytesWriter(&writer, res,
+                                                    v, base, alternate);
+                    if (res == NULL)
+                        goto error;
+                    continue;
+                }
+
+                temp = formatlong(v, flags, prec, c);
+                if (!temp)
+                    goto error;
+                assert(PyUnicode_IS_ASCII(temp));
+                pbuf = (const char *)PyUnicode_1BYTE_DATA(temp);
+                len = PyUnicode_GET_LENGTH(temp);
+                sign = 1;
+                if (flags & F_ZERO)
+                    fill = '0';
+                break;
+
+            case 'e':
+            case 'E':
+            case 'f':
+            case 'F':
+            case 'g':
+            case 'G':
+                if (width == -1 && prec == -1
+                    && !(flags & (F_SIGN | F_BLANK)))
+                {
+                    /* Fast path */
+                    writer.min_size -= 2; /* size preallocated for "%f" */
+                    res = formatfloat(v, flags, prec, c, NULL, &writer, res);
+                    if (res == NULL)
+                        goto error;
+                    continue;
+                }
+
+                if (!formatfloat(v, flags, prec, c, &temp, NULL, res))
+                    goto error;
+                pbuf = PyBytes_AS_STRING(temp);
+                len = PyBytes_GET_SIZE(temp);
+                sign = 1;
+                if (flags & F_ZERO)
+                    fill = '0';
+                break;
+
+            case 'c':
+                pbuf = &onechar;
+                len = byte_converter(v, &onechar);
+                if (!len)
+                    goto error;
+                if (width == -1) {
+                    /* Fast path */
+                    *res++ = onechar;
+                    continue;
+                }
+                break;
+
+            default:
+                PyErr_Format(PyExc_ValueError,
+                  "unsupported format character '%c' (0x%x) "
+                  "at index %zd",
+                  c, c,
+                  (Py_ssize_t)(fmt - 1 - format));
+                goto error;
+            }
+
+            if (sign) {
+                if (*pbuf == '-' || *pbuf == '+') {
+                    sign = *pbuf++;
+                    len--;
+                }
+                else if (flags & F_SIGN)
+                    sign = '+';
+                else if (flags & F_BLANK)
+                    sign = ' ';
+                else
+                    sign = 0;
+            }
+            if (width < len)
+                width = len;
+
+            alloc = width;
+            if (sign != 0 && len == width)
+                alloc++;
+            /* 2: size preallocated for %s */
+            if (alloc > 2) {
+                res = _PyBytesWriter_Prepare(&writer, res, alloc - 2);
+                if (res == NULL)
+                    goto error;
+            }
+#ifdef Py_DEBUG
+            before = res;
+#endif
+
+            /* Write the sign if needed */
+            if (sign) {
+                if (fill != ' ')
+                    *res++ = sign;
+                if (width > len)
+                    width--;
+            }
+
+            /* Write the numeric prefix for "x", "X" and "o" formats
+               if the alternate form is used.
+               For example, write "0x" for the "%#x" format. */
+            if ((flags & F_ALT) && (c == 'o' || c == 'x' || c == 'X')) {
+                assert(pbuf[0] == '0');
+                assert(pbuf[1] == c);
+                if (fill != ' ') {
+                    *res++ = *pbuf++;
+                    *res++ = *pbuf++;
+                }
+                width -= 2;
+                if (width < 0)
+                    width = 0;
+                len -= 2;
+            }
+
+            /* Pad left with the fill character if needed */
+            if (width > len && !(flags & F_LJUST)) {
+                memset(res, fill, width - len);
+                res += (width - len);
+                width = len;
+            }
+
+            /* If padding with spaces: write sign if needed and/or numeric
+               prefix if the alternate form is used */
+            if (fill == ' ') {
+                if (sign)
+                    *res++ = sign;
+                if ((flags & F_ALT) && (c == 'o' || c == 'x' || c == 'X')) {
+                    assert(pbuf[0] == '0');
+                    assert(pbuf[1] == c);
+                    *res++ = *pbuf++;
+                    *res++ = *pbuf++;
+                }
+            }
+
+            /* Copy bytes */
+            memcpy(res, pbuf, len);
+            res += len;
+
+            /* Pad right with the fill character if needed */
+            if (width > len) {
+                memset(res, ' ', width - len);
+                res += (width - len);
+            }
+
+            if (dict && (argidx < arglen)) {
+                PyErr_SetString(PyExc_TypeError,
+                           "not all arguments converted during bytes formatting");
+                Py_XDECREF(temp);
+                goto error;
+            }
+            Py_XDECREF(temp);
+
+#ifdef Py_DEBUG
+            /* check that we computed the exact size for this write */
+            assert((res - before) == alloc);
+#endif
+        } /* '%' */
+
+        /* If overallocation was disabled, ensure that it was the last
+           write. Otherwise, we missed an optimization */
+        assert(writer.overallocate || fmtcnt < 0 || use_bytearray);
+    } /* until end */
+
+    if (argidx < arglen && !dict) {
+        PyErr_SetString(PyExc_TypeError,
+                        "not all arguments converted during bytes formatting");
+        goto error;
+    }
+
+    if (args_owned) {
+        Py_DECREF(args);
+    }
+    return _PyBytesWriter_Finish(&writer, res);
+
+ error:
+    _PyBytesWriter_Dealloc(&writer);
+    if (args_owned) {
+        Py_DECREF(args);
+    }
+    return NULL;
+}
+
+/* =-= */
+
+static void
+bytes_dealloc(PyObject *op)
+{
+    Py_TYPE(op)->tp_free(op);
+}
+
+/* Unescape a backslash-escaped string. If unicode is non-zero,
+   the string is a u-literal. If recode_encoding is non-zero,
+   the string is UTF-8 encoded and should be re-encoded in the
+   specified encoding.  */
+
+static char *
+_PyBytes_DecodeEscapeRecode(const char **s, const char *end,
+                            const char *errors, const char *recode_encoding,
+                            _PyBytesWriter *writer, char *p)
+{
+    PyObject *u, *w;
+    const char* t;
+
+    t = *s;
+    /* Decode non-ASCII bytes as UTF-8. */
+    while (t < end && (*t & 0x80))
+        t++;
+    u = PyUnicode_DecodeUTF8(*s, t - *s, errors);
+    if (u == NULL)
+        return NULL;
+
+    /* Recode them in target encoding. */
+    w = PyUnicode_AsEncodedString(u, recode_encoding, errors);
+    Py_DECREF(u);
+    if  (w == NULL)
+        return NULL;
+    assert(PyBytes_Check(w));
+
+    /* Append bytes to output buffer. */
+    writer->min_size--;   /* subtract 1 preallocated byte */
+    p = _PyBytesWriter_WriteBytes(writer, p,
+                                  PyBytes_AS_STRING(w),
+                                  PyBytes_GET_SIZE(w));
+    Py_DECREF(w);
+    if (p == NULL)
+        return NULL;
+
+    *s = t;
+    return p;
+}
+
+PyObject *_PyBytes_DecodeEscape(const char *s,
+                                Py_ssize_t len,
+                                const char *errors,
+                                Py_ssize_t unicode,
+                                const char *recode_encoding,
+                                const char **first_invalid_escape)
+{
+    int c;
+    char *p;
+    const char *end;
+    _PyBytesWriter writer;
+
+    _PyBytesWriter_Init(&writer);
+
+    p = _PyBytesWriter_Alloc(&writer, len);
+    if (p == NULL)
+        return NULL;
+    writer.overallocate = 1;
+
+    *first_invalid_escape = NULL;
+
+    end = s + len;
+    while (s < end) {
+        if (*s != '\\') {
+          non_esc:
+            if (!(recode_encoding && (*s & 0x80))) {
+                *p++ = *s++;
+            }
+            else {
+                /* non-ASCII character and need to recode */
+                p = _PyBytes_DecodeEscapeRecode(&s, end,
+                                                errors, recode_encoding,
+                                                &writer, p);
+                if (p == NULL)
+                    goto failed;
+            }
+            continue;
+        }
+
+        s++;
+        if (s == end) {
+            PyErr_SetString(PyExc_ValueError,
+                            "Trailing \\ in string");
+            goto failed;
+        }
+
+        switch (*s++) {
+        /* XXX This assumes ASCII! */
+        case '\n': break;
+        case '\\': *p++ = '\\'; break;
+        case '\'': *p++ = '\''; break;
+        case '\"': *p++ = '\"'; break;
+        case 'b': *p++ = '\b'; break;
+        case 'f': *p++ = '\014'; break; /* FF */
+        case 't': *p++ = '\t'; break;
+        case 'n': *p++ = '\n'; break;
+        case 'r': *p++ = '\r'; break;
+        case 'v': *p++ = '\013'; break; /* VT */
+        case 'a': *p++ = '\007'; break; /* BEL, not classic C */
+        case '0': case '1': case '2': case '3':
+        case '4': case '5': case '6': case '7':
+            c = s[-1] - '0';
+            if (s < end && '0' <= *s && *s <= '7') {
+                c = (c<<3) + *s++ - '0';
+                if (s < end && '0' <= *s && *s <= '7')
+                    c = (c<<3) + *s++ - '0';
+            }
+            *p++ = c;
+            break;
+        case 'x':
+            if (s+1 < end) {
+                int digit1, digit2;
+                digit1 = _PyLong_DigitValue[Py_CHARMASK(s[0])];
+                digit2 = _PyLong_DigitValue[Py_CHARMASK(s[1])];
+                if (digit1 < 16 && digit2 < 16) {
+                    *p++ = (unsigned char)((digit1 << 4) + digit2);
+                    s += 2;
+                    break;
+                }
+            }
+            /* invalid hexadecimal digits */
+
+            if (!errors || strcmp(errors, "strict") == 0) {
+                PyErr_Format(PyExc_ValueError,
+                             "invalid \\x escape at position %d",
+                             s - 2 - (end - len));
+                goto failed;
+            }
+            if (strcmp(errors, "replace") == 0) {
+                *p++ = '?';
+            } else if (strcmp(errors, "ignore") == 0)
+                /* do nothing */;
+            else {
+                PyErr_Format(PyExc_ValueError,
+                             "decoding error; unknown "
+                             "error handling code: %.400s",
+                             errors);
+                goto failed;
+            }
+            /* skip \x */
+            if (s < end && Py_ISXDIGIT(s[0]))
+                s++; /* and a hexdigit */
+            break;
+
+        default:
+            if (*first_invalid_escape == NULL) {
+                *first_invalid_escape = s-1; /* Back up one char, since we've
+                                                already incremented s. */
+            }
+            *p++ = '\\';
+            s--;
+            goto non_esc; /* an arbitrary number of unescaped
+                             UTF-8 bytes may follow. */
+        }
+    }
+
+    return _PyBytesWriter_Finish(&writer, p);
+
+  failed:
+    _PyBytesWriter_Dealloc(&writer);
+    return NULL;
+}
+
+PyObject *PyBytes_DecodeEscape(const char *s,
+                                Py_ssize_t len,
+                                const char *errors,
+                                Py_ssize_t unicode,
+                                const char *recode_encoding)
+{
+    const char* first_invalid_escape;
+    PyObject *result = _PyBytes_DecodeEscape(s, len, errors, unicode,
+                                             recode_encoding,
+                                             &first_invalid_escape);
+    if (result == NULL)
+        return NULL;
+    if (first_invalid_escape != NULL) {
+        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+                             "invalid escape sequence '\\%c'",
+                             (unsigned char)*first_invalid_escape) < 0) {
+            Py_DECREF(result);
+            return NULL;
+        }
+    }
+    return result;
+
+}
+/* -------------------------------------------------------------------- */
+/* object api */
+
+Py_ssize_t
+PyBytes_Size(PyObject *op)
+{
+    if (!PyBytes_Check(op)) {
+        PyErr_Format(PyExc_TypeError,
+             "expected bytes, %.200s found", Py_TYPE(op)->tp_name);
+        return -1;
+    }
+    return Py_SIZE(op);
+}
+
+char *
+PyBytes_AsString(PyObject *op)
+{
+    if (!PyBytes_Check(op)) {
+        PyErr_Format(PyExc_TypeError,
+             "expected bytes, %.200s found", Py_TYPE(op)->tp_name);
+        return NULL;
+    }
+    return ((PyBytesObject *)op)->ob_sval;
+}
+
+int
+PyBytes_AsStringAndSize(PyObject *obj,
+                         char **s,
+                         Py_ssize_t *len)
+{
+    if (s == NULL) {
+        PyErr_BadInternalCall();
+        return -1;
+    }
+
+    if (!PyBytes_Check(obj)) {
+        PyErr_Format(PyExc_TypeError,
+             "expected bytes, %.200s found", Py_TYPE(obj)->tp_name);
+        return -1;
+    }
+
+    *s = PyBytes_AS_STRING(obj);
+    if (len != NULL)
+        *len = PyBytes_GET_SIZE(obj);
+    else if (strlen(*s) != (size_t)PyBytes_GET_SIZE(obj)) {
+        PyErr_SetString(PyExc_ValueError,
+                        "embedded null byte");
+        return -1;
+    }
+    return 0;
+}
+
+/* -------------------------------------------------------------------- */
+/* Methods */
+
+#include "stringlib/stringdefs.h"
+
+#include "stringlib/fastsearch.h"
+#include "stringlib/count.h"
+#include "stringlib/find.h"
+#include "stringlib/join.h"
+#include "stringlib/partition.h"
+#include "stringlib/split.h"
+#include "stringlib/ctype.h"
+
+#include "stringlib/transmogrify.h"
+
+PyObject *
+PyBytes_Repr(PyObject *obj, int smartquotes)
+{
+    PyBytesObject* op = (PyBytesObject*) obj;
+    Py_ssize_t i, length = Py_SIZE(op);
+    Py_ssize_t newsize, squotes, dquotes;
+    PyObject *v;
+    unsigned char quote, *s, *p;
+
+    /* Compute size of output string */
+    squotes = dquotes = 0;
+    newsize = 3; /* b'' */
+    s = (unsigned char*)op->ob_sval;
+    for (i = 0; i < length; i++) {
+        Py_ssize_t incr = 1;
+        switch(s[i]) {
+        case '\'': squotes++; break;
+        case '"':  dquotes++; break;
+        case '\\': case '\t': case '\n': case '\r':
+            incr = 2; break; /* \C */
+        default:
+            if (s[i] < ' ' || s[i] >= 0x7f)
+                incr = 4; /* \xHH */
+        }
+        if (newsize > PY_SSIZE_T_MAX - incr)
+            goto overflow;
+        newsize += incr;
+    }
+    quote = '\'';
+    if (smartquotes && squotes && !dquotes)
+        quote = '"';
+    if (squotes && quote == '\'') {
+        if (newsize > PY_SSIZE_T_MAX - squotes)
+            goto overflow;
+        newsize += squotes;
+    }
+
+    v = PyUnicode_New(newsize, 127);
+    if (v == NULL) {
+        return NULL;
+    }
+    p = PyUnicode_1BYTE_DATA(v);
+
+    *p++ = 'b', *p++ = quote;
+    for (i = 0; i < length; i++) {
+        unsigned char c = op->ob_sval[i];
+        if (c == quote || c == '\\')
+            *p++ = '\\', *p++ = c;
+        else if (c == '\t')
+            *p++ = '\\', *p++ = 't';
+        else if (c == '\n')
+            *p++ = '\\', *p++ = 'n';
+        else if (c == '\r')
+            *p++ = '\\', *p++ = 'r';
+        else if (c < ' ' || c >= 0x7f) {
+            *p++ = '\\';
+            *p++ = 'x';
+            *p++ = Py_hexdigits[(c & 0xf0) >> 4];
+            *p++ = Py_hexdigits[c & 0xf];
+        }
+        else
+            *p++ = c;
+    }
+    *p++ = quote;
+    assert(_PyUnicode_CheckConsistency(v, 1));
+    return v;
+
+  overflow:
+    PyErr_SetString(PyExc_OverflowError,
+                    "bytes object is too large to make repr");
+    return NULL;
+}
+
+static PyObject *
+bytes_repr(PyObject *op)
+{
+    return PyBytes_Repr(op, 1);
+}
+
+static PyObject *
+bytes_str(PyObject *op)
+{
+    if (Py_BytesWarningFlag) {
+        if (PyErr_WarnEx(PyExc_BytesWarning,
+                         "str() on a bytes instance", 1))
+            return NULL;
+    }
+    return bytes_repr(op);
+}
+
+static Py_ssize_t
+bytes_length(PyBytesObject *a)
+{
+    return Py_SIZE(a);
+}
+
+/* This is also used by PyBytes_Concat() */
+static PyObject *
+bytes_concat(PyObject *a, PyObject *b)
+{
+    Py_buffer va, vb;
+    PyObject *result = NULL;
+
+    va.len = -1;
+    vb.len = -1;
+    if (PyObject_GetBuffer(a, &va, PyBUF_SIMPLE) != 0 ||
+        PyObject_GetBuffer(b, &vb, PyBUF_SIMPLE) != 0) {
+        PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s",
+                     Py_TYPE(b)->tp_name, Py_TYPE(a)->tp_name);
+        goto done;
+    }
+
+    /* Optimize end cases */
+    if (va.len == 0 && PyBytes_CheckExact(b)) {
+        result = b;
+        Py_INCREF(result);
+        goto done;
+    }
+    if (vb.len == 0 && PyBytes_CheckExact(a)) {
+        result = a;
+        Py_INCREF(result);
+        goto done;
+    }
+
+    if (va.len > PY_SSIZE_T_MAX - vb.len) {
+        PyErr_NoMemory();
+        goto done;
+    }
+
+    result = PyBytes_FromStringAndSize(NULL, va.len + vb.len);
+    if (result != NULL) {
+        memcpy(PyBytes_AS_STRING(result), va.buf, va.len);
+        memcpy(PyBytes_AS_STRING(result) + va.len, vb.buf, vb.len);
+    }
+
+  done:
+    if (va.len != -1)
+        PyBuffer_Release(&va);
+    if (vb.len != -1)
+        PyBuffer_Release(&vb);
+    return result;
+}
+
+static PyObject *
+bytes_repeat(PyBytesObject *a, Py_ssize_t n)
+{
+    Py_ssize_t i;
+    Py_ssize_t j;
+    Py_ssize_t size;
+    PyBytesObject *op;
+    size_t nbytes;
+    if (n < 0)
+        n = 0;
+    /* watch out for overflows:  the size can overflow int,
+     * and the # of bytes needed can overflow size_t
+     */
+    if (n > 0 && Py_SIZE(a) > PY_SSIZE_T_MAX / n) {
+        PyErr_SetString(PyExc_OverflowError,
+            "repeated bytes are too long");
+        return NULL;
+    }
+    size = Py_SIZE(a) * n;
+    if (size == Py_SIZE(a) && PyBytes_CheckExact(a)) {
+        Py_INCREF(a);
+        return (PyObject *)a;
+    }
+    nbytes = (size_t)size;
+    if (nbytes + PyBytesObject_SIZE <= nbytes) {
+        PyErr_SetString(PyExc_OverflowError,
+            "repeated bytes are too long");
+        return NULL;
+    }
+    op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes);
+    if (op == NULL)
+        return PyErr_NoMemory();
+    (void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
+    op->ob_shash = -1;
+    op->ob_sval[size] = '\0';
+    if (Py_SIZE(a) == 1 && n > 0) {
+        memset(op->ob_sval, a->ob_sval[0] , n);
+        return (PyObject *) op;
+    }
+    i = 0;
+    if (i < size) {
+        memcpy(op->ob_sval, a->ob_sval, Py_SIZE(a));
+        i = Py_SIZE(a);
+    }
+    while (i < size) {
+        j = (i <= size-i)  ?  i  :  size-i;
+        memcpy(op->ob_sval+i, op->ob_sval, j);
+        i += j;
+    }
+    return (PyObject *) op;
+}
+
+static int
+bytes_contains(PyObject *self, PyObject *arg)
+{
+    return _Py_bytes_contains(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), arg);
+}
+
+static PyObject *
+bytes_item(PyBytesObject *a, Py_ssize_t i)
+{
+    if (i < 0 || i >= Py_SIZE(a)) {
+        PyErr_SetString(PyExc_IndexError, "index out of range");
+        return NULL;
+    }
+    return PyLong_FromLong((unsigned char)a->ob_sval[i]);
+}
+
+static int
+bytes_compare_eq(PyBytesObject *a, PyBytesObject *b)
+{
+    int cmp;
+    Py_ssize_t len;
+
+    len = Py_SIZE(a);
+    if (Py_SIZE(b) != len)
+        return 0;
+
+    if (a->ob_sval[0] != b->ob_sval[0])
+        return 0;
+
+    cmp = memcmp(a->ob_sval, b->ob_sval, len);
+    return (cmp == 0);
+}
+
+static PyObject*
+bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
+{
+    int c;
+    Py_ssize_t len_a, len_b;
+    Py_ssize_t min_len;
+    PyObject *result;
+    int rc;
+
+    /* Make sure both arguments are strings. */
+    if (!(PyBytes_Check(a) && PyBytes_Check(b))) {
+        if (Py_BytesWarningFlag && (op == Py_EQ || op == Py_NE)) {
+            rc = PyObject_IsInstance((PyObject*)a,
+                                     (PyObject*)&PyUnicode_Type);
+            if (!rc)
+                rc = PyObject_IsInstance((PyObject*)b,
+                                         (PyObject*)&PyUnicode_Type);
+            if (rc < 0)
+                return NULL;
+            if (rc) {
+                if (PyErr_WarnEx(PyExc_BytesWarning,
+                                 "Comparison between bytes and string", 1))
+                    return NULL;
+            }
+            else {
+                rc = PyObject_IsInstance((PyObject*)a,
+                                         (PyObject*)&PyLong_Type);
+                if (!rc)
+                    rc = PyObject_IsInstance((PyObject*)b,
+                                             (PyObject*)&PyLong_Type);
+                if (rc < 0)
+                    return NULL;
+                if (rc) {
+                    if (PyErr_WarnEx(PyExc_BytesWarning,
+                                     "Comparison between bytes and int", 1))
+                        return NULL;
+                }
+            }
+        }
+        result = Py_NotImplemented;
+    }
+    else if (a == b) {
+        switch (op) {
+        case Py_EQ:
+        case Py_LE:
+        case Py_GE:
+            /* a string is equal to itself */
+            result = Py_True;
+            break;
+        case Py_NE:
+        case Py_LT:
+        case Py_GT:
+            result = Py_False;
+            break;
+        default:
+            PyErr_BadArgument();
+            return NULL;
+        }
+    }
+    else if (op == Py_EQ || op == Py_NE) {
+        int eq = bytes_compare_eq(a, b);
+        eq ^= (op == Py_NE);
+        result = eq ? Py_True : Py_False;
+    }
+    else {
+        len_a = Py_SIZE(a);
+        len_b = Py_SIZE(b);
+        min_len = Py_MIN(len_a, len_b);
+        if (min_len > 0) {
+            c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
+            if (c == 0)
+                c = memcmp(a->ob_sval, b->ob_sval, min_len);
+        }
+        else
+            c = 0;
+        if (c == 0)
+            c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
+        switch (op) {
+        case Py_LT: c = c <  0; break;
+        case Py_LE: c = c <= 0; break;
+        case Py_GT: c = c >  0; break;
+        case Py_GE: c = c >= 0; break;
+        default:
+            PyErr_BadArgument();
+            return NULL;
+        }
+        result = c ? Py_True : Py_False;
+    }
+
+    Py_INCREF(result);
+    return result;
+}
+
+static Py_hash_t
+bytes_hash(PyBytesObject *a)
+{
+    if (a->ob_shash == -1) {
+        /* Can't fail */
+        a->ob_shash = _Py_HashBytes(a->ob_sval, Py_SIZE(a));
+    }
+    return a->ob_shash;
+}
+
+static PyObject*
+bytes_subscript(PyBytesObject* self, PyObject* item)
+{
+    if (PyIndex_Check(item)) {
+        Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
+        if (i == -1 && PyErr_Occurred())
+            return NULL;
+        if (i < 0)
+            i += PyBytes_GET_SIZE(self);
+        if (i < 0 || i >= PyBytes_GET_SIZE(self)) {
+            PyErr_SetString(PyExc_IndexError,
+                            "index out of range");
+            return NULL;
+        }
+        return PyLong_FromLong((unsigned char)self->ob_sval[i]);
+    }
+    else if (PySlice_Check(item)) {
+        Py_ssize_t start, stop, step, slicelength, cur, i;
+        char* source_buf;
+        char* result_buf;
+        PyObject* result;
+
+        if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
+            return NULL;
+        }
+        slicelength = PySlice_AdjustIndices(PyBytes_GET_SIZE(self), &start,
+                                            &stop, step);
+
+        if (slicelength <= 0) {
+            return PyBytes_FromStringAndSize("", 0);
+        }
+        else if (start == 0 && step == 1 &&
+                 slicelength == PyBytes_GET_SIZE(self) &&
+                 PyBytes_CheckExact(self)) {
+            Py_INCREF(self);
+            return (PyObject *)self;
+        }
+        else if (step == 1) {
+            return PyBytes_FromStringAndSize(
+                PyBytes_AS_STRING(self) + start,
+                slicelength);
+        }
+        else {
+            source_buf = PyBytes_AS_STRING(self);
+            result = PyBytes_FromStringAndSize(NULL, slicelength);
+            if (result == NULL)
+                return NULL;
+
+            result_buf = PyBytes_AS_STRING(result);
+            for (cur = start, i = 0; i < slicelength;
+                 cur += step, i++) {
+                result_buf[i] = source_buf[cur];
+            }
+
+            return result;
+        }
+    }
+    else {
+        PyErr_Format(PyExc_TypeError,
+                     "byte indices must be integers or slices, not %.200s",
+                     Py_TYPE(item)->tp_name);
+        return NULL;
+    }
+}
+
+static int
+bytes_buffer_getbuffer(PyBytesObject *self, Py_buffer *view, int flags)
+{
+    return PyBuffer_FillInfo(view, (PyObject*)self, (void *)self->ob_sval, Py_SIZE(self),
+                             1, flags);
+}
+
+static PySequenceMethods bytes_as_sequence = {
+    (lenfunc)bytes_length, /*sq_length*/
+    (binaryfunc)bytes_concat, /*sq_concat*/
+    (ssizeargfunc)bytes_repeat, /*sq_repeat*/
+    (ssizeargfunc)bytes_item, /*sq_item*/
+    0,                  /*sq_slice*/
+    0,                  /*sq_ass_item*/
+    0,                  /*sq_ass_slice*/
+    (objobjproc)bytes_contains /*sq_contains*/
+};
+
+static PyMappingMethods bytes_as_mapping = {
+    (lenfunc)bytes_length,
+    (binaryfunc)bytes_subscript,
+    0,
+};
+
+static PyBufferProcs bytes_as_buffer = {
+    (getbufferproc)bytes_buffer_getbuffer,
+    NULL,
+};
+
+
+#define LEFTSTRIP 0
+#define RIGHTSTRIP 1
+#define BOTHSTRIP 2
+
+/*[clinic input]
+bytes.split
+
+    sep: object = None
+        The delimiter according which to split the bytes.
+        None (the default value) means split on ASCII whitespace characters
+        (space, tab, return, newline, formfeed, vertical tab).
+    maxsplit: Py_ssize_t = -1
+        Maximum number of splits to do.
+        -1 (the default value) means no limit.
+
+Return a list of the sections in the bytes, using sep as the delimiter.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit)
+/*[clinic end generated code: output=52126b5844c1d8ef input=8b809b39074abbfa]*/
+{
+    Py_ssize_t len = PyBytes_GET_SIZE(self), n;
+    const char *s = PyBytes_AS_STRING(self), *sub;
+    Py_buffer vsub;
+    PyObject *list;
+
+    if (maxsplit < 0)
+        maxsplit = PY_SSIZE_T_MAX;
+    if (sep == Py_None)
+        return stringlib_split_whitespace((PyObject*) self, s, len, maxsplit);
+    if (PyObject_GetBuffer(sep, &vsub, PyBUF_SIMPLE) != 0)
+        return NULL;
+    sub = vsub.buf;
+    n = vsub.len;
+
+    list = stringlib_split((PyObject*) self, s, len, sub, n, maxsplit);
+    PyBuffer_Release(&vsub);
+    return list;
+}
+
+/*[clinic input]
+bytes.partition
+
+    sep: Py_buffer
+    /
+
+Partition the bytes into three parts using the given separator.
+
+This will search for the separator sep in the bytes. If the separator is found,
+returns a 3-tuple containing the part before the separator, the separator
+itself, and the part after it.
+
+If the separator is not found, returns a 3-tuple containing the original bytes
+object and two empty bytes objects.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_partition_impl(PyBytesObject *self, Py_buffer *sep)
+/*[clinic end generated code: output=f532b392a17ff695 input=61cca95519406099]*/
+{
+    return stringlib_partition(
+        (PyObject*) self,
+        PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
+        sep->obj, (const char *)sep->buf, sep->len
+        );
+}
+
+/*[clinic input]
+bytes.rpartition
+
+    sep: Py_buffer
+    /
+
+Partition the bytes into three parts using the given separator.
+
+This will search for the separator sep in the bytes, starting at the end. If
+the separator is found, returns a 3-tuple containing the part before the
+separator, the separator itself, and the part after it.
+
+If the separator is not found, returns a 3-tuple containing two empty bytes
+objects and the original bytes object.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep)
+/*[clinic end generated code: output=191b114cbb028e50 input=d78db010c8cfdbe1]*/
+{
+    return stringlib_rpartition(
+        (PyObject*) self,
+        PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
+        sep->obj, (const char *)sep->buf, sep->len
+        );
+}
+
+/*[clinic input]
+bytes.rsplit = bytes.split
+
+Return a list of the sections in the bytes, using sep as the delimiter.
+
+Splitting is done starting at the end of the bytes and working to the front.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit)
+/*[clinic end generated code: output=ba698d9ea01e1c8f input=0f86c9f28f7d7b7b]*/
+{
+    Py_ssize_t len = PyBytes_GET_SIZE(self), n;
+    const char *s = PyBytes_AS_STRING(self), *sub;
+    Py_buffer vsub;
+    PyObject *list;
+
+    if (maxsplit < 0)
+        maxsplit = PY_SSIZE_T_MAX;
+    if (sep == Py_None)
+        return stringlib_rsplit_whitespace((PyObject*) self, s, len, maxsplit);
+    if (PyObject_GetBuffer(sep, &vsub, PyBUF_SIMPLE) != 0)
+        return NULL;
+    sub = vsub.buf;
+    n = vsub.len;
+
+    list = stringlib_rsplit((PyObject*) self, s, len, sub, n, maxsplit);
+    PyBuffer_Release(&vsub);
+    return list;
+}
+
+
+/*[clinic input]
+bytes.join
+
+    iterable_of_bytes: object
+    /
+
+Concatenate any number of bytes objects.
+
+The bytes whose method is called is inserted in between each pair.
+
+The result is returned as a new bytes object.
+
+Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_join(PyBytesObject *self, PyObject *iterable_of_bytes)
+/*[clinic end generated code: output=a046f379f626f6f8 input=7fe377b95bd549d2]*/
+{
+    return stringlib_bytes_join((PyObject*)self, iterable_of_bytes);
+}
+
+PyObject *
+_PyBytes_Join(PyObject *sep, PyObject *x)
+{
+    assert(sep != NULL && PyBytes_Check(sep));
+    assert(x != NULL);
+    return bytes_join((PyBytesObject*)sep, x);
+}
+
+static PyObject *
+bytes_find(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_find(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+static PyObject *
+bytes_index(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_index(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+
+static PyObject *
+bytes_rfind(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_rfind(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+
+static PyObject *
+bytes_rindex(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_rindex(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+
+Py_LOCAL_INLINE(PyObject *)
+do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
+{
+    Py_buffer vsep;
+    char *s = PyBytes_AS_STRING(self);
+    Py_ssize_t len = PyBytes_GET_SIZE(self);
+    char *sep;
+    Py_ssize_t seplen;
+    Py_ssize_t i, j;
+
+    if (PyObject_GetBuffer(sepobj, &vsep, PyBUF_SIMPLE) != 0)
+        return NULL;
+    sep = vsep.buf;
+    seplen = vsep.len;
+
+    i = 0;
+    if (striptype != RIGHTSTRIP) {
+        while (i < len && memchr(sep, Py_CHARMASK(s[i]), seplen)) {
+            i++;
+        }
+    }
+
+    j = len;
+    if (striptype != LEFTSTRIP) {
+        do {
+            j--;
+        } while (j >= i && memchr(sep, Py_CHARMASK(s[j]), seplen));
+        j++;
+    }
+
+    PyBuffer_Release(&vsep);
+
+    if (i == 0 && j == len && PyBytes_CheckExact(self)) {
+        Py_INCREF(self);
+        return (PyObject*)self;
+    }
+    else
+        return PyBytes_FromStringAndSize(s+i, j-i);
+}
+
+
+Py_LOCAL_INLINE(PyObject *)
+do_strip(PyBytesObject *self, int striptype)
+{
+    char *s = PyBytes_AS_STRING(self);
+    Py_ssize_t len = PyBytes_GET_SIZE(self), i, j;
+
+    i = 0;
+    if (striptype != RIGHTSTRIP) {
+        while (i < len && Py_ISSPACE(s[i])) {
+            i++;
+        }
+    }
+
+    j = len;
+    if (striptype != LEFTSTRIP) {
+        do {
+            j--;
+        } while (j >= i && Py_ISSPACE(s[j]));
+        j++;
+    }
+
+    if (i == 0 && j == len && PyBytes_CheckExact(self)) {
+        Py_INCREF(self);
+        return (PyObject*)self;
+    }
+    else
+        return PyBytes_FromStringAndSize(s+i, j-i);
+}
+
+
+Py_LOCAL_INLINE(PyObject *)
+do_argstrip(PyBytesObject *self, int striptype, PyObject *bytes)
+{
+    if (bytes != NULL && bytes != Py_None) {
+        return do_xstrip(self, striptype, bytes);
+    }
+    return do_strip(self, striptype);
+}
+
+/*[clinic input]
+bytes.strip
+
+    bytes: object = None
+    /
+
+Strip leading and trailing bytes contained in the argument.
+
+If the argument is omitted or None, strip leading and trailing ASCII whitespace.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_strip_impl(PyBytesObject *self, PyObject *bytes)
+/*[clinic end generated code: output=c7c228d3bd104a1b input=8a354640e4e0b3ef]*/
+{
+    return do_argstrip(self, BOTHSTRIP, bytes);
+}
+
+/*[clinic input]
+bytes.lstrip
+
+    bytes: object = None
+    /
+
+Strip leading bytes contained in the argument.
+
+If the argument is omitted or None, strip leading  ASCII whitespace.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes)
+/*[clinic end generated code: output=28602e586f524e82 input=9baff4398c3f6857]*/
+{
+    return do_argstrip(self, LEFTSTRIP, bytes);
+}
+
+/*[clinic input]
+bytes.rstrip
+
+    bytes: object = None
+    /
+
+Strip trailing bytes contained in the argument.
+
+If the argument is omitted or None, strip trailing ASCII whitespace.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes)
+/*[clinic end generated code: output=547e3815c95447da input=b78af445c727e32b]*/
+{
+    return do_argstrip(self, RIGHTSTRIP, bytes);
+}
+
+
+static PyObject *
+bytes_count(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_count(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+
+/*[clinic input]
+bytes.translate
+
+    table: object
+        Translation table, which must be a bytes object of length 256.
+    /
+    delete as deletechars: object(c_default="NULL") = b''
+
+Return a copy with each character mapped by the given translation table.
+
+All characters occurring in the optional argument delete are removed.
+The remaining characters are mapped through the given translation table.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_translate_impl(PyBytesObject *self, PyObject *table,
+                     PyObject *deletechars)
+/*[clinic end generated code: output=43be3437f1956211 input=0ecdf159f654233c]*/
+{
+    char *input, *output;
+    Py_buffer table_view = {NULL, NULL};
+    Py_buffer del_table_view = {NULL, NULL};
+    const char *table_chars;
+    Py_ssize_t i, c, changed = 0;
+    PyObject *input_obj = (PyObject*)self;
+    const char *output_start, *del_table_chars=NULL;
+    Py_ssize_t inlen, tablen, dellen = 0;
+    PyObject *result;
+    int trans_table[256];
+
+    if (PyBytes_Check(table)) {
+        table_chars = PyBytes_AS_STRING(table);
+        tablen = PyBytes_GET_SIZE(table);
+    }
+    else if (table == Py_None) {
+        table_chars = NULL;
+        tablen = 256;
+    }
+    else {
+        if (PyObject_GetBuffer(table, &table_view, PyBUF_SIMPLE) != 0)
+            return NULL;
+        table_chars = table_view.buf;
+        tablen = table_view.len;
+    }
+
+    if (tablen != 256) {
+        PyErr_SetString(PyExc_ValueError,
+          "translation table must be 256 characters long");
+        PyBuffer_Release(&table_view);
+        return NULL;
+    }
+
+    if (deletechars != NULL) {
+        if (PyBytes_Check(deletechars)) {
+            del_table_chars = PyBytes_AS_STRING(deletechars);
+            dellen = PyBytes_GET_SIZE(deletechars);
+        }
+        else {
+            if (PyObject_GetBuffer(deletechars, &del_table_view, PyBUF_SIMPLE) != 0) {
+                PyBuffer_Release(&table_view);
+                return NULL;
+            }
+            del_table_chars = del_table_view.buf;
+            dellen = del_table_view.len;
+        }
+    }
+    else {
+        del_table_chars = NULL;
+        dellen = 0;
+    }
+
+    inlen = PyBytes_GET_SIZE(input_obj);
+    result = PyBytes_FromStringAndSize((char *)NULL, inlen);
+    if (result == NULL) {
+        PyBuffer_Release(&del_table_view);
+        PyBuffer_Release(&table_view);
+        return NULL;
+    }
+    output_start = output = PyBytes_AS_STRING(result);
+    input = PyBytes_AS_STRING(input_obj);
+
+    if (dellen == 0 && table_chars != NULL) {
+        /* If no deletions are required, use faster code */
+        for (i = inlen; --i >= 0; ) {
+            c = Py_CHARMASK(*input++);
+            if (Py_CHARMASK((*output++ = table_chars[c])) != c)
+                changed = 1;
+        }
+        if (!changed && PyBytes_CheckExact(input_obj)) {
+            Py_INCREF(input_obj);
+            Py_DECREF(result);
+            result = input_obj;
+        }
+        PyBuffer_Release(&del_table_view);
+        PyBuffer_Release(&table_view);
+        return result;
+    }
+
+    if (table_chars == NULL) {
+        for (i = 0; i < 256; i++)
+            trans_table[i] = Py_CHARMASK(i);
+    } else {
+        for (i = 0; i < 256; i++)
+            trans_table[i] = Py_CHARMASK(table_chars[i]);
+    }
+    PyBuffer_Release(&table_view);
+
+    for (i = 0; i < dellen; i++)
+        trans_table[(int) Py_CHARMASK(del_table_chars[i])] = -1;
+    PyBuffer_Release(&del_table_view);
+
+    for (i = inlen; --i >= 0; ) {
+        c = Py_CHARMASK(*input++);
+        if (trans_table[c] != -1)
+            if (Py_CHARMASK(*output++ = (char)trans_table[c]) == c)
+                continue;
+        changed = 1;
+    }
+    if (!changed && PyBytes_CheckExact(input_obj)) {
+        Py_DECREF(result);
+        Py_INCREF(input_obj);
+        return input_obj;
+    }
+    /* Fix the size of the resulting string */
+    if (inlen > 0)
+        _PyBytes_Resize(&result, output - output_start);
+    return result;
+}
+
+
+/*[clinic input]
+
+@staticmethod
+bytes.maketrans
+
+    frm: Py_buffer
+    to: Py_buffer
+    /
+
+Return a translation table useable for the bytes or bytearray translate method.
+
+The returned table will be one where each byte in frm is mapped to the byte at
+the same position in to.
+
+The bytes objects frm and to must be of the same length.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to)
+/*[clinic end generated code: output=a36f6399d4b77f6f input=de7a8fc5632bb8f1]*/
+{
+    return _Py_bytes_maketrans(frm, to);
+}
+
+
+/*[clinic input]
+bytes.replace
+
+    old: Py_buffer
+    new: Py_buffer
+    count: Py_ssize_t = -1
+        Maximum number of occurrences to replace.
+        -1 (the default value) means replace all occurrences.
+    /
+
+Return a copy with all occurrences of substring old replaced by new.
+
+If the optional argument count is given, only the first count occurrences are
+replaced.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
+                   Py_ssize_t count)
+/*[clinic end generated code: output=994fa588b6b9c104 input=b2fbbf0bf04de8e5]*/
+{
+    return stringlib_replace((PyObject *)self,
+                             (const char *)old->buf, old->len,
+                             (const char *)new->buf, new->len, count);
+}
+
+/** End DALKE **/
+
+
+static PyObject *
+bytes_startswith(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_startswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+static PyObject *
+bytes_endswith(PyBytesObject *self, PyObject *args)
+{
+    return _Py_bytes_endswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
+}
+
+
+/*[clinic input]
+bytes.decode
+
+    encoding: str(c_default="NULL") = 'utf-8'
+        The encoding with which to decode the bytes.
+    errors: str(c_default="NULL") = 'strict'
+        The error handling scheme to use for the handling of decoding errors.
+        The default is 'strict' meaning that decoding errors raise a
+        UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
+        as well as any other name registered with codecs.register_error that
+        can handle UnicodeDecodeErrors.
+
+Decode the bytes using the codec registered for encoding.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_decode_impl(PyBytesObject *self, const char *encoding,
+                  const char *errors)
+/*[clinic end generated code: output=5649a53dde27b314 input=958174769d2a40ca]*/
+{
+    return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors);
+}
+
+
+/*[clinic input]
+bytes.splitlines
+
+    keepends: bool(accept={int}) = False
+
+Return a list of the lines in the bytes, breaking at line boundaries.
+
+Line breaks are not included in the resulting list unless keepends is given and
+true.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_splitlines_impl(PyBytesObject *self, int keepends)
+/*[clinic end generated code: output=3484149a5d880ffb input=a8b32eb01ff5a5ed]*/
+{
+    return stringlib_splitlines(
+        (PyObject*) self, PyBytes_AS_STRING(self),
+        PyBytes_GET_SIZE(self), keepends
+        );
+}
+
+/*[clinic input]
+@classmethod
+bytes.fromhex
+
+    string: unicode
+    /
+
+Create a bytes object from a string of hexadecimal numbers.
+
+Spaces between two numbers are accepted.
+Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
+/*[clinic end generated code: output=0973acc63661bb2e input=bf4d1c361670acd3]*/
+{
+    PyObject *result = _PyBytes_FromHex(string, 0);
+    if (type != &PyBytes_Type && result != NULL) {
+        Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
+                                                       result, NULL));
+    }
+    return result;
+}
+
+PyObject*
+_PyBytes_FromHex(PyObject *string, int use_bytearray)
+{
+    char *buf;
+    Py_ssize_t hexlen, invalid_char;
+    unsigned int top, bot;
+    Py_UCS1 *str, *end;
+    _PyBytesWriter writer;
+
+    _PyBytesWriter_Init(&writer);
+    writer.use_bytearray = use_bytearray;
+
+    assert(PyUnicode_Check(string));
+    if (PyUnicode_READY(string))
+        return NULL;
+    hexlen = PyUnicode_GET_LENGTH(string);
+
+    if (!PyUnicode_IS_ASCII(string)) {
+        void *data = PyUnicode_DATA(string);
+        unsigned int kind = PyUnicode_KIND(string);
+        Py_ssize_t i;
+
+        /* search for the first non-ASCII character */
+        for (i = 0; i < hexlen; i++) {
+            if (PyUnicode_READ(kind, data, i) >= 128)
+                break;
+        }
+        invalid_char = i;
+        goto error;
+    }
+
+    assert(PyUnicode_KIND(string) == PyUnicode_1BYTE_KIND);
+    str = PyUnicode_1BYTE_DATA(string);
+
+    /* This overestimates if there are spaces */
+    buf = _PyBytesWriter_Alloc(&writer, hexlen / 2);
+    if (buf == NULL)
+        return NULL;
+
+    end = str + hexlen;
+    while (str < end) {
+        /* skip over spaces in the input */
+        if (Py_ISSPACE(*str)) {
+            do {
+                str++;
+            } while (Py_ISSPACE(*str));
+            if (str >= end)
+                break;
+        }
+
+        top = _PyLong_DigitValue[*str];
+        if (top >= 16) {
+            invalid_char = str - PyUnicode_1BYTE_DATA(string);
+            goto error;
+        }
+        str++;
+
+        bot = _PyLong_DigitValue[*str];
+        if (bot >= 16) {
+            invalid_char = str - PyUnicode_1BYTE_DATA(string);
+            goto error;
+        }
+        str++;
+
+        *buf++ = (unsigned char)((top << 4) + bot);
+    }
+
+    return _PyBytesWriter_Finish(&writer, buf);
+
+  error:
+    PyErr_Format(PyExc_ValueError,
+                 "non-hexadecimal number found in "
+                 "fromhex() arg at position %zd", invalid_char);
+    _PyBytesWriter_Dealloc(&writer);
+    return NULL;
+}
+
+PyDoc_STRVAR(hex__doc__,
+"B.hex() -> string\n\
+\n\
+Create a string of hexadecimal numbers from a bytes object.\n\
+Example: b'\\xb9\\x01\\xef'.hex() -> 'b901ef'.");
+
+static PyObject *
+bytes_hex(PyBytesObject *self)
+{
+    char* argbuf = PyBytes_AS_STRING(self);
+    Py_ssize_t arglen = PyBytes_GET_SIZE(self);
+    return _Py_strhex(argbuf, arglen);
+}
+
+static PyObject *
+bytes_getnewargs(PyBytesObject *v)
+{
+    return Py_BuildValue("(y#)", v->ob_sval, Py_SIZE(v));
+}
+
+
+static PyMethodDef
+bytes_methods[] = {
+    {"__getnewargs__",          (PyCFunction)bytes_getnewargs,  METH_NOARGS},
+    {"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS,
+     _Py_capitalize__doc__},
+    {"center", (PyCFunction)stringlib_center, METH_VARARGS,
+     _Py_center__doc__},
+    {"count", (PyCFunction)bytes_count, METH_VARARGS,
+     _Py_count__doc__},
+    BYTES_DECODE_METHODDEF
+    {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS,
+     _Py_endswith__doc__},
+    {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS,
+     _Py_expandtabs__doc__},
+    {"find", (PyCFunction)bytes_find, METH_VARARGS,
+     _Py_find__doc__},
+    BYTES_FROMHEX_METHODDEF
+    {"hex", (PyCFunction)bytes_hex, METH_NOARGS, hex__doc__},
+    {"index", (PyCFunction)bytes_index, METH_VARARGS, _Py_index__doc__},
+    {"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
+     _Py_isalnum__doc__},
+    {"isalpha", (PyCFunction)stringlib_isalpha, METH_NOARGS,
+     _Py_isalpha__doc__},
+    {"isdigit", (PyCFunction)stringlib_isdigit, METH_NOARGS,
+     _Py_isdigit__doc__},
+    {"islower", (PyCFunction)stringlib_islower, METH_NOARGS,
+     _Py_islower__doc__},
+    {"isspace", (PyCFunction)stringlib_isspace, METH_NOARGS,
+     _Py_isspace__doc__},
+    {"istitle", (PyCFunction)stringlib_istitle, METH_NOARGS,
+     _Py_istitle__doc__},
+    {"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS,
+     _Py_isupper__doc__},
+    BYTES_JOIN_METHODDEF
+    {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__},
+    {"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__},
+    BYTES_LSTRIP_METHODDEF
+    BYTES_MAKETRANS_METHODDEF
+    BYTES_PARTITION_METHODDEF
+    BYTES_REPLACE_METHODDEF
+    {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, _Py_rfind__doc__},
+    {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, _Py_rindex__doc__},
+    {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__},
+    BYTES_RPARTITION_METHODDEF
+    BYTES_RSPLIT_METHODDEF
+    BYTES_RSTRIP_METHODDEF
+    BYTES_SPLIT_METHODDEF
+    BYTES_SPLITLINES_METHODDEF
+    {"startswith", (PyCFunction)bytes_startswith, METH_VARARGS,
+     _Py_startswith__doc__},
+    BYTES_STRIP_METHODDEF
+    {"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
+     _Py_swapcase__doc__},
+    {"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__},
+    BYTES_TRANSLATE_METHODDEF
+    {"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__},
+    {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__},
+    {NULL,     NULL}                         /* sentinel */
+};
+
+static PyObject *
+bytes_mod(PyObject *self, PyObject *arg)
+{
+    if (!PyBytes_Check(self)) {
+        Py_RETURN_NOTIMPLEMENTED;
+    }
+    return _PyBytes_FormatEx(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
+                             arg, 0);
+}
+
+static PyNumberMethods bytes_as_number = {
+    0,              /*nb_add*/
+    0,              /*nb_subtract*/
+    0,              /*nb_multiply*/
+    bytes_mod,      /*nb_remainder*/
+};
+
+static PyObject *
+bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+
+static PyObject *
+bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    PyObject *x = NULL;
+    const char *encoding = NULL;
+    const char *errors = NULL;
+    PyObject *new = NULL;
+    PyObject *func;
+    Py_ssize_t size;
+    static char *kwlist[] = {"source", "encoding", "errors", 0};
+    _Py_IDENTIFIER(__bytes__);
+
+    if (type != &PyBytes_Type)
+        return bytes_subtype_new(type, args, kwds);
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, &x,
+                                     &encoding, &errors))
+        return NULL;
+    if (x == NULL) {
+        if (encoding != NULL || errors != NULL) {
+            PyErr_SetString(PyExc_TypeError,
+                            "encoding or errors without sequence "
+                            "argument");
+            return NULL;
+        }
+        return PyBytes_FromStringAndSize(NULL, 0);
+    }
+
+    if (encoding != NULL) {
+        /* Encode via the codec registry */
+        if (!PyUnicode_Check(x)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "encoding without a string argument");
+            return NULL;
+        }
+        new = PyUnicode_AsEncodedString(x, encoding, errors);
+        if (new == NULL)
+            return NULL;
+        assert(PyBytes_Check(new));
+        return new;
+    }
+
+    if (errors != NULL) {
+        PyErr_SetString(PyExc_TypeError,
+                        PyUnicode_Check(x) ?
+                        "string argument without an encoding" :
+                        "errors without a string argument");
+        return NULL;
+    }
+
+    /* We'd like to call PyObject_Bytes here, but we need to check for an
+       integer argument before deferring to PyBytes_FromObject, something
+       PyObject_Bytes doesn't do. */
+    func = _PyObject_LookupSpecial(x, &PyId___bytes__);
+    if (func != NULL) {
+        new = _PyObject_CallNoArg(func);
+        Py_DECREF(func);
+        if (new == NULL)
+            return NULL;
+        if (!PyBytes_Check(new)) {
+            PyErr_Format(PyExc_TypeError,
+                         "__bytes__ returned non-bytes (type %.200s)",
+                         Py_TYPE(new)->tp_name);
+            Py_DECREF(new);
+            return NULL;
+        }
+        return new;
+    }
+    else if (PyErr_Occurred())
+        return NULL;
+
+    if (PyUnicode_Check(x)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "string argument without an encoding");
+        return NULL;
+    }
+    /* Is it an integer? */
+    if (PyIndex_Check(x)) {
+        size = PyNumber_AsSsize_t(x, PyExc_OverflowError);
+        if (size == -1 && PyErr_Occurred()) {
+            if (PyErr_ExceptionMatches(PyExc_OverflowError))
+                return NULL;
+            PyErr_Clear();  /* fall through */
+        }
+        else {
+            if (size < 0) {
+                PyErr_SetString(PyExc_ValueError, "negative count");
+                return NULL;
+            }
+            new = _PyBytes_FromSize(size, 1);
+            if (new == NULL)
+                return NULL;
+            return new;
+        }
+    }
+
+    return PyBytes_FromObject(x);
+}
+
+static PyObject*
+_PyBytes_FromBuffer(PyObject *x)
+{
+    PyObject *new;
+    Py_buffer view;
+
+    if (PyObject_GetBuffer(x, &view, PyBUF_FULL_RO) < 0)
+        return NULL;
+
+    new = PyBytes_FromStringAndSize(NULL, view.len);
+    if (!new)
+        goto fail;
+    if (PyBuffer_ToContiguous(((PyBytesObject *)new)->ob_sval,
+                &view, view.len, 'C') < 0)
+        goto fail;
+    PyBuffer_Release(&view);
+    return new;
+
+fail:
+    Py_XDECREF(new);
+    PyBuffer_Release(&view);
+    return NULL;
+}
+
+#define _PyBytes_FROM_LIST_BODY(x, GET_ITEM)                                \
+    do {                                                                    \
+        PyObject *bytes;                                                    \
+        Py_ssize_t i;                                                       \
+        Py_ssize_t value;                                                   \
+        char *str;                                                          \
+        PyObject *item;                                                     \
+                                                                            \
+        bytes = PyBytes_FromStringAndSize(NULL, Py_SIZE(x));                \
+        if (bytes == NULL)                                                  \
+            return NULL;                                                    \
+        str = ((PyBytesObject *)bytes)->ob_sval;                            \
+                                                                            \
+        for (i = 0; i < Py_SIZE(x); i++) {                                  \
+            item = GET_ITEM((x), i);                                        \
+            value = PyNumber_AsSsize_t(item, NULL);                         \
+            if (value == -1 && PyErr_Occurred())                            \
+                goto error;                                                 \
+                                                                            \
+            if (value < 0 || value >= 256) {                                \
+                PyErr_SetString(PyExc_ValueError,                           \
+                                "bytes must be in range(0, 256)");          \
+                goto error;                                                 \
+            }                                                               \
+            *str++ = (char) value;                                          \
+        }                                                                   \
+        return bytes;                                                       \
+                                                                            \
+    error:                                                                  \
+        Py_DECREF(bytes);                                                   \
+        return NULL;                                                        \
+    } while (0)
+
+static PyObject*
+_PyBytes_FromList(PyObject *x)
+{
+    _PyBytes_FROM_LIST_BODY(x, PyList_GET_ITEM);
+}
+
+static PyObject*
+_PyBytes_FromTuple(PyObject *x)
+{
+    _PyBytes_FROM_LIST_BODY(x, PyTuple_GET_ITEM);
+}
+
+static PyObject *
+_PyBytes_FromIterator(PyObject *it, PyObject *x)
+{
+    char *str;
+    Py_ssize_t i, size;
+    _PyBytesWriter writer;
+
+    /* For iterator version, create a string object and resize as needed */
+    size = PyObject_LengthHint(x, 64);
+    if (size == -1 && PyErr_Occurred())
+        return NULL;
+
+    _PyBytesWriter_Init(&writer);
+    str = _PyBytesWriter_Alloc(&writer, size);
+    if (str == NULL)
+        return NULL;
+    writer.overallocate = 1;
+    size = writer.allocated;
+
+    /* Run the iterator to exhaustion */
+    for (i = 0; ; i++) {
+        PyObject *item;
+        Py_ssize_t value;
+
+        /* Get the next item */
+        item = PyIter_Next(it);
+        if (item == NULL) {
+            if (PyErr_Occurred())
+                goto error;
+            break;
+        }
+
+        /* Interpret it as an int (__index__) */
+        value = PyNumber_AsSsize_t(item, NULL);
+        Py_DECREF(item);
+        if (value == -1 && PyErr_Occurred())
+            goto error;
+
+        /* Range check */
+        if (value < 0 || value >= 256) {
+            PyErr_SetString(PyExc_ValueError,
+                            "bytes must be in range(0, 256)");
+            goto error;
+        }
+
+        /* Append the byte */
+        if (i >= size) {
+            str = _PyBytesWriter_Resize(&writer, str, size+1);
+            if (str == NULL)
+                return NULL;
+            size = writer.allocated;
+        }
+        *str++ = (char) value;
+    }
+
+    return _PyBytesWriter_Finish(&writer, str);
+
+  error:
+    _PyBytesWriter_Dealloc(&writer);
+    return NULL;
+}
+
+PyObject *
+PyBytes_FromObject(PyObject *x)
+{
+    PyObject *it, *result;
+
+    if (x == NULL) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+
+    if (PyBytes_CheckExact(x)) {
+        Py_INCREF(x);
+        return x;
+    }
+
+    /* Use the modern buffer interface */
+    if (PyObject_CheckBuffer(x))
+        return _PyBytes_FromBuffer(x);
+
+    if (PyList_CheckExact(x))
+        return _PyBytes_FromList(x);
+
+    if (PyTuple_CheckExact(x))
+        return _PyBytes_FromTuple(x);
+
+    if (!PyUnicode_Check(x)) {
+        it = PyObject_GetIter(x);
+        if (it != NULL) {
+            result = _PyBytes_FromIterator(it, x);
+            Py_DECREF(it);
+            return result;
+        }
+    }
+
+    PyErr_Format(PyExc_TypeError,
+                 "cannot convert '%.200s' object to bytes",
+                 x->ob_type->tp_name);
+    return NULL;
+}
+
+static PyObject *
+bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    PyObject *tmp, *pnew;
+    Py_ssize_t n;
+
+    assert(PyType_IsSubtype(type, &PyBytes_Type));
+    tmp = bytes_new(&PyBytes_Type, args, kwds);
+    if (tmp == NULL)
+        return NULL;
+    assert(PyBytes_Check(tmp));
+    n = PyBytes_GET_SIZE(tmp);
+    pnew = type->tp_alloc(type, n);
+    if (pnew != NULL) {
+        memcpy(PyBytes_AS_STRING(pnew),
+                  PyBytes_AS_STRING(tmp), n+1);
+        ((PyBytesObject *)pnew)->ob_shash =
+            ((PyBytesObject *)tmp)->ob_shash;
+    }
+    Py_DECREF(tmp);
+    return pnew;
+}
+
+PyDoc_STRVAR(bytes_doc,
+"bytes(iterable_of_ints) -> bytes\n\
+bytes(string, encoding[, errors]) -> bytes\n\
+bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer\n\
+bytes(int) -> bytes object of size given by the parameter initialized with null bytes\n\
+bytes() -> empty bytes object\n\
+\n\
+Construct an immutable array of bytes from:\n\
+  - an iterable yielding integers in range(256)\n\
+  - a text string encoded using the specified encoding\n\
+  - any object implementing the buffer API.\n\
+  - an integer");
+
+static PyObject *bytes_iter(PyObject *seq);
+
+PyTypeObject PyBytes_Type = {
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
+    "bytes",
+    PyBytesObject_SIZE,
+    sizeof(char),
+    bytes_dealloc,                      /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    (reprfunc)bytes_repr,                       /* tp_repr */
+    &bytes_as_number,                           /* tp_as_number */
+    &bytes_as_sequence,                         /* tp_as_sequence */
+    &bytes_as_mapping,                          /* tp_as_mapping */
+    (hashfunc)bytes_hash,                       /* tp_hash */
+    0,                                          /* tp_call */
+    bytes_str,                                  /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    &bytes_as_buffer,                           /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
+        Py_TPFLAGS_BYTES_SUBCLASS,              /* tp_flags */
+    bytes_doc,                                  /* tp_doc */
+    0,                                          /* tp_traverse */
+    0,                                          /* tp_clear */
+    (richcmpfunc)bytes_richcompare,             /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    bytes_iter,                                 /* tp_iter */
+    0,                                          /* tp_iternext */
+    bytes_methods,                              /* tp_methods */
+    0,                                          /* tp_members */
+    0,                                          /* tp_getset */
+    &PyBaseObject_Type,                         /* tp_base */
+    0,                                          /* tp_dict */
+    0,                                          /* tp_descr_get */
+    0,                                          /* tp_descr_set */
+    0,                                          /* tp_dictoffset */
+    0,                                          /* tp_init */
+    0,                                          /* tp_alloc */
+    bytes_new,                                  /* tp_new */
+    PyObject_Del,                               /* tp_free */
+};
+
+void
+PyBytes_Concat(PyObject **pv, PyObject *w)
+{
+    assert(pv != NULL);
+    if (*pv == NULL)
+        return;
+    if (w == NULL) {
+        Py_CLEAR(*pv);
+        return;
+    }
+
+    if (Py_REFCNT(*pv) == 1 && PyBytes_CheckExact(*pv)) {
+        /* Only one reference, so we can resize in place */
+        Py_ssize_t oldsize;
+        Py_buffer wb;
+
+        wb.len = -1;
+        if (PyObject_GetBuffer(w, &wb, PyBUF_SIMPLE) != 0) {
+            PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s",
+                         Py_TYPE(w)->tp_name, Py_TYPE(*pv)->tp_name);
+            Py_CLEAR(*pv);
+            return;
+        }
+
+        oldsize = PyBytes_GET_SIZE(*pv);
+        if (oldsize > PY_SSIZE_T_MAX - wb.len) {
+            PyErr_NoMemory();
+            goto error;
+        }
+        if (_PyBytes_Resize(pv, oldsize + wb.len) < 0)
+            goto error;
+
+        memcpy(PyBytes_AS_STRING(*pv) + oldsize, wb.buf, wb.len);
+        PyBuffer_Release(&wb);
+        return;
+
+      error:
+        PyBuffer_Release(&wb);
+        Py_CLEAR(*pv);
+        return;
+    }
+
+    else {
+        /* Multiple references, need to create new object */
+        PyObject *v;
+        v = bytes_concat(*pv, w);
+        Py_SETREF(*pv, v);
+    }
+}
+
+void
+PyBytes_ConcatAndDel(PyObject **pv, PyObject *w)
+{
+    PyBytes_Concat(pv, w);
+    Py_XDECREF(w);
+}
+
+
+/* The following function breaks the notion that bytes are immutable:
+   it changes the size of a bytes object.  We get away with this only if there
+   is only one module referencing the object.  You can also think of it
+   as creating a new bytes object and destroying the old one, only
+   more efficiently.  In any case, don't use this if the bytes object may
+   already be known to some other part of the code...
+   Note that if there's not enough memory to resize the bytes object, the
+   original bytes object at *pv is deallocated, *pv is set to NULL, an "out of
+   memory" exception is set, and -1 is returned.  Else (on success) 0 is
+   returned, and the value in *pv may or may not be the same as on input.
+   As always, an extra byte is allocated for a trailing \0 byte (newsize
+   does *not* include that), and a trailing \0 byte is stored.
+*/
+
+int
+_PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
+{
+    PyObject *v;
+    PyBytesObject *sv;
+    v = *pv;
+    if (!PyBytes_Check(v) || newsize < 0) {
+        goto error;
+    }
+    if (Py_SIZE(v) == newsize) {
+        /* return early if newsize equals to v->ob_size */
+        return 0;
+    }
+    if (Py_REFCNT(v) != 1) {
+        goto error;
+    }
+    /* XXX UNREF/NEWREF interface should be more symmetrical */
+    _Py_DEC_REFTOTAL;
+    _Py_ForgetReference(v);
+    *pv = (PyObject *)
+        PyObject_REALLOC(v, PyBytesObject_SIZE + newsize);
+    if (*pv == NULL) {
+        PyObject_Del(v);
+        PyErr_NoMemory();
+        return -1;
+    }
+    _Py_NewReference(*pv);
+    sv = (PyBytesObject *) *pv;
+    Py_SIZE(sv) = newsize;
+    sv->ob_sval[newsize] = '\0';
+    sv->ob_shash = -1;          /* invalidate cached hash value */
+    return 0;
+error:
+    *pv = 0;
+    Py_DECREF(v);
+    PyErr_BadInternalCall();
+    return -1;
+}
+
+void
+PyBytes_Fini(void)
+{
+    int i;
+    for (i = 0; i < UCHAR_MAX + 1; i++)
+        Py_CLEAR(characters[i]);
+    Py_CLEAR(nullstring);
+}
+
+/*********************** Bytes Iterator ****************************/
+
+typedef struct {
+    PyObject_HEAD
+    Py_ssize_t it_index;
+    PyBytesObject *it_seq; /* Set to NULL when iterator is exhausted */
+} striterobject;
+
+static void
+striter_dealloc(striterobject *it)
+{
+    _PyObject_GC_UNTRACK(it);
+    Py_XDECREF(it->it_seq);
+    PyObject_GC_Del(it);
+}
+
+static int
+striter_traverse(striterobject *it, visitproc visit, void *arg)
+{
+    Py_VISIT(it->it_seq);
+    return 0;
+}
+
+static PyObject *
+striter_next(striterobject *it)
+{
+    PyBytesObject *seq;
+    PyObject *item;
+
+    assert(it != NULL);
+    seq = it->it_seq;
+    if (seq == NULL)
+        return NULL;
+    assert(PyBytes_Check(seq));
+
+    if (it->it_index < PyBytes_GET_SIZE(seq)) {
+        item = PyLong_FromLong(
+            (unsigned char)seq->ob_sval[it->it_index]);
+        if (item != NULL)
+            ++it->it_index;
+        return item;
+    }
+
+    it->it_seq = NULL;
+    Py_DECREF(seq);
+    return NULL;
+}
+
+static PyObject *
+striter_len(striterobject *it)
+{
+    Py_ssize_t len = 0;
+    if (it->it_seq)
+        len = PyBytes_GET_SIZE(it->it_seq) - it->it_index;
+    return PyLong_FromSsize_t(len);
+}
+
+PyDoc_STRVAR(length_hint_doc,
+             "Private method returning an estimate of len(list(it)).");
+
+static PyObject *
+striter_reduce(striterobject *it)
+{
+    if (it->it_seq != NULL) {
+        return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
+                             it->it_seq, it->it_index);
+    } else {
+        return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
+    }
+}
+
+PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
+
+static PyObject *
+striter_setstate(striterobject *it, PyObject *state)
+{
+    Py_ssize_t index = PyLong_AsSsize_t(state);
+    if (index == -1 && PyErr_Occurred())
+        return NULL;
+    if (it->it_seq != NULL) {
+        if (index < 0)
+            index = 0;
+        else if (index > PyBytes_GET_SIZE(it->it_seq))
+            index = PyBytes_GET_SIZE(it->it_seq); /* iterator exhausted */
+        it->it_index = index;
+    }
+    Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(setstate_doc, "Set state information for unpickling.");
+
+static PyMethodDef striter_methods[] = {
+    {"__length_hint__", (PyCFunction)striter_len, METH_NOARGS,
+     length_hint_doc},
+    {"__reduce__",      (PyCFunction)striter_reduce, METH_NOARGS,
+     reduce_doc},
+    {"__setstate__",    (PyCFunction)striter_setstate, METH_O,
+     setstate_doc},
+    {NULL,              NULL}           /* sentinel */
+};
+
+PyTypeObject PyBytesIter_Type = {
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
+    "bytes_iterator",                           /* tp_name */
+    sizeof(striterobject),                      /* tp_basicsize */
+    0,                                          /* tp_itemsize */
+    /* methods */
+    (destructor)striter_dealloc,                /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    0,                                          /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    0,                                          /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
+    0,                                          /* tp_doc */
+    (traverseproc)striter_traverse,     /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    PyObject_SelfIter,                          /* tp_iter */
+    (iternextfunc)striter_next,                 /* tp_iternext */
+    striter_methods,                            /* tp_methods */
+    0,
+};
+
+static PyObject *
+bytes_iter(PyObject *seq)
+{
+    striterobject *it;
+
+    if (!PyBytes_Check(seq)) {
+        PyErr_BadInternalCall();
+        return NULL;
+    }
+    it = PyObject_GC_New(striterobject, &PyBytesIter_Type);
+    if (it == NULL)
+        return NULL;
+    it->it_index = 0;
+    Py_INCREF(seq);
+    it->it_seq = (PyBytesObject *)seq;
+    _PyObject_GC_TRACK(it);
+    return (PyObject *)it;
+}
+
+
+/* _PyBytesWriter API */
+
+#ifdef MS_WINDOWS
+   /* On Windows, overallocate by 50% is the best factor */
+#  define OVERALLOCATE_FACTOR 2
+#else
+   /* On Linux, overallocate by 25% is the best factor */
+#  define OVERALLOCATE_FACTOR 4
+#endif
+
+void
+_PyBytesWriter_Init(_PyBytesWriter *writer)
+{
+    /* Set all attributes before small_buffer to 0 */
+    memset(writer, 0, offsetof(_PyBytesWriter, small_buffer));
+#ifdef Py_DEBUG
+    memset(writer->small_buffer, 0xCB, sizeof(writer->small_buffer));
+#endif
+}
+
+void
+_PyBytesWriter_Dealloc(_PyBytesWriter *writer)
+{
+    Py_CLEAR(writer->buffer);
+}
+
+Py_LOCAL_INLINE(char*)
+_PyBytesWriter_AsString(_PyBytesWriter *writer)
+{
+    if (writer->use_small_buffer) {
+        assert(writer->buffer == NULL);
+        return writer->small_buffer;
+    }
+    else if (writer->use_bytearray) {
+        assert(writer->buffer != NULL);
+        return PyByteArray_AS_STRING(writer->buffer);
+    }
+    else {
+        assert(writer->buffer != NULL);
+        return PyBytes_AS_STRING(writer->buffer);
+    }
+}
+
+Py_LOCAL_INLINE(Py_ssize_t)
+_PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
+{
+    char *start = _PyBytesWriter_AsString(writer);
+    assert(str != NULL);
+    assert(str >= start);
+    assert(str - start <= writer->allocated);
+    return str - start;
+}
+
+Py_LOCAL_INLINE(void)
+_PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
+{
+#ifdef Py_DEBUG
+    char *start, *end;
+
+    if (writer->use_small_buffer) {
+        assert(writer->buffer == NULL);
+    }
+    else {
+        assert(writer->buffer != NULL);
+        if (writer->use_bytearray)
+            assert(PyByteArray_CheckExact(writer->buffer));
+        else
+            assert(PyBytes_CheckExact(writer->buffer));
+        assert(Py_REFCNT(writer->buffer) == 1);
+    }
+
+    if (writer->use_bytearray) {
+        /* bytearray has its own overallocation algorithm,
+           writer overallocation must be disabled */
+        assert(!writer->overallocate);
+    }
+
+    assert(0 <= writer->allocated);
+    assert(0 <= writer->min_size && writer->min_size <= writer->allocated);
+    /* the last byte must always be null */
+    start = _PyBytesWriter_AsString(writer);
+    assert(start[writer->allocated] == 0);
+
+    end = start + writer->allocated;
+    assert(str != NULL);
+    assert(start <= str && str <= end);
+#endif
+}
+
+void*
+_PyBytesWriter_Resize(_PyBytesWriter *writer, void *str, Py_ssize_t size)
+{
+    Py_ssize_t allocated, pos;
+
+    _PyBytesWriter_CheckConsistency(writer, str);
+    assert(writer->allocated < size);
+
+    allocated = size;
+    if (writer->overallocate
+        && allocated <= (PY_SSIZE_T_MAX - allocated / OVERALLOCATE_FACTOR)) {
+        /* overallocate to limit the number of realloc() */
+        allocated += allocated / OVERALLOCATE_FACTOR;
+    }
+
+    pos = _PyBytesWriter_GetSize(writer, str);
+    if (!writer->use_small_buffer) {
+        if (writer->use_bytearray) {
+            if (PyByteArray_Resize(writer->buffer, allocated))
+                goto error;
+            /* writer->allocated can be smaller than writer->buffer->ob_alloc,
+               but we cannot use ob_alloc because bytes may need to be moved
+               to use the whole buffer. bytearray uses an internal optimization
+               to avoid moving or copying bytes when bytes are removed at the
+               beginning (ex: del bytearray[:1]). */
+        }
+        else {
+            if (_PyBytes_Resize(&writer->buffer, allocated))
+                goto error;
+        }
+    }
+    else {
+        /* convert from stack buffer to bytes object buffer */
+        assert(writer->buffer == NULL);
+
+        if (writer->use_bytearray)
+            writer->buffer = PyByteArray_FromStringAndSize(NULL, allocated);
+        else
+            writer->buffer = PyBytes_FromStringAndSize(NULL, allocated);
+        if (writer->buffer == NULL)
+            goto error;
+
+        if (pos != 0) {
+            char *dest;
+            if (writer->use_bytearray)
+                dest = PyByteArray_AS_STRING(writer->buffer);
+            else
+                dest = PyBytes_AS_STRING(writer->buffer);
+            memcpy(dest,
+                      writer->small_buffer,
+                      pos);
+        }
+
+        writer->use_small_buffer = 0;
+#ifdef Py_DEBUG
+        memset(writer->small_buffer, 0xDB, sizeof(writer->small_buffer));
+#endif
+    }
+    writer->allocated = allocated;
+
+    str = _PyBytesWriter_AsString(writer) + pos;
+    _PyBytesWriter_CheckConsistency(writer, str);
+    return str;
+
+error:
+    _PyBytesWriter_Dealloc(writer);
+    return NULL;
+}
+
+void*
+_PyBytesWriter_Prepare(_PyBytesWriter *writer, void *str, Py_ssize_t size)
+{
+    Py_ssize_t new_min_size;
+
+    _PyBytesWriter_CheckConsistency(writer, str);
+    assert(size >= 0);
+
+    if (size == 0) {
+        /* nothing to do */
+        return str;
+    }
+
+    if (writer->min_size > PY_SSIZE_T_MAX - size) {
+        PyErr_NoMemory();
+        _PyBytesWriter_Dealloc(writer);
+        return NULL;
+    }
+    new_min_size = writer->min_size + size;
+
+    if (new_min_size > writer->allocated)
+        str = _PyBytesWriter_Resize(writer, str, new_min_size);
+
+    writer->min_size = new_min_size;
+    return str;
+}
+
+/* Allocate the buffer to write size bytes.
+   Return the pointer to the beginning of buffer data.
+   Raise an exception and return NULL on error. */
+void*
+_PyBytesWriter_Alloc(_PyBytesWriter *writer, Py_ssize_t size)
+{
+    /* ensure that _PyBytesWriter_Alloc() is only called once */
+    assert(writer->min_size == 0 && writer->buffer == NULL);
+    assert(size >= 0);
+
+    writer->use_small_buffer = 1;
+#ifdef Py_DEBUG
+    writer->allocated = sizeof(writer->small_buffer) - 1;
+    /* In debug mode, don't use the full small buffer because it is less
+       efficient than bytes and bytearray objects to detect buffer underflow
+       and buffer overflow. Use 10 bytes of the small buffer to test also
+       code using the smaller buffer in debug mode.
+
+       Don't modify the _PyBytesWriter structure (use a shorter small buffer)
+       in debug mode to also be able to detect stack overflow when running
+       tests in debug mode. The _PyBytesWriter is large (more than 512 bytes),
+       if Py_EnterRecursiveCall() is not used in deep C callback, we may hit a
+       stack overflow. */
+    writer->allocated = Py_MIN(writer->allocated, 10);
+    /* _PyBytesWriter_CheckConsistency() requires the last byte to be 0,
+       to detect buffer overflow */
+    writer->small_buffer[writer->allocated] = 0;
+#else
+    writer->allocated = sizeof(writer->small_buffer);
+#endif
+    return _PyBytesWriter_Prepare(writer, writer->small_buffer, size);
+}
+
+PyObject *
+_PyBytesWriter_Finish(_PyBytesWriter *writer, void *str)
+{
+    Py_ssize_t size;
+    PyObject *result;
+
+    _PyBytesWriter_CheckConsistency(writer, str);
+
+    size = _PyBytesWriter_GetSize(writer, str);
+    if (size == 0 && !writer->use_bytearray) {
+        Py_CLEAR(writer->buffer);
+        /* Get the empty byte string singleton */
+        result = PyBytes_FromStringAndSize(NULL, 0);
+    }
+    else if (writer->use_small_buffer) {
+        if (writer->use_bytearray) {
+            result = PyByteArray_FromStringAndSize(writer->small_buffer, size);
+        }
+        else {
+            result = PyBytes_FromStringAndSize(writer->small_buffer, size);
+        }
+    }
+    else {
+        result = writer->buffer;
+        writer->buffer = NULL;
+
+        if (size != writer->allocated) {
+            if (writer->use_bytearray) {
+                if (PyByteArray_Resize(result, size)) {
+                    Py_DECREF(result);
+                    return NULL;
+                }
+            }
+            else {
+                if (_PyBytes_Resize(&result, size)) {
+                    assert(result == NULL);
+                    return NULL;
+                }
+            }
+        }
+    }
+    return result;
+}
+
+void*
+_PyBytesWriter_WriteBytes(_PyBytesWriter *writer, void *ptr,
+                          const void *bytes, Py_ssize_t size)
+{
+    char *str = (char *)ptr;
+
+    str = _PyBytesWriter_Prepare(writer, str, size);
+    if (str == NULL)
+        return NULL;
+
+    memcpy(str, bytes, size);
+    str += size;
+
+    return str;
+}
index 738e613c836ca55a50d73fb73ef75b2a33a89282..5b645787cbf6f64333f6c6a9deb2d19d774e663e 100644 (file)
@@ -88,9 +88,9 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name)
             base = PyTuple_GET_ITEM(bases, i);
             if (!PyClass_Check(base)) {
                 if (PyCallable_Check(
-                    (PyObject *) base->ob_type))
+                        (PyObject *) Py_TYPE(base)))
                     return PyObject_CallFunctionObjArgs(
-                        (PyObject *) base->ob_type,
+                        (PyObject *) Py_TYPE(base),
                         name, bases, dict, NULL);
                 PyErr_SetString(PyExc_TypeError,
                     "PyClass_New: base must be a class");
@@ -265,7 +265,7 @@ class_getattr(register PyClassObject *op, PyObject *name)
                      PyString_AS_STRING(op->cl_name), sname);
         return NULL;
     }
-    f = TP_DESCR_GET(v->ob_type);
+    f = TP_DESCR_GET(Py_TYPE(v));
     if (f == NULL)
         Py_INCREF(v);
     else
@@ -442,8 +442,7 @@ class_traverse(PyClassObject *o, visitproc visit, void *arg)
 }
 
 PyTypeObject PyClass_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "classobj",
     sizeof(PyClassObject),
     0,
@@ -639,9 +638,9 @@ instance_dealloc(register PyInstanceObject *inst)
         PyObject_ClearWeakRefs((PyObject *) inst);
 
     /* Temporarily resurrect the object. */
-    assert(inst->ob_type == &PyInstance_Type);
-    assert(inst->ob_refcnt == 0);
-    inst->ob_refcnt = 1;
+    assert(Py_TYPE(inst) == &PyInstance_Type);
+    assert(Py_REFCNT(inst) == 0);
+    Py_REFCNT(inst) = 1;
 
     /* Save the current exception, if any. */
     PyErr_Fetch(&error_type, &error_value, &error_traceback);
@@ -665,8 +664,8 @@ instance_dealloc(register PyInstanceObject *inst)
     /* Undo the temporary resurrection; can't use DECREF here, it would
      * cause a recursive call.
      */
-    assert(inst->ob_refcnt > 0);
-    if (--inst->ob_refcnt == 0) {
+    assert(Py_REFCNT(inst) > 0);
+    if (--Py_REFCNT(inst) == 0) {
 
         /* New weakrefs could be created during the finalizer call.
             If this occurs, clear them out without calling their
@@ -682,12 +681,12 @@ instance_dealloc(register PyInstanceObject *inst)
         PyObject_GC_Del(inst);
     }
     else {
-        Py_ssize_t refcnt = inst->ob_refcnt;
+        Py_ssize_t refcnt = Py_REFCNT(inst);
         /* __del__ resurrected it!  Make it look like the original
          * Py_DECREF never happened.
          */
         _Py_NewReference((PyObject *)inst);
-        inst->ob_refcnt = refcnt;
+        Py_REFCNT(inst) = refcnt;
         _PyObject_GC_TRACK(inst);
         /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
          * we need to undo that. */
@@ -699,8 +698,8 @@ instance_dealloc(register PyInstanceObject *inst)
          * undone.
          */
 #ifdef COUNT_ALLOCS
-        --inst->ob_type->tp_frees;
-        --inst->ob_type->tp_allocs;
+        --Py_TYPE(inst)->tp_frees;
+        --Py_TYPE(inst)->tp_allocs;
 #endif
     }
 }
@@ -756,7 +755,7 @@ instance_getattr2(register PyInstanceObject *inst, PyObject *name)
     v = class_lookup(inst->in_class, name, &klass);
     if (v != NULL) {
         Py_INCREF(v);
-        f = TP_DESCR_GET(v->ob_type);
+        f = TP_DESCR_GET(Py_TYPE(v));
         if (f != NULL) {
             PyObject *w = f(v, (PyObject *)inst,
                             (PyObject *)(inst->in_class));
@@ -1012,7 +1011,7 @@ instance_hash(PyInstanceObject *inst)
         return -1;
     if (PyInt_Check(res) || PyLong_Check(res))
         /* This already converts a -1 result to -2. */
-        outcome = res->ob_type->tp_hash(res);
+        outcome = Py_TYPE(res)->tp_hash(res);
     else {
         PyErr_SetString(PyExc_TypeError,
                         "__hash__() should return an int");
@@ -1500,7 +1499,7 @@ half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc,
     }
     v1 = PyTuple_GetItem(coerced, 0);
     w = PyTuple_GetItem(coerced, 1);
-    if (v1->ob_type == v->ob_type && PyInstance_Check(v)) {
+    if (Py_TYPE(v1) == Py_TYPE(v) && PyInstance_Check(v)) {
         /* prevent recursion if __coerce__ returns self as the first
          * argument */
         result = generic_binary_op(v1, w, opname);
@@ -2077,7 +2076,7 @@ instance_getiter(PyInstanceObject *self)
             PyErr_Format(PyExc_TypeError,
                          "__iter__ returned non-iterator "
                          "of type '%.100s'",
-                         res->ob_type->tp_name);
+                         Py_TYPE(res)->tp_name);
             Py_DECREF(res);
             res = NULL;
         }
@@ -2201,8 +2200,7 @@ static PyNumberMethods instance_as_number = {
 };
 
 PyTypeObject PyInstance_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "instance",
     sizeof(PyInstanceObject),
     0,
@@ -2321,7 +2319,7 @@ static PyObject *
 instancemethod_getattro(PyObject *obj, PyObject *name)
 {
     PyMethodObject *im = (PyMethodObject *)obj;
-    PyTypeObject *tp = obj->ob_type;
+    PyTypeObject *tp = Py_TYPE(obj);
     PyObject *descr = NULL;
 
     if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) {
@@ -2333,9 +2331,9 @@ instancemethod_getattro(PyObject *obj, PyObject *name)
     }
 
     if (descr != NULL) {
-        descrgetfunc f = TP_DESCR_GET(descr->ob_type);
+        descrgetfunc f = TP_DESCR_GET(Py_TYPE(descr));
         if (f != NULL)
-            return f(descr, obj, (PyObject *)obj->ob_type);
+            return f(descr, obj, (PyObject *)Py_TYPE(obj));
         else {
             Py_INCREF(descr);
             return descr;
@@ -2538,7 +2536,7 @@ getinstclassname(PyObject *inst, char *buf, int bufsize)
     if (klass == NULL) {
         /* This function cannot return an exception */
         PyErr_Clear();
-        klass = (PyObject *)(inst->ob_type);
+        klass = (PyObject *)Py_TYPE(inst);
         Py_INCREF(klass);
     }
     getclassname(klass, buf, bufsize);
@@ -2631,8 +2629,7 @@ instancemethod_descr_get(PyObject *meth, PyObject *obj, PyObject *cls)
 }
 
 PyTypeObject PyMethod_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "instancemethod",
     sizeof(PyMethodObject),
     0,
index 9506067c7db466d160d24b6c1355070804adf9d1..c544ecd8c2d2547fff5c068d82694f0230b68c64 100644 (file)
@@ -1076,6 +1076,7 @@ dict_dealloc(register PyDictObject *mp)
 {
     register PyDictEntry *ep;
     Py_ssize_t fill = mp->ma_fill;
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
     PyObject_GC_UnTrack(mp);
     Py_TRASHCAN_SAFE_BEGIN(mp)
     for (ep = mp->ma_table; fill > 0; ep++) {
@@ -2576,6 +2577,8 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
 static void
 dictiter_dealloc(dictiterobject *di)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    _PyObject_GC_UNTRACK(di);
     Py_XDECREF(di->di_dict);
     Py_XDECREF(di->di_result);
     PyObject_GC_Del(di);
@@ -2855,6 +2858,8 @@ typedef struct {
 static void
 dictview_dealloc(dictviewobject *dv)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    _PyObject_GC_UNTRACK(dv);
     Py_XDECREF(dv->dv_dict);
     PyObject_GC_Del(dv);
 }
@@ -3000,21 +3005,29 @@ dictview_repr(dictviewobject *dv)
 {
     PyObject *seq;
     PyObject *seq_str;
-    PyObject *result;
+    PyObject *result = NULL;
+    Py_ssize_t rc;
 
+    rc = Py_ReprEnter((PyObject *)dv);
+    if (rc != 0) {
+        return rc > 0 ? PyString_FromString("...") : NULL;
+    }
     seq = PySequence_List((PyObject *)dv);
-    if (seq == NULL)
-        return NULL;
-
+    if (seq == NULL) {
+        goto Done;
+    }
     seq_str = PyObject_Repr(seq);
+    Py_DECREF(seq);
+
     if (seq_str == NULL) {
-        Py_DECREF(seq);
-        return NULL;
+        goto Done;
     }
     result = PyString_FromFormat("%s(%s)", Py_TYPE(dv)->tp_name,
                                  PyString_AS_STRING(seq_str));
     Py_DECREF(seq_str);
-    Py_DECREF(seq);
+
+Done:
+    Py_ReprLeave((PyObject *)dv);
     return result;
 }
 
index 1ef381f391428cb60feb5f6ef3507272d4021656..8f86a5b8de39e784c6013247768eb02b19a3993a 100644 (file)
@@ -87,19 +87,25 @@ enum_next_long(enumobject *en, PyObject* next_item)
 
     if (en->en_longindex == NULL) {
         en->en_longindex = PyInt_FromSsize_t(PY_SSIZE_T_MAX);
-        if (en->en_longindex == NULL)
+        if (en->en_longindex == NULL) {
+            Py_DECREF(next_item);
             return NULL;
+        }
     }
     if (one == NULL) {
         one = PyInt_FromLong(1);
-        if (one == NULL)
+        if (one == NULL) {
+            Py_DECREF(next_item);
             return NULL;
+        }
     }
     next_index = en->en_longindex;
     assert(next_index != NULL);
     stepped_up = PyNumber_Add(next_index, one);
-    if (stepped_up == NULL)
+    if (stepped_up == NULL) {
+        Py_DECREF(next_item);
         return NULL;
+    }
     en->en_longindex = stepped_up;
 
     if (result->ob_refcnt == 1) {
index 1929777197fda77bace06d9518e13d9320797540..224d1ba08afb5ca9b5ce6c5f03c6c16ba31cd72a 100644 (file)
@@ -368,8 +368,7 @@ static PyGetSetDef BaseException_getset[] = {
 
 
 static PyTypeObject _PyExc_BaseException = {
-    PyObject_HEAD_INIT(NULL)
-    0,                          /*ob_size*/
+    PyVarObject_HEAD_INIT(NULL, 0)
     EXC_MODULE_NAME "BaseException", /*tp_name*/
     sizeof(PyBaseExceptionObject), /*tp_basicsize*/
     0,                          /*tp_itemsize*/
@@ -419,8 +418,7 @@ PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException;
  */
 #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \
 static PyTypeObject _PyExc_ ## EXCNAME = { \
-    PyObject_HEAD_INIT(NULL) \
-    0, \
+    PyVarObject_HEAD_INIT(NULL, 0) \
     EXC_MODULE_NAME # EXCNAME, \
     sizeof(PyBaseExceptionObject), \
     0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \
@@ -435,8 +433,7 @@ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
 
 #define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \
 static PyTypeObject _PyExc_ ## EXCNAME = { \
-    PyObject_HEAD_INIT(NULL) \
-    0, \
+    PyVarObject_HEAD_INIT(NULL, 0) \
     EXC_MODULE_NAME # EXCNAME, \
     sizeof(Py ## EXCSTORE ## Object), \
     0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
@@ -451,8 +448,7 @@ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
 
 #define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \
 static PyTypeObject _PyExc_ ## EXCNAME = { \
-    PyObject_HEAD_INIT(NULL) \
-    0, \
+    PyVarObject_HEAD_INIT(NULL, 0) \
     EXC_MODULE_NAME # EXCNAME, \
     sizeof(Py ## EXCSTORE ## Object), 0, \
     (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
@@ -1679,8 +1675,7 @@ done:
 }
 
 static PyTypeObject _PyExc_UnicodeEncodeError = {
-    PyObject_HEAD_INIT(NULL)
-    0,
+    PyVarObject_HEAD_INIT(NULL, 0)
     EXC_MODULE_NAME "UnicodeEncodeError",
     sizeof(PyUnicodeErrorObject), 0,
     (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1764,8 +1759,7 @@ done:
 }
 
 static PyTypeObject _PyExc_UnicodeDecodeError = {
-    PyObject_HEAD_INIT(NULL)
-    0,
+    PyVarObject_HEAD_INIT(NULL, 0)
     EXC_MODULE_NAME "UnicodeDecodeError",
     sizeof(PyUnicodeErrorObject), 0,
     (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1862,8 +1856,7 @@ done:
 }
 
 static PyTypeObject _PyExc_UnicodeTranslateError = {
-    PyObject_HEAD_INIT(NULL)
-    0,
+    PyVarObject_HEAD_INIT(NULL, 0)
     EXC_MODULE_NAME "UnicodeTranslateError",
     sizeof(PyUnicodeErrorObject), 0,
     (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
index a7d64ba16d440b878ce6a257e098c0f17c4ae4b8..b524f09e0a396eda0097eae724e5851068b91384 100644 (file)
@@ -121,10 +121,15 @@ dircheck(PyFileObject* f)
 {
 #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
     struct stat buf;
+    int res;
     if (f->f_fp == NULL)
         return f;
-    if (fstat(fileno(f->f_fp), &buf) == 0 &&
-        S_ISDIR(buf.st_mode)) {
+
+    Py_BEGIN_ALLOW_THREADS
+    res = fstat(fileno(f->f_fp), &buf);
+    Py_END_ALLOW_THREADS
+
+    if (res == 0 && S_ISDIR(buf.st_mode)) {
         char *msg = strerror(EISDIR);
         PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(isO)",
                                               EISDIR, msg, f->f_name);
@@ -427,10 +432,10 @@ close_the_file(PyFileObject *f)
     if (local_fp != NULL) {
         local_close = f->f_close;
         if (local_close != NULL && f->unlocked_count > 0) {
-            if (f->ob_refcnt > 0) {
+            if (Py_REFCNT(f) > 0) {
                 PyErr_SetString(PyExc_IOError,
                     "close() called during concurrent "
-                    "operation on the same file object.");
+                    "operation on the same file object");
             } else {
                 /* This should not happen unless someone is
                  * carelessly playing with the PyFileObject
@@ -438,7 +443,7 @@ close_the_file(PyFileObject *f)
                  * pointer. */
                 PyErr_SetString(PyExc_SystemError,
                     "PyFileObject locking error in "
-                    "destructor (refcnt <= 0 at close).");
+                    "destructor (refcnt <= 0 at close)");
             }
             return NULL;
         }
@@ -604,7 +609,12 @@ err_iterbuffered(void)
     return NULL;
 }
 
-static void drop_readahead(PyFileObject *);
+static void
+drop_file_readahead(PyFileObject *f)
+{
+    PyMem_FREE(f->f_buf);
+    f->f_buf = NULL;
+}
 
 /* Methods */
 
@@ -627,7 +637,7 @@ file_dealloc(PyFileObject *f)
     Py_XDECREF(f->f_mode);
     Py_XDECREF(f->f_encoding);
     Py_XDECREF(f->f_errors);
-    drop_readahead(f);
+    drop_file_readahead(f);
     Py_TYPE(f)->tp_free((PyObject *)f);
 }
 
@@ -762,7 +772,7 @@ file_seek(PyFileObject *f, PyObject *args)
 
     if (f->f_fp == NULL)
         return err_closed();
-    drop_readahead(f);
+    drop_file_readahead(f);
     whence = 0;
     if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence))
         return NULL;
@@ -1004,7 +1014,13 @@ new_buffersize(PyFileObject *f, size_t currentsize)
 #ifdef HAVE_FSTAT
     off_t pos, end;
     struct stat st;
-    if (fstat(fileno(f->f_fp), &st) == 0) {
+    int res;
+    size_t bufsize = 0;
+
+    FILE_BEGIN_ALLOW_THREADS(f)
+    res = fstat(fileno(f->f_fp), &st);
+
+    if (res == 0) {
         end = st.st_size;
         /* The following is not a bug: we really need to call lseek()
            *and* ftell().  The reason is that some stdio libraries
@@ -1015,16 +1031,21 @@ new_buffersize(PyFileObject *f, size_t currentsize)
            works.  We can't use the lseek() value either, because we
            need to take the amount of buffered data into account.
            (Yet another reason why stdio stinks. :-) */
+
         pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR);
+
         if (pos >= 0) {
             pos = ftell(f->f_fp);
         }
         if (pos < 0)
             clearerr(f->f_fp);
         if (end > pos && pos >= 0)
-            return currentsize + end - pos + 1;
+            bufsize = currentsize + end - pos + 1;
         /* Add 1 so if the file were to grow we'd notice. */
     }
+    FILE_END_ALLOW_THREADS(f)
+    if (bufsize != 0)
+        return bufsize;
 #endif
     /* Expand the buffer by an amount proportional to the current size,
        giving us amortized linear-time behavior. Use a less-than-double
@@ -2221,12 +2242,16 @@ static PyGetSetDef file_getsetlist[] = {
     {0},
 };
 
+typedef struct {
+    char *buf, *bufptr, *bufend;
+} readaheadbuffer;
+
 static void
-drop_readahead(PyFileObject *f)
+drop_readaheadbuffer(readaheadbuffer *rab)
 {
-    if (f->f_buf != NULL) {
-        PyMem_Free(f->f_buf);
-        f->f_buf = NULL;
+    if (rab->buf != NULL) {
+        PyMem_FREE(rab->buf);
+        rab->buf = NULL;
     }
 }
 
@@ -2234,35 +2259,34 @@ drop_readahead(PyFileObject *f)
    (unless at EOF) and no more than bufsize.  Returns negative value on
    error, will set MemoryError if bufsize bytes cannot be allocated. */
 static int
-readahead(PyFileObject *f, Py_ssize_t bufsize)
+readahead(PyFileObject *f, readaheadbuffer *rab, Py_ssize_t bufsize)
 {
     Py_ssize_t chunksize;
 
-    if (f->f_buf != NULL) {
-        if( (f->f_bufend - f->f_bufptr) >= 1)
+    if (rab->buf != NULL) {
+        if ((rab->bufend - rab->bufptr) >= 1)
             return 0;
         else
-            drop_readahead(f);
+            drop_readaheadbuffer(rab);
     }
-    if ((f->f_buf = (char *)PyMem_Malloc(bufsize)) == NULL) {
+    if ((rab->buf = PyMem_MALLOC(bufsize)) == NULL) {
         PyErr_NoMemory();
         return -1;
     }
     FILE_BEGIN_ALLOW_THREADS(f)
     errno = 0;
-    chunksize = Py_UniversalNewlineFread(
-        f->f_buf, bufsize, f->f_fp, (PyObject *)f);
+    chunksize = Py_UniversalNewlineFread(rab->buf, bufsize, f->f_fp, (PyObject *)f);
     FILE_END_ALLOW_THREADS(f)
     if (chunksize == 0) {
         if (ferror(f->f_fp)) {
             PyErr_SetFromErrno(PyExc_IOError);
             clearerr(f->f_fp);
-            drop_readahead(f);
+            drop_readaheadbuffer(rab);
             return -1;
         }
     }
-    f->f_bufptr = f->f_buf;
-    f->f_bufend = f->f_buf + chunksize;
+    rab->bufptr = rab->buf;
+    rab->bufend = rab->buf + chunksize;
     return 0;
 }
 
@@ -2272,45 +2296,43 @@ readahead(PyFileObject *f, Py_ssize_t bufsize)
    logarithmic buffer growth to about 50 even when reading a 1gb line. */
 
 static PyStringObject *
-readahead_get_line_skip(PyFileObject *f, Py_ssize_t skip, Py_ssize_t bufsize)
+readahead_get_line_skip(PyFileObject *f, readaheadbuffer *rab, Py_ssize_t skip, Py_ssize_t bufsize)
 {
     PyStringObject* s;
     char *bufptr;
     char *buf;
     Py_ssize_t len;
 
-    if (f->f_buf == NULL)
-        if (readahead(f, bufsize) < 0)
+    if (rab->buf == NULL)
+        if (readahead(f, rab, bufsize) < 0)
             return NULL;
 
-    len = f->f_bufend - f->f_bufptr;
+    len = rab->bufend - rab->bufptr;
     if (len == 0)
-        return (PyStringObject *)
-            PyString_FromStringAndSize(NULL, skip);
-    bufptr = (char *)memchr(f->f_bufptr, '\n', len);
+        return (PyStringObject *)PyString_FromStringAndSize(NULL, skip);
+    bufptr = (char *)memchr(rab->bufptr, '\n', len);
     if (bufptr != NULL) {
         bufptr++;                               /* Count the '\n' */
-        len = bufptr - f->f_bufptr;
-        s = (PyStringObject *)
-            PyString_FromStringAndSize(NULL, skip + len);
+        len = bufptr - rab->bufptr;
+        s = (PyStringObject *)PyString_FromStringAndSize(NULL, skip + len);
         if (s == NULL)
             return NULL;
-        memcpy(PyString_AS_STRING(s) + skip, f->f_bufptr, len);
-        f->f_bufptr = bufptr;
-        if (bufptr == f->f_bufend)
-            drop_readahead(f);
+        memcpy(PyString_AS_STRING(s) + skip, rab->bufptr, len);
+        rab->bufptr = bufptr;
+        if (bufptr == rab->bufend)
+            drop_readaheadbuffer(rab);
     } else {
-        bufptr = f->f_bufptr;
-        buf = f->f_buf;
-        f->f_buf = NULL;                /* Force new readahead buffer */
+        bufptr = rab->bufptr;
+        buf = rab->buf;
+        rab->buf = NULL;                /* Force new readahead buffer */
         assert(len <= PY_SSIZE_T_MAX - skip);
-        s = readahead_get_line_skip(f, skip + len, bufsize + (bufsize>>2));
+        s = readahead_get_line_skip(f, rab, skip + len, bufsize + (bufsize>>2));
         if (s == NULL) {
-            PyMem_Free(buf);
+            PyMem_FREE(buf);
             return NULL;
         }
         memcpy(PyString_AS_STRING(s) + skip, bufptr, len);
-        PyMem_Free(buf);
+        PyMem_FREE(buf);
     }
     return s;
 }
@@ -2328,7 +2350,30 @@ file_iternext(PyFileObject *f)
     if (!f->readable)
         return err_mode("reading");
 
-    l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE);
+    {
+        /*
+          Multiple threads can enter this method while the GIL is released
+          during file read and wreak havoc on the file object's readahead
+          buffer. To avoid dealing with cross-thread coordination issues, we
+          cache the file buffer state locally and only set it back on the file
+          object when we're done.
+        */
+        readaheadbuffer rab = {f->f_buf, f->f_bufptr, f->f_bufend};
+        f->f_buf = NULL;
+        l = readahead_get_line_skip(f, &rab, 0, READAHEAD_BUFSIZE);
+        /*
+          Make sure the file's internal read buffer is cleared out. This will
+          only do anything if some other thread interleaved with us during
+          readahead. We want to drop any changeling buffer, so we don't leak
+          memory. We may lose data, but that's what you get for reading the same
+          file object in multiple threads.
+        */
+        drop_file_readahead(f);
+        f->f_buf = rab.buf;
+        f->f_bufptr = rab.bufptr;
+        f->f_bufend = rab.bufend;
+    }
+
     if (l == NULL || PyString_GET_SIZE(l) == 0) {
         Py_XDECREF(l);
         return NULL;
@@ -2692,7 +2737,7 @@ int PyObject_AsFileDescriptor(PyObject *o)
     }
     else {
         PyErr_SetString(PyExc_TypeError,
-                        "argument must be an int, or have a fileno() method.");
+                        "argument must be an int, or have a fileno() method");
         return -1;
     }
 
index 801f286e6a4c78c12ee3c7b3188fc11493b7a2da..37dd67e669384185d1ccc5486b7ee297358ba810 100644 (file)
@@ -1,4 +1,3 @@
-
 /* Float object implementation */
 
 /* XXX There should be overflow checks here, but it's hard to check
@@ -65,7 +64,7 @@ PyFloat_GetMin(void)
     return DBL_MIN;
 }
 
-static PyTypeObject FloatInfoType = {0, 0, 0, 0, 0, 0};
+static PyTypeObject FloatInfoType;
 
 PyDoc_STRVAR(floatinfo__doc__,
 "sys.float_info\n\
@@ -80,7 +79,7 @@ static PyStructSequence_Field floatinfo_fields[] = {
                     "is representable"},
     {"max_10_exp",      "DBL_MAX_10_EXP -- maximum int e such that 10**e "
                     "is representable"},
-    {"min",             "DBL_MIN -- Minimum positive normalizer float"},
+    {"min",             "DBL_MIN -- Minimum positive normalized float"},
     {"min_exp",         "DBL_MIN_EXP -- minimum int e such that radix**(e-1) "
                     "is a normalized float"},
     {"min_10_exp",      "DBL_MIN_10_EXP -- minimum int e such that 10**e is "
@@ -90,7 +89,7 @@ static PyStructSequence_Field floatinfo_fields[] = {
     {"epsilon",         "DBL_EPSILON -- Difference between 1 and the next "
                     "representable float"},
     {"radix",           "FLT_RADIX -- radix of exponent"},
-    {"rounds",          "FLT_ROUNDS -- addition rounds"},
+    {"rounds",          "FLT_ROUNDS -- rounding mode"},
     {0}
 };
 
index 2c8fb017492e778760f6f74d5e25f3b8ad8a5611..175874503bb2fdf7617ad5805e5462389e1fe198 100644 (file)
@@ -89,6 +89,9 @@ frame_getlineno(PyFrameObject *f, void *closure)
  *  o 'try'/'for'/'while' blocks can't be jumped into because the blockstack
  *    needs to be set up before their code runs, and for 'for' loops the
  *    iterator needs to be on the stack.
+ *  o Jumps cannot be made from within a trace function invoked with a
+ *    'return' or 'exception' event since the eval loop has been exited at
+ *    that time.
  */
 static int
 frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
@@ -122,13 +125,32 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
         return -1;
     }
 
+    /* Upon the 'call' trace event of a new frame, f->f_lasti is -1 and
+     * f->f_trace is NULL, check first on the first condition.
+     * Forbidding jumps from the 'call' event of a new frame is a side effect
+     * of allowing to set f_lineno only from trace functions. */
+    if (f->f_lasti == -1) {
+        PyErr_Format(PyExc_ValueError,
+                     "can't jump from the 'call' trace event of a new frame");
+        return -1;
+    }
+
     /* You can only do this from within a trace function, not via
      * _getframe or similar hackery. */
-    if (!f->f_trace)
-    {
+    if (!f->f_trace) {
         PyErr_Format(PyExc_ValueError,
-                     "f_lineno can only be set by a"
-                     " line trace function");
+                     "f_lineno can only be set by a trace function");
+        return -1;
+    }
+
+    /* Forbid jumps upon a 'return' trace event (except after executing a
+     * YIELD_VALUE opcode, f_stacktop is not NULL in that case) and upon an
+     * 'exception' trace event.
+     * Jumps from 'call' trace events have already been forbidden above for new
+     * frames, so this check does not change anything for 'call' events. */
+    if (f->f_stacktop == NULL) {
+        PyErr_SetString(PyExc_ValueError,
+                "can only jump from a 'line' trace event");
         return -1;
     }
 
@@ -178,6 +200,15 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
     min_addr = MIN(new_lasti, f->f_lasti);
     max_addr = MAX(new_lasti, f->f_lasti);
 
+    /* The trace function is called with a 'return' trace event after the
+     * execution of a yield statement. */
+    assert(f->f_lasti != -1);
+    if (code[f->f_lasti] == YIELD_VALUE) {
+        PyErr_SetString(PyExc_ValueError,
+                "can't jump from a yield statement");
+        return -1;
+    }
+
     /* You can't jump onto a line with an 'except' statement on it -
      * they expect to have an exception on the top of the stack, which
      * won't be true if you jump to them.  They always start with code
@@ -340,6 +371,11 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
             PyObject *v = (*--f->f_stacktop);
             Py_DECREF(v);
         }
+        if (b->b_type == SETUP_WITH) {
+            /* Pop the exit function. */
+            PyObject *v = (*--f->f_stacktop);
+            Py_DECREF(v);
+        }
     }
 
     /* Finally set the new f_lineno and f_lasti and return OK. */
index 04e4d29916950d77ebc023042c4fa747fdd6d2f5..3ab00af1e28c97bca945c15336ad1a0a6d9a0bb3 100644 (file)
@@ -1486,7 +1486,7 @@ PyInt_ClearFreeList(void)
         for (i = 0, p = &list->objects[0];
              i < N_INTOBJECTS;
              i++, p++) {
-            if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
+            if (PyInt_CheckExact(p) && Py_REFCNT(p) != 0)
                 u++;
         }
         next = list->next;
@@ -1497,7 +1497,7 @@ PyInt_ClearFreeList(void)
                  i < N_INTOBJECTS;
                  i++, p++) {
                 if (!PyInt_CheckExact(p) ||
-                    p->ob_refcnt == 0) {
+                    Py_REFCNT(p) == 0) {
                     Py_TYPE(p) = (struct _typeobject *)
                         free_list;
                     free_list = p;
@@ -1560,14 +1560,14 @@ PyInt_Fini(void)
             for (i = 0, p = &list->objects[0];
                  i < N_INTOBJECTS;
                  i++, p++) {
-                if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
+                if (PyInt_CheckExact(p) && Py_REFCNT(p) != 0)
                     /* XXX(twouters) cast refcount to
                        long until %zd is universally
                        available
                      */
                     fprintf(stderr,
                 "#   <int at %p, refcnt=%ld, val=%ld>\n",
-                                p, (long)p->ob_refcnt,
+                                p, (long)Py_REFCNT(p),
                                 p->ob_ival);
             }
             list = list->next;
index bb65e98714eea16e6094b71b2d94eb724d34fc1d..24eff769c64e700ef261c076dbf9524db92610b0 100644 (file)
@@ -383,10 +383,7 @@ list_repr(PyListObject *v)
        so must refetch the list size on each iteration. */
     for (i = 0; i < Py_SIZE(v); ++i) {
         int status;
-        if (Py_EnterRecursiveCall(" while getting the repr of a list"))
-            goto Done;
         s = PyObject_Repr(v->ob_item[i]);
-        Py_LeaveRecursiveCall();
         if (s == NULL)
             goto Done;
         status = PyList_Append(pieces, s);
index 768a92a941446141b61d2d34abeed4ca55ff7acc..5d6ce70d537dde10aaf5aa3f9f6f03643f7bcb18 100644 (file)
@@ -83,12 +83,12 @@ _PyLong_Copy(PyLongObject *src)
     Py_ssize_t i;
 
     assert(src != NULL);
-    i = src->ob_size;
+    i = Py_SIZE(src);
     if (i < 0)
         i = -(i);
     result = _PyLong_New(i);
     if (result != NULL) {
-        result->ob_size = src->ob_size;
+        Py_SIZE(result) = Py_SIZE(src);
         while (--i >= 0)
             result->ob_digit[i] = src->ob_digit[i];
     }
@@ -129,7 +129,7 @@ PyLong_FromLong(long ival)
     v = _PyLong_New(ndigits);
     if (v != NULL) {
         digit *p = v->ob_digit;
-        v->ob_size = negative ? -ndigits : ndigits;
+        Py_SIZE(v) = negative ? -ndigits : ndigits;
         t = abs_ival;
         while (t) {
             *p++ = (digit)(t & PyLong_MASK);
@@ -372,7 +372,7 @@ PyLong_AsSsize_t(PyObject *vv) {
         return -1;
     }
     v = (PyLongObject *)vv;
-    i = v->ob_size;
+    i = Py_SIZE(v);
     sign = 1;
     x = 0;
     if (i < 0) {
@@ -464,7 +464,7 @@ PyLong_AsUnsignedLongMask(PyObject *vv)
         return (unsigned long) -1;
     }
     v = (PyLongObject *)vv;
-    i = v->ob_size;
+    i = Py_SIZE(v);
     sign = 1;
     x = 0;
     if (i < 0) {
@@ -951,7 +951,7 @@ PyLong_AsLongLong(PyObject *vv)
         PyObject *io;
         if (PyInt_Check(vv))
             return (PY_LONG_LONG)PyInt_AsLong(vv);
-        if ((nb = vv->ob_type->tp_as_number) == NULL ||
+        if ((nb = Py_TYPE(vv)->tp_as_number) == NULL ||
             nb->nb_int == NULL) {
             PyErr_SetString(PyExc_TypeError, "an integer is required");
             return -1;
@@ -1025,7 +1025,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *vv)
         return (unsigned long) -1;
     }
     v = (PyLongObject *)vv;
-    i = v->ob_size;
+    i = Py_SIZE(v);
     sign = 1;
     x = 0;
     if (i < 0) {
@@ -1068,7 +1068,7 @@ PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow)
 
     if (!PyLong_Check(vv)) {
         PyNumberMethods *nb;
-        nb = vv->ob_type->tp_as_number;
+        nb = Py_TYPE(vv)->tp_as_number;
         if (nb == NULL || nb->nb_int == NULL) {
             PyErr_SetString(PyExc_TypeError,
                             "an integer is required");
@@ -1495,10 +1495,10 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
     *p = '\0';
     if (addL)
         *--p = 'L';
-    if (a->ob_size < 0)
+    if (Py_SIZE(a) < 0)
         sign = '-';
 
-    if (a->ob_size == 0) {
+    if (Py_SIZE(a) == 0) {
         *--p = '0';
     }
     else if ((base & (base - 1)) == 0) {
@@ -2063,10 +2063,10 @@ long_divrem(PyLongObject *a, PyLongObject *b,
        The quotient z has the sign of a*b;
        the remainder r has the sign of a,
        so a = b*z + r. */
-    if ((a->ob_size < 0) != (b->ob_size < 0))
-        z->ob_size = -(z->ob_size);
-    if (a->ob_size < 0 && (*prem)->ob_size != 0)
-        (*prem)->ob_size = -((*prem)->ob_size);
+    if ((Py_SIZE(a) < 0) != (Py_SIZE(b) < 0))
+        Py_SIZE(z) = -(Py_SIZE(z));
+    if (Py_SIZE(a) < 0 && Py_SIZE(*prem) != 0)
+        Py_SIZE(*prem) = -Py_SIZE(*prem);
     *pdiv = z;
     return 0;
 }
@@ -2398,7 +2398,7 @@ long_hash(PyLongObject *v)
     /* This is designed so that Python ints and longs with the
        same value hash to the same value, otherwise comparisons
        of mapping keys will turn out weird */
-    i = v->ob_size;
+    i = Py_SIZE(v);
     sign = 1;
     x = 0;
     if (i < 0) {
@@ -2510,7 +2510,7 @@ x_sub(PyLongObject *a, PyLongObject *b)
     }
     assert(borrow == 0);
     if (sign < 0)
-        z->ob_size = -(z->ob_size);
+        Py_SIZE(z) = -(Py_SIZE(z));
     return long_normalize(z);
 }
 
@@ -2521,17 +2521,17 @@ long_add(PyLongObject *v, PyLongObject *w)
 
     CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
 
-    if (a->ob_size < 0) {
-        if (b->ob_size < 0) {
+    if (Py_SIZE(a) < 0) {
+        if (Py_SIZE(b) < 0) {
             z = x_add(a, b);
-            if (z != NULL && z->ob_size != 0)
-                z->ob_size = -(z->ob_size);
+            if (z != NULL && Py_SIZE(z) != 0)
+                Py_SIZE(z) = -(Py_SIZE(z));
         }
         else
             z = x_sub(b, a);
     }
     else {
-        if (b->ob_size < 0)
+        if (Py_SIZE(b) < 0)
             z = x_sub(a, b);
         else
             z = x_add(a, b);
@@ -2548,16 +2548,16 @@ long_sub(PyLongObject *v, PyLongObject *w)
 
     CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
 
-    if (a->ob_size < 0) {
-        if (b->ob_size < 0)
+    if (Py_SIZE(a) < 0) {
+        if (Py_SIZE(b) < 0)
             z = x_sub(a, b);
         else
             z = x_add(a, b);
-        if (z != NULL && z->ob_size != 0)
-            z->ob_size = -(z->ob_size);
+        if (z != NULL && Py_SIZE(z) != 0)
+            Py_SIZE(z) = -(Py_SIZE(z));
     }
     else {
-        if (b->ob_size < 0)
+        if (Py_SIZE(b) < 0)
             z = x_add(a, b);
         else
             z = x_sub(a, b);
@@ -2742,7 +2742,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
     /* If a is small compared to b, splitting on b gives a degenerate
      * case with ah==0, and Karatsuba may be (even much) less efficient
      * than "grade school" then.  However, we can still win, by viewing
-     * b as a string of "big digits", each of width a->ob_size.  That
+     * b as a string of "big digits", each of width Py_SIZE(a).  That
      * leads to a sequence of balanced calls to k_mul.
      */
     if (2 * asize <= bsize)
@@ -2910,7 +2910,7 @@ ah*bh and al*bl too.
 
 /* b has at least twice the digits of a, and a is big enough that Karatsuba
  * would pay off *if* the inputs had balanced sizes.  View b as a sequence
- * of slices, each with a->ob_size digits, and multiply the slices by a,
+ * of slices, each with Py_SIZE(a) digits, and multiply the slices by a,
  * one at a time.  This gives k_mul balanced inputs to work with, and is
  * also cache-friendly (we compute one double-width slice of the result
  * at a time, then move on, never backtracking except for the helpful
@@ -2982,8 +2982,8 @@ long_mul(PyLongObject *v, PyLongObject *w)
 
     z = k_mul(a, b);
     /* Negate if exactly one of the inputs is negative. */
-    if (((a->ob_size ^ b->ob_size) < 0) && z)
-        z->ob_size = -(z->ob_size);
+    if (((Py_SIZE(a) ^ Py_SIZE(b)) < 0) && z)
+        Py_SIZE(z) = -(Py_SIZE(z));
     Py_DECREF(a);
     Py_DECREF(b);
     return (PyObject *)z;
@@ -3464,7 +3464,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
             Py_DECREF(c);
             c = temp;
             temp = NULL;
-            c->ob_size = - c->ob_size;
+            Py_SIZE(c) = - Py_SIZE(c);
         }
 
         /* if modulus == 1:
@@ -3608,21 +3608,21 @@ static PyObject *
 long_neg(PyLongObject *v)
 {
     PyLongObject *z;
-    if (v->ob_size == 0 && PyLong_CheckExact(v)) {
+    if (Py_SIZE(v) == 0 && PyLong_CheckExact(v)) {
         /* -0 == 0 */
         Py_INCREF(v);
         return (PyObject *) v;
     }
     z = (PyLongObject *)_PyLong_Copy(v);
     if (z != NULL)
-        z->ob_size = -(v->ob_size);
+        Py_SIZE(z) = -(Py_SIZE(v));
     return (PyObject *)z;
 }
 
 static PyObject *
 long_abs(PyLongObject *v)
 {
-    if (v->ob_size < 0)
+    if (Py_SIZE(v) < 0)
         return long_neg(v);
     else
         return long_long((PyObject *)v);
@@ -3725,15 +3725,15 @@ long_lshift(PyObject *v, PyObject *w)
     wordshift = shiftby / PyLong_SHIFT;
     remshift  = shiftby - wordshift * PyLong_SHIFT;
 
-    oldsize = ABS(a->ob_size);
+    oldsize = ABS(Py_SIZE(a));
     newsize = oldsize + wordshift;
     if (remshift)
         ++newsize;
     z = _PyLong_New(newsize);
     if (z == NULL)
         goto out;
-    if (a->ob_size < 0)
-        z->ob_size = -(z->ob_size);
+    if (Py_SIZE(a) < 0)
+        Py_SIZE(z) = -(Py_SIZE(z));
     for (i = 0; i < wordshift; i++)
         z->ob_digit[i] = 0;
     accum = 0;
@@ -4142,7 +4142,7 @@ long_sizeof(PyLongObject *v)
 {
     Py_ssize_t res;
 
-    res = v->ob_type->tp_basicsize + ABS(Py_SIZE(v))*sizeof(digit);
+    res = Py_TYPE(v)->tp_basicsize + ABS(Py_SIZE(v))*sizeof(digit);
     return PyInt_FromSsize_t(res);
 }
 
@@ -4314,8 +4314,7 @@ static PyNumberMethods long_as_number = {
 };
 
 PyTypeObject PyLong_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,                                          /* ob_size */
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "long",                                     /* tp_name */
     offsetof(PyLongObject, ob_digit),           /* tp_basicsize */
     sizeof(digit),                              /* tp_itemsize */
index 7a2821897999d756e795e3ae27f39204937b57db..65366b0b351b4c049690f507a353711f44cdecf5 100644 (file)
@@ -378,7 +378,12 @@ PyObject_Repr(PyObject *v)
                                    Py_TYPE(v)->tp_name, v);
     else {
         PyObject *res;
+        /* It is possible for a type to have a tp_repr representation that
+           loops infinitely. */
+        if (Py_EnterRecursiveCall(" while getting the repr of an object"))
+            return NULL;
         res = (*Py_TYPE(v)->tp_repr)(v);
+        Py_LeaveRecursiveCall();
         if (res == NULL)
             return NULL;
 #ifdef Py_USING_UNICODE
index 1bb1866dc6f9ac2cfdc838f2c434154a0a443d96..9adcff7a27efd496eeb3f8157b2e0577c7a68e2b 100644 (file)
@@ -101,7 +101,7 @@ static int running_on_valgrind = -1;
  *
  * For small requests, the allocator sub-allocates <Big> blocks of memory.
  * Requests greater than SMALL_REQUEST_THRESHOLD bytes are routed to the
- * system's allocator. 
+ * system's allocator.
  *
  * Small requests are grouped in size classes spaced 8 bytes apart, due
  * to the required valid alignment of the returned address. Requests of
@@ -134,7 +134,7 @@ static int running_on_valgrind = -1;
  *       65-72                   72                       8
  *        ...                   ...                     ...
  *      497-504                 504                      62
- *      505-512                 512                      63 
+ *      505-512                 512                      63
  *
  *      0, SMALL_REQUEST_THRESHOLD + 1 and up: routed to the underlying
  *      allocator.
@@ -176,7 +176,7 @@ static int running_on_valgrind = -1;
  * Although not required, for better performance and space efficiency,
  * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2.
  */
-#define SMALL_REQUEST_THRESHOLD 512 
+#define SMALL_REQUEST_THRESHOLD 512
 #define NB_SMALL_SIZE_CLASSES   (SMALL_REQUEST_THRESHOLD / ALIGNMENT)
 
 /*
@@ -209,12 +209,12 @@ static int running_on_valgrind = -1;
  * usually an address range reservation for <Big> bytes, unless all pages within
  * this space are referenced subsequently. So malloc'ing big blocks and not
  * using them does not mean "wasting memory". It's an addressable range
- * wastage... 
+ * wastage...
  *
  * Arenas are allocated with mmap() on systems supporting anonymous memory
  * mappings to reduce heap fragmentation.
  */
-#define ARENA_SIZE              (256 << 10)     /* 256KB */
+#define ARENA_SIZE              (256 << 10)     /* 256KiB */
 
 #ifdef WITH_MEMORY_LIMITS
 #define MAX_ARENAS              (SMALL_MEMORY_LIMIT / ARENA_SIZE)
@@ -619,7 +619,7 @@ new_arena(void)
 #else
     address = malloc(ARENA_SIZE);
     err = (address == 0);
-#endif    
+#endif
     if (err) {
         /* The allocation failed: return NULL after putting the
          * arenaobj back.
@@ -1552,7 +1552,7 @@ _PyObject_DebugReallocApi(char api, void *p, size_t nbytes)
         /* overflow:  can't represent total as a size_t */
         return NULL;
 
-    if (nbytes < original_nbytes) {
+    if (nbytes <= original_nbytes) {
         /* shrinking:  mark old extra memory dead */
         memset(q + nbytes, DEADBYTE, original_nbytes - nbytes + 2*SST);
     }
@@ -1562,8 +1562,14 @@ _PyObject_DebugReallocApi(char api, void *p, size_t nbytes)
      * but we live with that.
      */
     q = (uchar *)PyObject_Realloc(q - 2*SST, total);
-    if (q == NULL)
+    if (q == NULL) {
+        if (nbytes <= original_nbytes) {
+            /* bpo-31626: the memset() above expects that realloc never fails
+               on shrinking a memory block. */
+            Py_FatalError("Shrinking reallocation failed");
+        }
         return NULL;
+    }
 
     write_size_t(q, nbytes);
     assert(q[SST] == (uchar)api);
index baa8deebe89149cb0954514095de2dd1bfc9f90e..888069a433a5073728a956ea764163567cd99916 100644 (file)
@@ -183,8 +183,7 @@ static PyMethodDef range_methods[] = {
 };
 
 PyTypeObject PyRange_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,                          /* Number of items for varobject */
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "xrange",                   /* Name of this type */
     sizeof(rangeobject),        /* Basic object size */
     0,                          /* Item size for varobject */
@@ -256,8 +255,7 @@ static PyMethodDef rangeiter_methods[] = {
 };
 
 static PyTypeObject Pyrangeiter_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,                                      /* ob_size */
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "rangeiterator",                        /* tp_name */
     sizeof(rangeiterobject),                /* tp_basicsize */
     0,                                      /* tp_itemsize */
index b3ca643c4f6caaefd177ad877f0726936c97cdc4..154be43564dd6d03b7b8ce8e2389edbde4c9352e 100644 (file)
@@ -549,6 +549,7 @@ set_dealloc(PySetObject *so)
 {
     register setentry *entry;
     Py_ssize_t fill = so->fill;
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
     PyObject_GC_UnTrack(so);
     Py_TRASHCAN_SAFE_BEGIN(so)
     if (so->weakreflist != NULL)
@@ -582,13 +583,13 @@ set_tp_print(PySetObject *so, FILE *fp, int flags)
         if (status < 0)
             return status;
         Py_BEGIN_ALLOW_THREADS
-        fprintf(fp, "%s(...)", so->ob_type->tp_name);
+        fprintf(fp, "%s(...)", Py_TYPE(so)->tp_name);
         Py_END_ALLOW_THREADS
         return 0;
     }
 
     Py_BEGIN_ALLOW_THREADS
-    fprintf(fp, "%s([", so->ob_type->tp_name);
+    fprintf(fp, "%s([", Py_TYPE(so)->tp_name);
     Py_END_ALLOW_THREADS
     while (set_next(so, &pos, &entry)) {
         Py_BEGIN_ALLOW_THREADS
@@ -616,7 +617,7 @@ set_repr(PySetObject *so)
     if (status != 0) {
         if (status < 0)
             return NULL;
-        return PyString_FromFormat("%s(...)", so->ob_type->tp_name);
+        return PyString_FromFormat("%s(...)", Py_TYPE(so)->tp_name);
     }
 
     keys = PySequence_List((PyObject *)so);
@@ -627,7 +628,7 @@ set_repr(PySetObject *so)
     if (listrepr == NULL)
         goto done;
 
-    result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name,
+    result = PyString_FromFormat("%s(%s)", Py_TYPE(so)->tp_name,
         PyString_AS_STRING(listrepr));
     Py_DECREF(listrepr);
 done:
@@ -811,6 +812,8 @@ typedef struct {
 static void
 setiter_dealloc(setiterobject *si)
 {
+    /* bpo-31095: UnTrack is needed before calling any callbacks */
+    _PyObject_GC_UNTRACK(si);
     Py_XDECREF(si->si_set);
     PyObject_GC_Del(si);
 }
index a61c8aa013b4c80d569e6807c85006e77c110859..6f4b18cc5c65a848c689c450da506d801682cae2 100644 (file)
@@ -288,10 +288,7 @@ tuplerepr(PyTupleObject *v)
 
     /* Do repr() on each element. */
     for (i = 0; i < n; ++i) {
-        if (Py_EnterRecursiveCall(" while getting the repr of a tuple"))
-            goto Done;
         s = PyObject_Repr(v->ob_item[i]);
-        Py_LeaveRecursiveCall();
         if (s == NULL)
             goto Done;
         PyTuple_SET_ITEM(pieces, i, s);
index 2eb4fe0b17fbf043ceba8f6928391bb91e4eeb60..344e6f24fc5bf061f12757cbf51e177c9cd9aa85 100644 (file)
@@ -196,7 +196,7 @@ weakref_repr(PyWeakReference *self)
 static PyObject *
 weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op)
 {
-    if ((op != Py_EQ && op != Py_NE) || self->ob_type != other->ob_type) {
+    if ((op != Py_EQ && op != Py_NE) || Py_TYPE(self) != Py_TYPE(other)) {
         Py_INCREF(Py_NotImplemented);
         return Py_NotImplemented;
     }
@@ -914,7 +914,7 @@ PyObject_ClearWeakRefs(PyObject *object)
 
     if (object == NULL
         || !PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))
-        || object->ob_refcnt != 0) {
+        || Py_REFCNT(object) != 0) {
         PyErr_BadInternalCall();
         return;
     }
@@ -937,7 +937,7 @@ PyObject_ClearWeakRefs(PyObject *object)
             current->wr_callback = NULL;
             clear_weakref(current);
             if (callback != NULL) {
-                if (current->ob_refcnt > 0)
+                if (Py_REFCNT(current) > 0)
                     handle_callback(current, callback);
                 Py_DECREF(callback);
             }
@@ -955,7 +955,7 @@ PyObject_ClearWeakRefs(PyObject *object)
             for (i = 0; i < count; ++i) {
                 PyWeakReference *next = current->wr_next;
 
-                if (current->ob_refcnt > 0)
+                if (Py_REFCNT(current) > 0)
                 {
                     Py_INCREF(current);
                     PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);
index 0fed5171a5e1be470859ea1489f074601b372518..6225fdff5d838115eaed03eeed1e1fb5fe50a175 100644 (file)
@@ -70,8 +70,8 @@ if '%build_tkinter%'=='true' (
         set tcl_dbg_ext=\r
         set debug_flag=0\r
     )\r
-    set tcldir=%externals_dir%\tcl-8.5.15.0\r
-    set tkdir=%externals_dir%\tk-8.5.15.0\r
+    set tcldir=%externals_dir%\tcl-8.5.19.0\r
+    set tkdir=%externals_dir%\tk-8.5.19.0\r
     set tixdir=%externals_dir%\tix-8.4.3.5\r
 )\r
 if '%build_tkinter%'=='true' (\r
index 8ddf78a40a9c387dca746fcfb3ed12055ae79e03..3578ab9eecf38a35faf92227ff8842f072f6f79e 100644 (file)
@@ -50,7 +50,7 @@
        />\r
        <UserMacro\r
                Name="bsddb47Dir"\r
-               Value="$(externalsDir)\db-4.7.25.0\build_windows"\r
+               Value="$(externalsDir)\bsddb-4.7.25.0\build_windows"\r
        />\r
        <UserMacro\r
                Name="bsddb47DepLibs"\r
@@ -74,7 +74,7 @@
        />\r
        <UserMacro\r
                Name="sqlite3Dir"\r
-               Value="$(externalsDir)\sqlite-3.8.11.0"\r
+               Value="$(externalsDir)\sqlite-3.14.2.0"\r
        />\r
        <UserMacro\r
                Name="bz2Dir"\r
index d56b5d10dc96c0f016dbda1ee0fb0d0784c49a43..d7700f09c749d436750c18697cf921d7181b8ff1 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -271,6 +271,7 @@ msiobj_dealloc(msiobj* msidb)
 {
     MsiCloseHandle(msidb->h);
     msidb->h = 0;
+    PyObject_Del(msidb);
 }
 
 static PyObject*
index f73d14f57930f279b64076d02cfc9e4296fd8533..fc9aaa461132cab47fe1edcecadaf340186174d8 100644 (file)
@@ -341,9 +341,13 @@ getenvironment(PyObject* environment)
     envsize = PyMapping_Length(environment);
 
     keys = PyMapping_Keys(environment);
+    if (!keys) {
+        return NULL;
+    }
     values = PyMapping_Values(environment);
-    if (!keys || !values)
+    if (!values) {
         goto error;
+    }
 
     out = PyString_FromStringAndSize(NULL, 2048);
     if (! out)
index b8f4191fd1fc177c1dd8563afedb6cd57bb98097..c52dc365a7d80e784a9d14ee344dd80b98f47a59 100644 (file)
@@ -5,12 +5,15 @@ echo.%~nx0 [flags and arguments] [quoted MSBuild options]
 echo.\r
 echo.Build CPython from the command line.  Requires the appropriate\r
 echo.version(s) of Microsoft Visual Studio to be installed (see readme.txt).\r
-echo.Also requires Subversion (svn.exe) to be on PATH if the '-e' flag is\r
-echo.given.\r
 echo.\r
 echo.After the flags recognized by this script, up to 9 arguments to be passed\r
 echo.directly to MSBuild may be passed.  If the argument contains an '=', the\r
-echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`)\r
+echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`).\r
+echo.Alternatively you can put extra flags for MSBuild in a file named \r
+echo.`msbuild.rsp` in the `PCbuild` directory, one flag per line. This file\r
+echo.will be picked automatically by MSBuild. Flags put in this file does not\r
+echo.need to be quoted. You can still use environment variables inside the \r
+echo.response file.\r
 echo.\r
 echo.Available flags:\r
 echo.  -h  Display this help message\r
@@ -47,7 +50,6 @@ exit /b 127
 :Run\r
 setlocal\r
 set platf=Win32\r
-set vs_platf=x86\r
 set conf=Release\r
 set target=Build\r
 set dir=%~dp0\r
@@ -56,10 +58,6 @@ set verbose=/nologo /v:m
 set kill=\r
 set do_pgo=\r
 set pgo_job=-m test.regrtest --pgo\r
-set on_64_bit=true\r
-\r
-rem This may not be 100% accurate, but close enough.\r
-if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)\r
 \r
 :CheckOpts\r
 if "%~1"=="-h" goto Usage\r
@@ -89,33 +87,27 @@ if "%IncludeBsddb%"=="" set IncludeBsddb=true
 \r
 if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"\r
 \r
-if "%platf%"=="x64" (\r
-    if "%on_64_bit%"=="true" (\r
-        rem This ought to always be correct these days...\r
-        set vs_platf=amd64\r
-    ) else (\r
-        if "%do_pgo%"=="true" (\r
-            echo.ERROR: Cannot cross-compile with PGO\r
-            echo.    32bit operating system detected, if this is incorrect,\r
-            echo.    make sure the ProgramFiles(x86^) environment variable is set\r
-            exit /b 1\r
-        )\r
-        set vs_platf=x86_amd64\r
+if "%do_pgo%" EQU "true" if "%platf%" EQU "x64" (\r
+    if "%PROCESSOR_ARCHITEW6432%" NEQ "AMD64" if "%PROCESSOR_ARCHITECTURE%" NEQ "AMD64" (\r
+        echo.ERROR: Cannot cross-compile with PGO \r
+        echo.       32bit operating system detected. Ensure your PROCESSOR_ARCHITECTURE\r
+        echo.       and PROCESSOR_ARCHITEW6432 environment variables are correct.\r
+        exit /b 1 \r
     )\r
 )\r
 \r
-if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"\r
+if "%GIT%" EQU "" set GIT=git\r
 if exist "%GIT%" set GITProperty=/p:GIT="%GIT%"\r
-if not exist "%GIT%" echo Cannot find Git on PATH & set GITProperty=\r
 \r
 rem Setup the environment\r
-call "%dir%env.bat" %vs_platf% >nul\r
+call "%dir%find_msbuild.bat" %MSBUILD%\r
+if ERRORLEVEL 1 (call "%dir%env.bat" && set MSBUILD=msbuild)\r
 \r
 if "%kill%"=="true" call :Kill\r
 \r
 if "%do_pgo%"=="true" (\r
     set conf=PGInstrument\r
-    call :Build\r
+    call :Build %1 %2 %3 %4 %5 %6 %7 %8 %9\r
     del /s "%dir%\*.pgc"\r
     del /s "%dir%\..\Lib\*.pyc"\r
     echo on\r
@@ -123,12 +115,13 @@ if "%do_pgo%"=="true" (
     @echo off\r
     call :Kill\r
     set conf=PGUpdate\r
+    set target=Build\r
 )\r
 goto Build\r
 \r
 :Kill\r
 echo on\r
-msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^\r
+%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^\r
  /p:Configuration=%conf% /p:Platform=%platf%^\r
  /p:KillPython=true\r
 \r
@@ -140,7 +133,7 @@ rem Call on MSBuild to do the work, echo the command.
 rem Passing %1-9 is not the preferred option, but argument parsing in\r
 rem batch is, shall we say, "lackluster"\r
 echo on\r
-msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^\r
+%MSBUILD% "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^\r
  /p:Configuration=%conf% /p:Platform=%platf%^\r
  /p:IncludeExternals=%IncludeExternals%^\r
  /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^\r
diff --git a/PCbuild/find_msbuild.bat b/PCbuild/find_msbuild.bat
new file mode 100644 (file)
index 0000000..08b6482
--- /dev/null
@@ -0,0 +1,52 @@
+@rem\r
+@rem Searches for MSBuild.exe. This is the only tool we need to initiate\r
+@rem a build, so we no longer search for the full VC toolset.\r
+@rem\r
+@rem This file is supposed to modify the state of the caller (specifically\r
+@rem the MSBUILD variable), so we do not use setlocal or echo, and avoid\r
+@rem changing any other persistent state.\r
+@rem\r
+\r
+@rem No arguments provided means do full search\r
+@if '%1' EQU '' goto :begin_search\r
+\r
+@rem One argument may be the full path. Use a goto so we don't try to\r
+@rem parse the next if statement - incorrect quoting in the multi-arg\r
+@rem case can cause us to break immediately.\r
+@if '%2' EQU '' goto :one_arg\r
+\r
+@rem Entire command line may represent the full path if quoting failed.\r
+@if exist "%*" (set MSBUILD="%*") & (set _Py_MSBuild_Source=environment) & goto :found\r
+@goto :begin_search\r
+\r
+:one_arg\r
+@if exist "%~1" (set MSBUILD="%~1") & (set _Py_MSBuild_Source=environment) & goto :found\r
+\r
+:begin_search\r
+@set MSBUILD=\r
+\r
+@rem If msbuild.exe is on the PATH, assume that the user wants that one.\r
+@msbuild /version > nul 2>&1\r
+@if NOT ERRORLEVEL 9009 set MSBUILD=msbuild & (set _Py_MSBuild_Source=PATH) & goto :found\r
+\r
+@rem VS 2015 and earlier register MSBuild separately, so we can find it.\r
+@rem Prefer MSBuild 14.0 over MSBuild 15.0, since the latter may not be able to find a VC14 install.\r
+@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32 >nul 2>nul\r
+@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32') DO @(\r
+    @if "%%i"=="MSBuildToolsPath" @if exist "%%k\msbuild.exe" @(set MSBUILD="%%k\msbuild.exe")\r
+)\r
+@if exist %MSBUILD% (set _Py_MSBuild_Source=registry) & goto :found\r
+\r
+@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there.\r
+@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul\r
+@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @(\r
+    @if "%%i"=="15.0" @if exist "%%k\MSBuild\15.0\Bin\msbuild.exe" @(set MSBUILD="%%k\MSBuild\15.0\Bin\msbuild.exe")\r
+)\r
+@if exist %MSBUILD% (set _Py_MSBuild_Source=Visual Studio 2017 registry) & goto :found\r
+\r
+\r
+@exit /b 1\r
+\r
+:found\r
+@echo Using %MSBUILD% (found in the %_Py_MSBuild_Source%)\r
+@set _Py_MSBuild_Source=\r
diff --git a/PCbuild/find_python.bat b/PCbuild/find_python.bat
new file mode 100644 (file)
index 0000000..6e81200
--- /dev/null
@@ -0,0 +1,75 @@
+@rem\r
+@rem Searches for python.exe and may download a private copy from nuget.\r
+@rem\r
+@rem This file is supposed to modify the state of the caller (specifically\r
+@rem the MSBUILD variable), so we do not use setlocal or echo, and avoid\r
+@rem changing any other persistent state.\r
+@rem\r
+\r
+@rem No arguments provided means do full search\r
+@if '%1' EQU '' goto :begin_search\r
+\r
+@rem One argument may be the full path. Use a goto so we don't try to\r
+@rem parse the next if statement - incorrect quoting in the multi-arg\r
+@rem case can cause us to break immediately.\r
+@if '%2' EQU '' goto :one_arg\r
+\r
+@rem Entire command line may represent the full path if quoting failed.\r
+@if exist "%*" (set PYTHON="%*") & (set _Py_Python_Source=from environment) & goto :found\r
+@goto :begin_search\r
+\r
+:one_arg\r
+@if exist "%~1" (set PYTHON="%~1") & (set _Py_Python_Source=from environment) & goto :found\r
+\r
+:begin_search\r
+@set PYTHON=\r
+\r
+@set _Py_EXTERNALS_DIR=%EXTERNAL_DIR%\r
+@if "%_Py_EXTERNALS_DIR%"=="" (set _Py_EXTERNALS_DIR=%~dp0\..\externals)\r
+\r
+@rem If we have Python in externals, use that one\r
+@if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") & (set _Py_Python_Source=found in externals directory) & goto :found\r
+\r
+@rem If HOST_PYTHON is recent enough, use that\r
+@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -c "import sys; assert sys.version_info[:2] >= (3, 6)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found\r
+\r
+@rem If py.exe finds a recent enough version, use that one\r
+@py -3.6 -V >nul 2>&1 && (set PYTHON=py -3.6) && (set _Py_Python_Source=found with py.exe) && goto :found\r
+\r
+@if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%"\r
+@set _Py_NUGET=%NUGET%\r
+@set _Py_NUGET_URL=%NUGET_URL%\r
+@set _Py_HOST_PYTHON=%HOST_PYTHON%\r
+@if "%_Py_HOST_PYTHON%"=="" set _Py_HOST_PYTHON=py\r
+@if "%_Py_NUGET%"=="" (set _Py_NUGET=%_Py_EXTERNALS_DIR%\nuget.exe)\r
+@if "%_Py_NUGET_URL%"=="" (set _Py_NUGET_URL=https://aka.ms/nugetclidl)\r
+@if NOT exist "%_Py_NUGET%" (\r
+    @echo Downloading nuget...\r
+    @rem NB: Must use single quotes around NUGET here, NOT double!\r
+    @rem Otherwise, a space in the path would break things\r
+    @rem If it fails, retry with any available copy of Python\r
+    @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%'\r
+    @if errorlevel 1 (\r
+        @%_Py_HOST_PYTHON% "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%"\r
+    )\r
+)\r
+@echo Installing Python via nuget...\r
+@"%_Py_NUGET%" install pythonx86 -ExcludeVersion -OutputDirectory "%_Py_EXTERNALS_DIR%"\r
+@rem Quote it here; it's not quoted later because "py -3.6" wouldn't work\r
+@if not errorlevel 1 (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") & (set _Py_Python_Source=found on nuget.org) & goto :found\r
+\r
+\r
+@set _Py_Python_Source=\r
+@set _Py_EXTERNALS_DIR=\r
+@set _Py_NUGET=\r
+@set _Py_NUGET_URL=\r
+@set _Py_HOST_PYTHON=\r
+@exit /b 1\r
+\r
+:found\r
+@echo Using %PYTHON% (%_Py_Python_Source%)\r
+@set _Py_Python_Source=\r
+@set _Py_EXTERNALS_DIR=\r
+@set _Py_NUGET=\r
+@set _Py_NUGET_URL=\r
+@set _Py_HOST_PYTHON=\r
diff --git a/PCbuild/get_external.py b/PCbuild/get_external.py
new file mode 100644 (file)
index 0000000..a682d38
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import pathlib
+import zipfile
+from urllib.request import urlretrieve
+
+
+def fetch_zip(commit_hash, zip_dir, *, org='python', binary=False, verbose):
+    repo = f'cpython-{"bin" if binary else "source"}-deps'
+    url = f'https://github.com/{org}/{repo}/archive/{commit_hash}.zip'
+    reporthook = None
+    if verbose:
+        reporthook = print
+    zip_dir.mkdir(parents=True, exist_ok=True)
+    filename, headers = urlretrieve(
+        url,
+        zip_dir / f'{commit_hash}.zip',
+        reporthook=reporthook,
+    )
+    return filename
+
+
+def extract_zip(externals_dir, zip_path):
+    with zipfile.ZipFile(os.fspath(zip_path)) as zf:
+        zf.extractall(os.fspath(externals_dir))
+        return externals_dir / zf.namelist()[0].split('/')[0]
+
+
+def parse_args():
+    p = argparse.ArgumentParser()
+    p.add_argument('-v', '--verbose', action='store_true')
+    p.add_argument('-b', '--binary', action='store_true',
+                   help='Is the dependency in the binary repo?')
+    p.add_argument('-O', '--organization',
+                   help='Organization owning the deps repos', default='python')
+    p.add_argument('-e', '--externals-dir', type=pathlib.Path,
+                   help='Directory in which to store dependencies',
+                   default=pathlib.Path(__file__).parent.parent / 'externals')
+    p.add_argument('tag',
+                   help='tag of the dependency')
+    return p.parse_args()
+
+
+def main():
+    args = parse_args()
+    zip_path = fetch_zip(
+        args.tag,
+        args.externals_dir / 'zips',
+        org=args.organization,
+        binary=args.binary,
+        verbose=args.verbose,
+    )
+    final_name = args.externals_dir / args.tag
+    extract_zip(args.externals_dir, zip_path).replace(final_name)
+
+
+if __name__ == '__main__':
+    main()
index 7a7a1e2390b8604d7694e38a386143c50d4aee9f..b5cf00c4eee07e5326697762fdf73ca9c8e7a1e6 100644 (file)
@@ -2,51 +2,41 @@
 setlocal\r
 rem Simple script to fetch source for external libraries\r
 \r
-if not exist "%~dp0..\externals" mkdir "%~dp0..\externals"\r
-pushd "%~dp0..\externals"\r
+if "%PCBUILD%"=="" (set PCBUILD=%~dp0)\r
+if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%PCBUILD%\..\externals)\r
 \r
-if "%SVNROOT%"=="" set SVNROOT=http://svn.python.org/projects/external/\r
+set DO_FETCH=true\r
+set DO_CLEAN=false\r
 \r
-rem Optionally clean up first.  Be warned that this can be very destructive!\r
-if not "%1"=="" (\r
-    for %%c in (-c --clean --clean-only) do (\r
-        if "%1"=="%%c" goto clean\r
-    )\r
-    goto usage\r
-)\r
-goto fetch\r
+:CheckOpts\r
+if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts\r
+if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts\r
+if "%~1"=="--python" (set PYTHON_FOR_BUILD=%2) & shift & shift & goto CheckOpts\r
+if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts\r
+if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts\r
+if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts\r
+if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean\r
+if "x%~1" NEQ "x" goto usage\r
 \r
+if "%DO_CLEAN%"=="false" goto fetch\r
 :clean\r
 echo.Cleaning up external libraries.\r
-for /D %%d in (\r
-               bzip2-*\r
-               db-*\r
-               nasm-*\r
-               openssl-*\r
-               tcl-*\r
-               tcltk*\r
-               tk-*\r
-               tix-*\r
-               sqlite-*\r
-               xz-*\r
-               ) do (\r
-    echo.Removing %%d\r
-    rmdir /s /q %%d\r
-)\r
-if "%1"=="--clean-only" (\r
-    goto end\r
+if exist "%EXTERNALS_DIR%" (\r
+    rem Sometimes this fails the first time; try it twice\r
+    rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%"\r
 )\r
 \r
+if "%DO_FETCH%"=="false" goto end\r
 :fetch\r
-rem Fetch current versions\r
 \r
-svn --version > nul 2>&1\r
+if "%ORG%"=="" (set ORG=python)\r
+call "%PCBUILD%\find_python.bat" "%PYTHON%"\r
+\r
+git 2>&1 > nul\r
 if ERRORLEVEL 9009 (\r
-    echo.svn.exe must be on your PATH.\r
-    echo.Try TortoiseSVN (http://tortoisesvn.net/^) and be sure to check the\r
-    echo.command line tools option.\r
-    popd\r
-    exit /b 1\r
+    if "%PYTHON%"=="" (\r
+        echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1\r
+    )\r
 )\r
 \r
 echo.Fetching external libraries...\r
@@ -56,52 +46,62 @@ rem files in both this dir and PC\VS9.0
 \r
 set libraries=\r
 set libraries=%libraries%                                    bzip2-1.0.6\r
-if NOT "%IncludeBsddb%"=="false" set libraries=%libraries%   db-4.7.25.0\r
-if NOT "%IncludeSSL%"=="false" set libraries=%libraries%     nasm-2.11.06\r
-if NOT "%IncludeSSL%"=="false" set libraries=%libraries%     openssl-1.0.2k\r
-set libraries=%libraries%                                    sqlite-3.8.11.0\r
-if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.15.0\r
-if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.15.0\r
+if NOT "%IncludeBsddb%"=="false" set libraries=%libraries%   bsddb-4.7.25.0\r
+if NOT "%IncludeSSL%"=="false" set libraries=%libraries%     openssl-1.0.2o\r
+set libraries=%libraries%                                    sqlite-3.14.2.0\r
+if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.19.0\r
+if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.19.0\r
 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.5\r
 \r
 for %%e in (%libraries%) do (\r
-    if exist %%e (\r
+    if exist "%EXTERNALS_DIR%\%%e" (\r
         echo.%%e already exists, skipping.\r
+    ) else if "%PYTHON%"=="" (\r
+        echo.Fetching %%e with git...\r
+        git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"\r
     ) else (\r
         echo.Fetching %%e...\r
-        svn export -q %SVNROOT%%%e\r
+        %PYTHON% "%PCBUILD%\get_external.py" -O %ORG% %%e\r
+    )\r
+)\r
+\r
+echo.Fetching external binaries...\r
+\r
+set binaries=\r
+set binaries=%binaries%\r
+if NOT "%IncludeSSL%"=="false" set binaries=%binaries%     nasm-2.11.06\r
+\r
+for %%b in (%binaries%) do (\r
+    if exist "%EXTERNALS_DIR%\%%b" (\r
+        echo.%%b already exists, skipping.\r
+    ) else if "%PYTHON%"=="" (\r
+        echo.Fetching %%b with git...\r
+        git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"\r
+    ) else (\r
+        echo.Fetching %%b...\r
+        %PYTHON% "%PCBUILD%\get_external.py" -b -O %ORG% %%b\r
     )\r
 )\r
 \r
+echo Finished.\r
 goto end\r
 \r
 :usage\r
-echo.invalid argument: %1\r
-echo.usage: %~n0 [[ -c ^| --clean ] ^| --clean-only ]\r
+echo.Valid options: -c, --clean, --clean-only, --organization, --python,\r
+echo.--no-tkinter, --no-openssl\r
 echo.\r
-echo.Pull all sources necessary for compiling optional extension modules\r
-echo.that rely on external libraries.  Requires svn.exe to be on your PATH\r
-echo.and pulls sources from %SVNROOT%.\r
+echo.Pull all sources and binaries necessary for compiling optional extension\r
+echo.modules that rely on external libraries.\r
 echo.\r
-echo.Use the -c or --clean option to clean up all external library sources\r
-echo.before pulling in the current versions.\r
+echo.The --organization option determines which github organization to download\r
+echo.from, the --python option determines which Python 3.6+ interpreter to use\r
+echo.with PCbuild\get_external.py.\r
+echo.\r
+echo.Use the -c or --clean option to remove the entire externals directory.\r
 echo.\r
 echo.Use the --clean-only option to do the same cleaning, without pulling in\r
 echo.anything new.\r
 echo.\r
-echo.Only the first argument is checked, all others are ignored.\r
-echo.\r
-echo.**WARNING**: the cleaning options unconditionally remove any directory\r
-echo.that is a child of\r
-echo.   %CD%\r
-echo.and matches wildcard patterns beginning with bzip2-, db-, nasm-, openssl-,\r
-echo.tcl-, tcltk, tk-, tix-, sqlite-, or xz-, and as such has the potential\r
-echo.to be very destructive if you are not aware of what it is doing.  Use with\r
-echo.caution!\r
-popd\r
 exit /b -1\r
 \r
-\r
 :end\r
-echo Finished.\r
-popd\r
index 4cf4e5b9ef59c87438620cc42595fb3ff2374f6a..5f5ae75c15371bccd972cab034bcae88a79d5174 100644 (file)
 \r
     <!-- Directories of external projects. tcltk is handled in tcltk.props -->\r
     <ExternalsDir>$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`))</ExternalsDir>\r
-    <sqlite3Dir>$(ExternalsDir)sqlite-3.8.11.0\</sqlite3Dir>\r
+    <sqlite3Dir>$(ExternalsDir)sqlite-3.14.2.0\</sqlite3Dir>\r
     <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>\r
-    <bsddbDir>$(ExternalsDir)db-4.7.25.0</bsddbDir>\r
-    <opensslDir>$(ExternalsDir)openssl-1.0.2k\</opensslDir>\r
+    <bsddbDir>$(ExternalsDir)bsddb-4.7.25.0</bsddbDir>\r
+    <opensslDir>$(ExternalsDir)openssl-1.0.2o\</opensslDir>\r
     <opensslIncludeDir>$(opensslDir)include32</opensslIncludeDir>\r
     <opensslIncludeDir Condition="'$(ArchName)' == 'amd64'">$(opensslDir)include64</opensslIncludeDir>\r
     <nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>\r
index 75f0d479ec8bc0abe8c328c8c7835b992001c225..093e9f02d41e5939734dff1f2e061ff76dbe8250 100644 (file)
@@ -93,6 +93,8 @@
   </ImportGroup>\r
   <Target Name="GeneratePythonBat" AfterTargets="AfterBuild">\r
     <PropertyGroup>\r
+      <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin</_PGOPath>\r
+      <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64</_PGOPath>\r
       <_Content>@rem This script invokes the most recently built Python with all arguments\r
 @rem passed through to the interpreter.  This file is generated by the\r
 @rem build process and any changes *will* be thrown away by the next\r
 @rem This is only meant as a convenience for developing CPython\r
 @rem and using it outside of that context is ill-advised.\r
 @echo Running $(Configuration)^|$(Platform) interpreter...\r
+@setlocal\r
+@set PYTHONHOME=$(PySourcePath)\r
+$(_PGOPath)\r
 @"$(OutDir)python$(PyDebugExt).exe" %*\r
 </_Content>\r
       <_ExistingContent Condition="Exists('$(PySourcePath)python.bat')">$([System.IO.File]::ReadAllText('$(PySourcePath)python.bat'))</_ExistingContent>\r
index 9438b3991263a38e9c9c4522958c5f51c2ae28fa..df1c0c78da6741bcd926c3cb6aa24cf65eacdbf4 100644 (file)
@@ -4,9 +4,11 @@ Quick Start Guide
 1.  Install Microsoft Visual Studio 2008, any edition.\r
 2.  Install Microsoft Visual Studio 2010, any edition, or Windows SDK 7.1\r
     and any version of Microsoft Visual Studio newer than 2010.\r
-3.  Install Subversion, and make sure 'svn.exe' is on your PATH.\r
-4.  Run "build.bat -e" to build Python in 32-bit Release configuration.\r
-5.  (Optional, but recommended) Run the test suite with "rt.bat -q".\r
+2a. Optionally install Python 3.6 or later.  If not installed,\r
+    get_externals.bat (build.bat -e) will download and use Python via\r
+    NuGet.\r
+3.  Run "build.bat -e" to build Python in 32-bit Release configuration.\r
+4.  (Optional, but recommended) Run the test suite with "rt.bat -q".\r
 \r
 \r
 Building Python using MSVC 9.0 via MSBuild\r
@@ -38,13 +40,20 @@ MSVCRT90.dll.
 \r
 For other Windows platforms and compilers, see ../PC/readme.txt.\r
 \r
-All you need to do to build is open the solution "pcbuild.sln" in Visual\r
-Studio, select the desired combination of configuration and platform,\r
+To build modules that depend on external libraries, you need to download\r
+(and, for some of them, build) those first. It's thus recommended to build\r
+from the command line once as specified below under "Getting External Sources"\r
+as that does this automatically.\r
+\r
+Then, to continue development, you can open the solution "pcbuild.sln" in\r
+Visual Studio, select the desired combination of configuration and platform,\r
 then build with "Build Solution".  You can also build from the command\r
 line using the "build.bat" script in this directory; see below for\r
 details.  The solution is configured to build the projects in the correct\r
 order.\r
 \r
+To build an installer package, refer to the README in the Tools/msi folder.\r
+\r
 The solution currently supports two platforms.  The Win32 platform is\r
 used to build standard x86-compatible 32-bit binaries, output into this\r
 directory.  The x64 platform is used for building 64-bit AMD64 (aka\r
@@ -183,7 +192,7 @@ _bz2
     Homepage:\r
         http://www.bzip.org/\r
 _ssl\r
-    Python wrapper for version 1.0.2k of the OpenSSL secure sockets\r
+    Python wrapper for version 1.0.2o of the OpenSSL secure sockets\r
     library, which is built by ssl.vcxproj\r
     Homepage:\r
         http://www.openssl.org/\r
@@ -222,7 +231,7 @@ _sqlite3
     Homepage:\r
         http://www.sqlite.org/\r
 _tkinter\r
-    Wraps version 8.5.15 of the Tk windowing system.\r
+    Wraps version 8.5.19 of the Tk windowing system.\r
     Homepage:\r
         http://www.tcl.tk/\r
 \r
@@ -250,9 +259,16 @@ order to download the relevant source files for each project before they
 can be built.  However, a simple script is provided to make this as\r
 painless as possible, called "get_externals.bat" and located in this\r
 directory.  This script extracts all the external sub-projects from\r
-    http://svn.python.org/projects/external\r
-via Subversion (so you'll need svn.exe on your PATH) and places them\r
-in ..\externals (relative to this directory).\r
+    https://github.com/python/cpython-source-deps\r
+and\r
+    https://github.com/python/cpython-bin-deps\r
+via a Python script called "get_external.py", located in this directory.\r
+If Python 3.6 or later is not available via the "py.exe" launcher, the\r
+path or command to use for Python can be provided in the PYTHON_FOR_BUILD\r
+environment variable, or get_externals.bat will download the latest\r
+version of NuGet and use it to download the latest "pythonx86" package\r
+for use with get_external.py.  Everything downloaded by these scripts is\r
+stored in ..\externals (relative to this directory).\r
 \r
 It is also possible to download sources from each project's homepage,\r
 though you may have to change folder names or pass the names to MSBuild\r
index 072523c9ee768184b4d38510bbf8d58e8999b959..111ccb1f87216743cd50e7a09c94070c5bbc252a 100644 (file)
@@ -4,7 +4,7 @@
   <PropertyGroup>\r
     <TclMajorVersion>8</TclMajorVersion>\r
     <TclMinorVersion>5</TclMinorVersion>\r
-    <TclPatchLevel>15</TclPatchLevel>\r
+    <TclPatchLevel>19</TclPatchLevel>\r
     <TclRevision>0</TclRevision>\r
     <TkMajorVersion>$(TclMajorVersion)</TkMajorVersion>\r
     <TkMinorVersion>$(TclMinorVersion)</TkMinorVersion>\r
index 8e8c0cceb311df6752f4ebe751318128c38f723d..37875e56199af3e9d966ddf85fe88f54064ec21e 100644 (file)
@@ -72,6 +72,12 @@ get_once_registry(void)
             return NULL;
         return _once_registry;
     }
+    if (!PyDict_Check(registry)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "warnings.onceregistry must be a dict");
+        Py_DECREF(registry);
+        return NULL;
+    }
     Py_DECREF(_once_registry);
     _once_registry = registry;
     return registry;
@@ -296,7 +302,7 @@ warn_explicit(PyObject *category, PyObject *message,
     int rc;
 
     if (registry && !PyDict_Check(registry) && (registry != Py_None)) {
-        PyErr_SetString(PyExc_TypeError, "'registry' must be a dict");
+        PyErr_SetString(PyExc_TypeError, "'registry' must be a dict or None");
         return NULL;
     }
 
@@ -678,8 +684,9 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
         }
 
         /* Split the source into lines. */
-        source_list = PyObject_CallMethodObjArgs(source, splitlines_name,
-                                                    NULL);
+        source_list = PyObject_CallMethodObjArgs((PyObject *)&PyString_Type,
+                                                 splitlines_name, source,
+                                                 NULL);
         Py_DECREF(source);
         if (!source_list)
             return NULL;
index 70308e9dc9eaf425b2cbef0fb621ec49c8d2d149..9ce3b275eab2efb5a4717dba032222d92df042fa 100644 (file)
@@ -54,7 +54,7 @@ PyDoc_STRVAR(import_doc,
 "__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n\
 \n\
 Import a module. Because this function is meant for use by the Python\n\
-interpreter and not for general use it is better to use\n\
+interpreter and not for general use, it is better to use\n\
 importlib.import_module() to programmatically import a module.\n\
 \n\
 The globals argument is only used to determine the context;\n\
@@ -63,9 +63,8 @@ should be a list of names to emulate ``from name import ...'', or an\n\
 empty list to emulate ``import name''.\n\
 When importing a module from a package, note that __import__('A.B', ...)\n\
 returns package A when fromlist is empty, but its submodule B when\n\
-fromlist is not empty.  Level is used to determine whether to perform \n\
-absolute or relative imports.  -1 is the original strategy of attempting\n\
-both absolute and relative imports, 0 is absolute, a positive number\n\
+fromlist is not empty.  The level argument is used to determine whether to\n\
+perform absolute or relative imports: 0 is absolute, while a positive number\n\
 is the number of parent directories to search relative to the current module.");
 
 
@@ -374,7 +373,9 @@ PyDoc_STRVAR(format_doc,
 "format(value[, format_spec]) -> string\n\
 \n\
 Returns value.__format__(format_spec)\n\
-format_spec defaults to \"\"");
+format_spec defaults to the empty string.\n\
+See the Format Specification Mini-Language section of help('FORMATTING') for\n\
+details.");
 
 static PyObject *
 builtin_chr(PyObject *self, PyObject *args)
index 4e4adc2d63dc1b696a72bbdcd69630b66a35c7b6..b55b4d66880cd03b56163b4764661f778e574387 100644 (file)
@@ -689,11 +689,19 @@ PyObject *
 PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 {
 #ifdef DYNAMIC_EXECUTION_PROFILE
-  #undef USE_COMPUTED_GOTOS
+    #undef USE_COMPUTED_GOTOS
 #endif
 #ifdef HAVE_COMPUTED_GOTOS
     #ifndef USE_COMPUTED_GOTOS
-    #define USE_COMPUTED_GOTOS 1
+        #if defined(__clang__) && (__clang_major__ < 5)
+            /* Computed gotos caused significant performance regression
+             * with clang < 5.0.
+             * https://bugs.python.org/issue32616
+             */
+            #define USE_COMPUTED_GOTOS 0
+        #else
+            #define USE_COMPUTED_GOTOS 1
+        #endif
     #endif
 #else
     #if defined(USE_COMPUTED_GOTOS) && USE_COMPUTED_GOTOS
@@ -2590,6 +2598,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 
         TARGET(IMPORT_NAME)
         {
+            long res;
             w = GETITEM(names, oparg);
             x = PyDict_GetItemString(f->f_builtins, "__import__");
             if (x == NULL) {
@@ -2600,7 +2609,12 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
             Py_INCREF(x);
             v = POP();
             u = TOP();
-            if (PyInt_AsLong(u) != -1 || PyErr_Occurred())
+            res = PyInt_AsLong(u);
+            if (res != -1 || PyErr_Occurred()) {
+                if (res == -1) {
+                    assert(PyErr_Occurred());
+                    PyErr_Clear();
+                }
                 w = PyTuple_Pack(5,
                             w,
                             f->f_globals,
@@ -2608,6 +2622,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                   Py_None : f->f_locals,
                             v,
                             u);
+            }
             else
                 w = PyTuple_Pack(4,
                             w,
index 9c9b23698520bb0fb4546d513f96d11b3076e010..4fe69e12bf84840e3ad0d041c77110537d9d0ba0 100644 (file)
@@ -1075,6 +1075,15 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
         return 0; \
 }
 
+/* Same as ADDOP_O, but steals a reference. */
+#define ADDOP_N(C, OP, O, TYPE) { \
+    if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) { \
+        Py_DECREF((O)); \
+        return 0; \
+    } \
+    Py_DECREF((O)); \
+}
+
 #define ADDOP_NAME(C, OP, O, TYPE) { \
     if (!compiler_addop_name((C), (OP), (C)->u->u_ ## TYPE, (O))) \
         return 0; \
@@ -1890,8 +1899,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
                                 dot ? dot - src : strlen(src));
             if (!attr)
                 return 0;
-            ADDOP_O(c, LOAD_ATTR, attr, names);
-            Py_DECREF(attr);
+            ADDOP_N(c, LOAD_ATTR, attr, names);
             src = dot + 1;
         }
     }
@@ -1923,8 +1931,7 @@ compiler_import(struct compiler *c, stmt_ty s)
         if (level == NULL)
             return 0;
 
-        ADDOP_O(c, LOAD_CONST, level, consts);
-        Py_DECREF(level);
+        ADDOP_N(c, LOAD_CONST, level, consts);
         ADDOP_O(c, LOAD_CONST, Py_None, consts);
         ADDOP_NAME(c, IMPORT_NAME, alias->name, names);
 
@@ -1959,8 +1966,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
 {
     int i, n = asdl_seq_LEN(s->v.ImportFrom.names);
 
-    PyObject *names = PyTuple_New(n);
-    PyObject *level;
+    PyObject *level, *names;
     static PyObject *empty_string;
 
     if (!empty_string) {
@@ -1969,9 +1975,6 @@ compiler_from_import(struct compiler *c, stmt_ty s)
             return 0;
     }
 
-    if (!names)
-        return 0;
-
     if (s->v.ImportFrom.level == 0 && c->c_flags &&
         !(c->c_flags->cf_flags & CO_FUTURE_ABSOLUTE_IMPORT))
         level = PyInt_FromLong(-1);
@@ -1979,9 +1982,13 @@ compiler_from_import(struct compiler *c, stmt_ty s)
         level = PyInt_FromLong(s->v.ImportFrom.level);
 
     if (!level) {
-        Py_DECREF(names);
         return 0;
     }
+    ADDOP_N(c, LOAD_CONST, level, consts);
+
+    names = PyTuple_New(n);
+    if (!names)
+        return 0;
 
     /* build up the names */
     for (i = 0; i < n; i++) {
@@ -1992,16 +1999,12 @@ compiler_from_import(struct compiler *c, stmt_ty s)
 
     if (s->lineno > c->c_future->ff_lineno && s->v.ImportFrom.module &&
         !strcmp(PyString_AS_STRING(s->v.ImportFrom.module), "__future__")) {
-        Py_DECREF(level);
         Py_DECREF(names);
         return compiler_error(c, "from __future__ imports must occur "
                               "at the beginning of the file");
     }
+    ADDOP_N(c, LOAD_CONST, names, consts);
 
-    ADDOP_O(c, LOAD_CONST, level, consts);
-    Py_DECREF(level);
-    ADDOP_O(c, LOAD_CONST, names, consts);
-    Py_DECREF(names);
     if (s->v.ImportFrom.module) {
         ADDOP_NAME(c, IMPORT_NAME, s->v.ImportFrom.module, names);
     }
@@ -2024,7 +2027,6 @@ compiler_from_import(struct compiler *c, stmt_ty s)
             store_name = alias->asname;
 
         if (!compiler_nameop(c, store_name, Store)) {
-            Py_DECREF(names);
             return 0;
         }
     }
@@ -2391,8 +2393,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
                             "param invalid for local variable");
             return 0;
         }
-        ADDOP_O(c, op, mangled, varnames);
-        Py_DECREF(mangled);
+        ADDOP_N(c, op, mangled, varnames);
         return 1;
     case OP_GLOBAL:
         switch (ctx) {
index 0f441deb84d0b22af5a48dbf60c97cad6e9ff292..9d9c33ac2de6d43f4ac3f2523fae1bb275a75019 100644 (file)
@@ -24,5 +24,5 @@
 const char *
 Py_GetCompiler(void)
 {
-       return COMPILER;
+    return COMPILER;
 }
index c37f8fa81cbe2a1d3062dce6a45959e4842d462a..1b69012fbc1795c666a136c5e39b46b2a5dcd605 100644 (file)
@@ -4,7 +4,7 @@
 
 static char cprt[] = 
 "\
-Copyright (c) 2001-2017 Python Software Foundation.\n\
+Copyright (c) 2001-2018 Python Software Foundation.\n\
 All Rights Reserved.\n\
 \n\
 Copyright (c) 2000 BeOpen.com.\n\
index e1a84d0bf7175cca0bfe3d706bd7997fbf271517..f55599bdb089a4ec5f58bb9cfcbe1fc364aa3227 100644 (file)
@@ -465,6 +465,9 @@ PyMarshal_WriteLongToFile(long x, FILE *fp, int version)
 {
     WFILE wf;
     wf.fp = fp;
+    wf.str = NULL;
+    wf.ptr = NULL;
+    wf.end = NULL;
     wf.error = WFERR_OK;
     wf.depth = 0;
     wf.strings = NULL;
@@ -477,6 +480,9 @@ PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp, int version)
 {
     WFILE wf;
     wf.fp = fp;
+    wf.str = NULL;
+    wf.ptr = NULL;
+    wf.end = NULL;
     wf.error = WFERR_OK;
     wf.depth = 0;
     wf.strings = (version > 0) ? PyDict_New() : NULL;
index eb992c17801de094e7b0b1f294e5c59899cf9e44..f33f18202360f579d155feb4a26d6c454cffbbe5 100644 (file)
@@ -588,6 +588,8 @@ PyGILState_Ensure(void)
 {
     int current;
     PyThreadState *tcur;
+    int need_init_threads = 0;
+
     /* Note that we do not auto-init Python here - apart from
        potential races with 2 threads auto-initializing, pep-311
        spells out other issues.  Embedders are expected to have
@@ -596,6 +598,8 @@ PyGILState_Ensure(void)
     assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */
     tcur = (PyThreadState *)PyThread_get_key_value(autoTLSkey);
     if (tcur == NULL) {
+        need_init_threads = 1;
+
         /* Create a new thread state for this thread */
         tcur = PyThreadState_New(autoInterpreterState);
         if (tcur == NULL)
@@ -605,16 +609,28 @@ PyGILState_Ensure(void)
         tcur->gilstate_counter = 0;
         current = 0; /* new thread state is never current */
     }
-    else
+    else {
         current = PyThreadState_IsCurrent(tcur);
-    if (current == 0)
+    }
+
+    if (current == 0) {
         PyEval_RestoreThread(tcur);
+    }
+
     /* Update our counter in the thread-state - no need for locks:
        - tcur will remain valid as we hold the GIL.
        - the counter is safe as we are the only thread "allowed"
          to modify this value
     */
     ++tcur->gilstate_counter;
+
+    if (need_init_threads) {
+        /* At startup, Python has no concrete GIL. If PyGILState_Ensure() is
+           called from a new thread for the first time, we need the create the
+           GIL. */
+        PyEval_InitThreads();
+    }
+
     return current ? PyGILState_LOCKED : PyGILState_UNLOCKED;
 }
 
index 2ffecc722dc317f91147d6f4f39bed5ff6e74225..44fe13d2f7d559eda2d49891f9366761d2169b9f 100644 (file)
 #include "windows.h"
 #endif
 
-#ifndef Py_REF_DEBUG
-#define PRINT_TOTAL_REFS()
-#else /* Py_REF_DEBUG */
-#define PRINT_TOTAL_REFS() fprintf(stderr,                              \
-                   "[%" PY_FORMAT_SIZE_T "d refs]\n",                   \
-                   _Py_GetRefTotal())
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -104,6 +96,21 @@ PyModule_GetWarningsModule(void)
     return PyImport_ImportModule("warnings");
 }
 
+static void
+_PyDebug_PrintTotalRefs(void)
+{
+#ifdef Py_REF_DEBUG
+    Py_ssize_t total;
+
+    if (!Py_GETENV("PYTHONSHOWREFCOUNT")) {
+        return;
+    }
+
+    total = _Py_GetRefTotal();
+    fprintf(stderr, "[%" PY_FORMAT_SIZE_T "d refs]\n", total);
+#endif
+}
+
 static int initialized = 0;
 
 /* API to access the initialized flag -- useful for esoteric use */
@@ -481,10 +488,12 @@ Py_Finalize(void)
 
     /* Debugging stuff */
 #ifdef COUNT_ALLOCS
-    dump_counts(stdout);
+    if (Py_GETENV("PYTHONSHOWALLOCCOUNT")) {
+        dump_counts(stderr);
+    }
 #endif
 
-    PRINT_TOTAL_REFS();
+    _PyDebug_PrintTotalRefs();
 
 #ifdef Py_TRACE_REFS
     /* Display all objects still alive -- this can invoke arbitrary
@@ -775,7 +784,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
     }
     for (;;) {
         ret = PyRun_InteractiveOneFlags(fp, filename, flags);
-        PRINT_TOTAL_REFS();
+        _PyDebug_PrintTotalRefs();
         if (ret == E_EOF)
             return 0;
         /*
index 3b4247b4153efd162bcb5223946c3e4eec350627..21790b1cd1877cd93128b78d95cd94954c9444b8 100644 (file)
@@ -162,12 +162,14 @@ PyTypeObject PySTEntry_Type = {
 };
 
 static int symtable_analyze(struct symtable *st);
-static int symtable_warn(struct symtable *st, char *msg, int lineno);
+static int symtable_warn(struct symtable *st,
+                         PyObject *warn, const char *msg, int lineno);
 static int symtable_enter_block(struct symtable *st, identifier name,
                                 _Py_block_ty block, void *ast, int lineno);
 static int symtable_exit_block(struct symtable *st, void *ast);
 static int symtable_visit_stmt(struct symtable *st, stmt_ty s);
 static int symtable_visit_expr(struct symtable *st, expr_ty s);
+static int symtable_visit_listcomp(struct symtable *st, expr_ty e);
 static int symtable_visit_genexp(struct symtable *st, expr_ty s);
 static int symtable_visit_setcomp(struct symtable *st, expr_ty e);
 static int symtable_visit_dictcomp(struct symtable *st, expr_ty e);
@@ -796,14 +798,18 @@ symtable_analyze(struct symtable *st)
 
 
 static int
-symtable_warn(struct symtable *st, char *msg, int lineno)
+symtable_warn(struct symtable *st, PyObject *warn, const char *msg, int lineno)
 {
-    if (PyErr_WarnExplicit(PyExc_SyntaxWarning, msg, st->st_filename,
-                           lineno, NULL, NULL) < 0)     {
-        if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) {
+    if (lineno < 0) {
+        lineno = st->st_cur->ste_lineno;
+    }
+    if (PyErr_WarnExplicit(warn, msg, st->st_filename, lineno, NULL, NULL) < 0) {
+        if (PyErr_ExceptionMatches(warn)) {
+            /* Replace the warning exception with a SyntaxError
+               to get a more accurate error report */
+            PyErr_Clear();
             PyErr_SetString(PyExc_SyntaxError, msg);
-            PyErr_SyntaxLocation(st->st_filename,
-                                 st->st_cur->ste_lineno);
+            PyErr_SyntaxLocation(st->st_filename, lineno);
         }
         return 0;
     }
@@ -1153,7 +1159,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
                     PyOS_snprintf(buf, sizeof(buf),
                                   GLOBAL_AFTER_USE,
                                   c_name);
-                if (!symtable_warn(st, buf, s->lineno))
+                if (!symtable_warn(st, PyExc_SyntaxWarning, buf, s->lineno))
                     return 0;
             }
             if (!symtable_add_def(st, name, DEF_GLOBAL))
@@ -1221,8 +1227,8 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
         VISIT_SEQ(st, expr, e->v.Set.elts);
         break;
     case ListComp_kind:
-        VISIT(st, expr, e->v.ListComp.elt);
-        VISIT_SEQ(st, comprehension, e->v.ListComp.generators);
+        if (!symtable_visit_listcomp(st, e))
+            return 0;
         break;
     case GeneratorExp_kind:
         if (!symtable_visit_genexp(st, e))
@@ -1420,12 +1426,11 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
         return r;
     }
     else {
-        if (st->st_cur->ste_type != ModuleBlock) {
-            int lineno = st->st_cur->ste_lineno;
-            if (!symtable_warn(st, IMPORT_STAR_WARNING, lineno)) {
-                Py_DECREF(store_name);
-                return 0;
-            }
+        if (st->st_cur->ste_type != ModuleBlock &&
+            !symtable_warn(st, PyExc_SyntaxWarning, IMPORT_STAR_WARNING, -1))
+        {
+            Py_DECREF(store_name);
+            return 0;
         }
         st->st_cur->ste_unoptimized |= OPT_IMPORT_STAR;
         Py_DECREF(store_name);
@@ -1509,7 +1514,10 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e,
         !symtable_enter_block(st, scope_name, FunctionBlock, (void *)e, 0)) {
         return 0;
     }
-    st->st_cur->ste_generator = is_generator;
+    /* In order to check for yield expressions under '-3', we clear
+       the generator flag, and restore it at the end */
+    is_generator |= st->st_cur->ste_generator;
+    st->st_cur->ste_generator = 0;
     /* Outermost iter is received as an argument */
     if (!symtable_implicit_arg(st, 0)) {
         symtable_exit_block(st, (void *)e);
@@ -1527,9 +1535,55 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e,
     if (value)
         VISIT_IN_BLOCK(st, expr, value, (void*)e);
     VISIT_IN_BLOCK(st, expr, elt, (void*)e);
+    if (Py_Py3kWarningFlag && st->st_cur->ste_generator) {
+        const char *msg = (
+            (e->kind == SetComp_kind) ? "'yield' inside set comprehension" :
+            (e->kind == DictComp_kind) ? "'yield' inside dict comprehension" :
+            "'yield' inside generator expression");
+        if (!symtable_warn(st, PyExc_DeprecationWarning, msg, -1)) {
+            symtable_exit_block(st, (void *)e);
+            return 0;
+        }
+    }
+    st->st_cur->ste_generator |= is_generator;
     return symtable_exit_block(st, (void *)e);
 }
 
+static int
+symtable_visit_listcomp(struct symtable *st, expr_ty e)
+{
+    asdl_seq *generators = e->v.ListComp.generators;
+    int i, is_generator;
+    /* In order to check for yield expressions under '-3', we clear
+       the generator flag, and restore it at the end */
+    is_generator = st->st_cur->ste_generator;
+    st->st_cur->ste_generator = 0;
+    VISIT(st, expr, e->v.ListComp.elt);
+    for (i = 0; i < asdl_seq_LEN(generators); i++) {
+        comprehension_ty lc = (comprehension_ty)asdl_seq_GET(generators, i);
+        VISIT(st, expr, lc->target);
+        if (i == 0 && !st->st_cur->ste_generator) {
+            /* 'yield' in the outermost iterator doesn't cause a warning */
+            VISIT(st, expr, lc->iter);
+            is_generator |= st->st_cur->ste_generator;
+            st->st_cur->ste_generator = 0;
+        }
+        else {
+            VISIT(st, expr, lc->iter);
+        }
+        VISIT_SEQ(st, expr, lc->ifs);
+    }
+
+    if (Py_Py3kWarningFlag && st->st_cur->ste_generator) {
+        const char *msg = "'yield' inside list comprehension";
+        if (!symtable_warn(st, PyExc_DeprecationWarning, msg, -1)) {
+            return 0;
+        }
+    }
+    st->st_cur->ste_generator |= is_generator;
+    return 1;
+}
+
 static int
 symtable_visit_genexp(struct symtable *st, expr_ty e)
 {
diff --git a/README b/README
index 00a6b3946550aa8cacfc35310f72b9dc47f0a6dd..8a8883631f30adfe8acbe5ec0e965b647a7bd2e3 100644 (file)
--- a/README
+++ b/README
@@ -1,8 +1,8 @@
-This is Python version 2.7.14
+This is Python version 2.7.15
 =============================
 
 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
-2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation.  All rights
+2012, 2013, 2014, 2015, 2016, 2017, 2018 Python Software Foundation.  All rights
 reserved.
 
 Copyright (c) 2000 BeOpen.com.
index a62d2fe441f8bf8116a08da390c71c79a7710fad..ddd750ed44d6df62943e4c0d82de289dc2a06ad9 100755 (executable)
@@ -261,25 +261,6 @@ def containsAny(str, set):
     return 1 in [c in str for c in set]
 
 
-def _visit_pyfiles(list, dirname, names):
-    """Helper for getFilesForName()."""
-    # get extension for python source files
-    if not globals().has_key('_py_ext'):
-        global _py_ext
-        _py_ext = [triple[0] for triple in imp.get_suffixes()
-                   if triple[2] == imp.PY_SOURCE][0]
-
-    # don't recurse into CVS directories
-    if 'CVS' in names:
-        names.remove('CVS')
-
-    # add all *.py files to list
-    list.extend(
-        [os.path.join(dirname, file) for file in names
-         if os.path.splitext(file)[1] == _py_ext]
-        )
-
-
 def _get_modpkg_path(dotted_name, pathlist=None):
     """Get the filesystem path for a module or a package.
 
@@ -340,7 +321,20 @@ def getFilesForName(name):
     if os.path.isdir(name):
         # find all python files in directory
         list = []
-        os.path.walk(name, _visit_pyfiles, list)
+        # get extension for python source files
+        if '_py_ext' not in globals():
+            global _py_ext
+            _py_ext = [triple[0] for triple in imp.get_suffixes()
+                       if triple[2] == imp.PY_SOURCE][0]
+        for root, dirs, files in os.walk(name):
+            # don't recurse into CVS directories
+            if 'CVS' in dirs:
+                dirs.remove('CVS')
+            # add all *.py files to list
+            list.extend(
+                [os.path.join(root, file) for file in files
+                 if os.path.splitext(file)[1] == _py_ext]
+                )
         return list
     elif os.path.exists(name):
         # a single file
index 3c953f727d6a901e419be56537778c340dd999d0..96e29d1fb9ff64f21cb5682d1674d76806a38e62 100644 (file)
@@ -21,6 +21,8 @@ if "%~1" EQU "-p" (set PACKAGES=%PACKAGES% %~2) && shift && shift && goto CheckO
 if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)\r
 \r
 if not defined NUGET where nuget -q || echo Cannot find nuget.exe on PATH and NUGET is not set. && exit /B 1\r
+call "%PCBUILD%find_msbuild.bat" %MSBUILD%\r
+if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)\r
 if not defined PYTHON set PYTHON=py -3\r
 \r
 @%PYTHON% -c "" >nul 2>nul\r
@@ -29,7 +31,6 @@ if not defined PYTHON set PYTHON=py -3
     set PYTHON="%D%obj\python\tools\python.exe"\r
 )\r
 \r
-call "%PCBUILD%env.bat" x86\r
 \r
 if defined PACKAGES set PACKAGES="/p:Packages=%PACKAGES%"\r
 \r
@@ -38,7 +39,7 @@ if defined BUILDX86 (
     ) else if not exist "%PCBUILD%python.exe" call "%PCBUILD%build.bat" -e\r
     if errorlevel 1 goto :eof\r
 \r
-    msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES%\r
+    %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES%\r
     if errorlevel 1 goto :eof\r
 )\r
 \r
@@ -47,7 +48,7 @@ if defined BUILDX64 (
     ) else if not exist "%PCBUILD%amd64\python.exe" call "%PCBUILD%build.bat" -p x64 -e\r
     if errorlevel 1 goto :eof\r
 \r
-    msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES%\r
+    %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES%\r
     if errorlevel 1 goto :eof\r
 )\r
 \r
index 8eeee71c50f90a4b264c610e262f20478fd1f2b6..aa6c624f483aca0d86d3b2f0749a4e11f17fb584 100644 (file)
@@ -14,6 +14,7 @@
 \r
     <PropertyGroup>\r
         <NuspecVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</NuspecVersion>\r
+        <NuspecVersion Condition="$(ReleaseLevelName) != ''">$(NuspecVersion)-$(ReleaseLevelName)</NuspecVersion>\r
         <SignOutput>false</SignOutput>\r
         <TargetName>$(OutputName).$(NuspecVersion)</TargetName>\r
         <TargetExt>.nupkg</TargetExt>\r
index df15edbc8d6502b7a6aedc94b8aff766c60d06d3..540901ba7d7092224629497cbd0681a32ffba5f1 100755 (executable)
@@ -109,7 +109,7 @@ def check(file):
     if verbose:
         print "checking", file, "...",
     try:
-        f = io.open(file)
+        f = open(file, "rb")
     except IOError, msg:
         errprint("%s: I/O Error: %s" % (file, str(msg)))
         return
@@ -133,7 +133,7 @@ def check(file):
                 shutil.copyfile(file, bak)
                 if verbose:
                     print "backed up", file, "to", bak
-            f = io.open(file, "w", newline=newline)
+            f = open(file, "wb")
             r.write(f)
             f.close()
             if verbose:
@@ -144,7 +144,21 @@ def check(file):
             print "unchanged."
         return False
 
-def _rstrip(line, JUNK='\n \t'):
+def _detect_newlines(lines):
+    newlines = {'\r\n' if line[-2:] == '\r\n' else
+                '\n' if line[-1:] == '\n' else
+                '\r' if line[-1:] == '\r' else
+                ''
+                for line in lines}
+    newlines.discard('')
+    newlines = tuple(sorted(newlines))
+    if not newlines:
+        return '\n'
+    if len(newlines) == 1:
+        return newlines[0]
+    return newlines
+
+def _rstrip(line, JUNK='\r\n \t'):
     """Return line stripped of trailing spaces, tabs, newlines.
 
     Note that line.rstrip() instead also strips sundry control characters,
@@ -166,10 +180,18 @@ class Reindenter:
         # Raw file lines.
         self.raw = f.readlines()
 
+        # Save the newlines found in the file so they can be used to
+        #  create output without mutating the newlines.
+        self.newlines = _detect_newlines(self.raw)
+        if isinstance(self.newlines, tuple):
+            self.newline = self.newlines[0]
+        else:
+            self.newline = self.newlines
+
         # File lines, rstripped & tab-expanded.  Dummy at start is so
         # that we can use tokenize's 1-based line numbering easily.
-        # Note that a line is all-blank iff it's "\n".
-        self.lines = [_rstrip(line).expandtabs() + "\n"
+        # Note that a line is all-blank iff it's newline.
+        self.lines = [_rstrip(line).expandtabs() + self.newline
                       for line in self.raw]
         self.lines.insert(0, None)
         self.index = 1  # index into self.lines of next line
@@ -180,15 +202,11 @@ class Reindenter:
         # indeed, they're our headache!
         self.stats = []
 
-        # Save the newlines found in the file so they can be used to
-        #  create output without mutating the newlines.
-        self.newlines = f.newlines
-
     def run(self):
         tokenize.tokenize(self.getline, self.tokeneater)
         # Remove trailing empty lines.
         lines = self.lines
-        while lines and lines[-1] == "\n":
+        while lines and lines[-1] == self.newline:
             lines.pop()
         # Sentinel.
         stats = self.stats
@@ -244,7 +262,7 @@ class Reindenter:
             else:
                 for line in lines[thisstmt:nextstmt]:
                     if diff > 0:
-                        if line == "\n":
+                        if line == self.newline:
                             after.append(line)
                         else:
                             after.append(" " * diff + line)
diff --git a/Tools/ssl/multissltests.py b/Tools/ssl/multissltests.py
new file mode 100755 (executable)
index 0000000..ffc57f0
--- /dev/null
@@ -0,0 +1,431 @@
+#!./python
+"""Run Python tests against multiple installations of OpenSSL and LibreSSL
+
+The script
+
+  (1) downloads OpenSSL / LibreSSL tar bundle
+  (2) extracts it to ./src
+  (3) compiles OpenSSL / LibreSSL
+  (4) installs OpenSSL / LibreSSL into ../multissl/$LIB/$VERSION/
+  (5) forces a recompilation of Python modules using the
+      header and library files from ../multissl/$LIB/$VERSION/
+  (6) runs Python's test suite
+
+The script must be run with Python's build directory as current working
+directory.
+
+The script uses LD_RUN_PATH, LD_LIBRARY_PATH, CPPFLAGS and LDFLAGS to bend
+search paths for header files and shared libraries. It's known to work on
+Linux with GCC and clang.
+
+Please keep this script compatible with Python 2.7, and 3.4 to 3.7.
+
+(c) 2013-2017 Christian Heimes <christian@python.org>
+"""
+from __future__ import print_function
+
+import argparse
+from datetime import datetime
+import logging
+import os
+try:
+    from urllib.request import urlopen
+except ImportError:
+    from urllib2 import urlopen
+import subprocess
+import shutil
+import sys
+import tarfile
+
+
+log = logging.getLogger("multissl")
+
+OPENSSL_OLD_VERSIONS = [
+     "0.9.8zc",
+     "0.9.8zh",
+     "1.0.1u",
+]
+
+OPENSSL_RECENT_VERSIONS = [
+     "1.0.2",
+     "1.0.2l",
+     "1.1.0f",
+]
+
+LIBRESSL_OLD_VERSIONS = [
+    "2.3.10",
+    "2.4.5",
+]
+
+LIBRESSL_RECENT_VERSIONS = [
+    "2.5.5",
+    "2.6.4",
+    "2.7.1",
+]
+
+# store files in ../multissl
+HERE = os.path.abspath(os.getcwd())
+MULTISSL_DIR = os.path.abspath(os.path.join(HERE, '..', 'multissl'))
+
+parser = argparse.ArgumentParser(
+    prog='multissl',
+    description=(
+        "Run CPython tests with multiple OpenSSL and LibreSSL "
+        "versions."
+    )
+)
+parser.add_argument(
+    '--debug',
+    action='store_true',
+    help="Enable debug mode",
+)
+parser.add_argument(
+    '--disable-ancient',
+    action='store_true',
+    help="Don't test OpenSSL < 1.0.2 and LibreSSL < 2.5.3.",
+)
+parser.add_argument(
+    '--openssl',
+    nargs='+',
+    default=(),
+    help=(
+        "OpenSSL versions, defaults to '{}' (ancient: '{}') if no "
+        "OpenSSL and LibreSSL versions are given."
+    ).format(OPENSSL_RECENT_VERSIONS, OPENSSL_OLD_VERSIONS)
+)
+parser.add_argument(
+    '--libressl',
+    nargs='+',
+    default=(),
+    help=(
+        "LibreSSL versions, defaults to '{}' (ancient: '{}') if no "
+        "OpenSSL and LibreSSL versions are given."
+    ).format(LIBRESSL_RECENT_VERSIONS, LIBRESSL_OLD_VERSIONS)
+)
+parser.add_argument(
+    '--tests',
+    nargs='*',
+    default=(),
+    help="Python tests to run, defaults to all SSL related tests.",
+)
+parser.add_argument(
+    '--base-directory',
+    default=MULTISSL_DIR,
+    help="Base directory for OpenSSL / LibreSSL sources and builds."
+)
+parser.add_argument(
+    '--no-network',
+    action='store_false',
+    dest='network',
+    help="Disable network tests."
+)
+parser.add_argument(
+    '--compile-only',
+    action='store_true',
+    help="Don't run tests, only compile _ssl.c and _hashopenssl.c."
+)
+
+
+class AbstractBuilder(object):
+    library = None
+    url_template = None
+    src_template = None
+    build_template = None
+
+    module_files = ("Modules/_ssl.c",
+                    "Modules/_hashopenssl.c")
+    module_libs = ("_ssl", "_hashlib")
+
+    def __init__(self, version, compile_args=(),
+                 basedir=MULTISSL_DIR):
+        self.version = version
+        self.compile_args = compile_args
+        # installation directory
+        self.install_dir = os.path.join(
+            os.path.join(basedir, self.library.lower()), version
+        )
+        # source file
+        self.src_dir = os.path.join(basedir, 'src')
+        self.src_file = os.path.join(
+            self.src_dir, self.src_template.format(version))
+        # build directory (removed after install)
+        self.build_dir = os.path.join(
+            self.src_dir, self.build_template.format(version))
+
+    def __str__(self):
+        return "<{0.__class__.__name__} for {0.version}>".format(self)
+
+    def __eq__(self, other):
+        if not isinstance(other, AbstractBuilder):
+            return NotImplemented
+        return (
+            self.library == other.library
+            and self.version == other.version
+        )
+
+    def __hash__(self):
+        return hash((self.library, self.version))
+
+    @property
+    def openssl_cli(self):
+        """openssl CLI binary"""
+        return os.path.join(self.install_dir, "bin", "openssl")
+
+    @property
+    def openssl_version(self):
+        """output of 'bin/openssl version'"""
+        cmd = [self.openssl_cli, "version"]
+        return self._subprocess_output(cmd)
+
+    @property
+    def pyssl_version(self):
+        """Value of ssl.OPENSSL_VERSION"""
+        cmd = [
+            sys.executable,
+            '-c', 'import ssl; print(ssl.OPENSSL_VERSION)'
+        ]
+        return self._subprocess_output(cmd)
+
+    @property
+    def include_dir(self):
+        return os.path.join(self.install_dir, "include")
+
+    @property
+    def lib_dir(self):
+        return os.path.join(self.install_dir, "lib")
+
+    @property
+    def has_openssl(self):
+        return os.path.isfile(self.openssl_cli)
+
+    @property
+    def has_src(self):
+        return os.path.isfile(self.src_file)
+
+    def _subprocess_call(self, cmd, env=None, **kwargs):
+        log.debug("Call '{}'".format(" ".join(cmd)))
+        return subprocess.check_call(cmd, env=env, **kwargs)
+
+    def _subprocess_output(self, cmd, env=None, **kwargs):
+        log.debug("Call '{}'".format(" ".join(cmd)))
+        if env is None:
+            env = os.environ.copy()
+            env["LD_LIBRARY_PATH"] = self.lib_dir
+        out = subprocess.check_output(cmd, env=env, **kwargs)
+        return out.strip().decode("utf-8")
+
+    def _download_src(self):
+        """Download sources"""
+        src_dir = os.path.dirname(self.src_file)
+        if not os.path.isdir(src_dir):
+            os.makedirs(src_dir)
+        url = self.url_template.format(self.version)
+        log.info("Downloading from {}".format(url))
+        req = urlopen(url)
+        # KISS, read all, write all
+        data = req.read()
+        log.info("Storing {}".format(self.src_file))
+        with open(self.src_file, "wb") as f:
+            f.write(data)
+
+    def _unpack_src(self):
+        """Unpack tar.gz bundle"""
+        # cleanup
+        if os.path.isdir(self.build_dir):
+            shutil.rmtree(self.build_dir)
+        os.makedirs(self.build_dir)
+
+        tf = tarfile.open(self.src_file)
+        name = self.build_template.format(self.version)
+        base = name + '/'
+        # force extraction into build dir
+        members = tf.getmembers()
+        for member in list(members):
+            if member.name == name:
+                members.remove(member)
+            elif not member.name.startswith(base):
+                raise ValueError(member.name, base)
+            member.name = member.name[len(base):].lstrip('/')
+        log.info("Unpacking files to {}".format(self.build_dir))
+        tf.extractall(self.build_dir, members)
+
+    def _build_src(self):
+        """Now build openssl"""
+        log.info("Running build in {}".format(self.build_dir))
+        cwd = self.build_dir
+        cmd = ["./config", "shared", "--prefix={}".format(self.install_dir)]
+        cmd.extend(self.compile_args)
+        self._subprocess_call(cmd, cwd=cwd)
+        # Old OpenSSL versions do not support parallel builds.
+        self._subprocess_call(["make", "-j1"], cwd=cwd)
+
+    def _make_install(self, remove=True):
+        self._subprocess_call(["make", "-j1", "install"], cwd=self.build_dir)
+        if remove:
+            shutil.rmtree(self.build_dir)
+
+    def install(self):
+        log.info(self.openssl_cli)
+        if not self.has_openssl:
+            if not self.has_src:
+                self._download_src()
+            else:
+                log.debug("Already has src {}".format(self.src_file))
+            self._unpack_src()
+            self._build_src()
+            self._make_install()
+        else:
+            log.info("Already has installation {}".format(self.install_dir))
+        # validate installation
+        version = self.openssl_version
+        if self.version not in version:
+            raise ValueError(version)
+
+    def recompile_pymods(self):
+        log.warning("Using build from {}".format(self.build_dir))
+        # force a rebuild of all modules that use OpenSSL APIs
+        for fname in self.module_files:
+            os.utime(fname, None)
+        # remove all build artefacts
+        for root, dirs, files in os.walk('build'):
+            for filename in files:
+                if filename.startswith(self.module_libs):
+                    os.unlink(os.path.join(root, filename))
+
+        # overwrite header and library search paths
+        env = os.environ.copy()
+        env["CPPFLAGS"] = "-I{}".format(self.include_dir)
+        env["LDFLAGS"] = "-L{}".format(self.lib_dir)
+        # set rpath
+        env["LD_RUN_PATH"] = self.lib_dir
+
+        log.info("Rebuilding Python modules")
+        cmd = [sys.executable, "setup.py", "build"]
+        self._subprocess_call(cmd, env=env)
+        self.check_imports()
+
+    def check_imports(self):
+        cmd = [sys.executable, "-c", "import _ssl; import _hashlib"]
+        self._subprocess_call(cmd)
+
+    def check_pyssl(self):
+        version = self.pyssl_version
+        if self.version not in version:
+            raise ValueError(version)
+
+    def run_python_tests(self, tests, network=True):
+        if not tests:
+            cmd = [sys.executable, 'Lib/test/ssltests.py', '-j0']
+        elif sys.version_info < (3, 3):
+            cmd = [sys.executable, '-m', 'test.regrtest']
+        else:
+            cmd = [sys.executable, '-m', 'test', '-j0']
+        if network:
+            cmd.extend(['-u', 'network', '-u', 'urlfetch'])
+        cmd.extend(['-w', '-r'])
+        cmd.extend(tests)
+        self._subprocess_call(cmd, stdout=None)
+
+
+class BuildOpenSSL(AbstractBuilder):
+    library = "OpenSSL"
+    url_template = "https://www.openssl.org/source/openssl-{}.tar.gz"
+    src_template = "openssl-{}.tar.gz"
+    build_template = "openssl-{}"
+
+
+class BuildLibreSSL(AbstractBuilder):
+    library = "LibreSSL"
+    url_template = (
+        "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-{}.tar.gz")
+    src_template = "libressl-{}.tar.gz"
+    build_template = "libressl-{}"
+
+
+def configure_make():
+    if not os.path.isfile('Makefile'):
+        log.info('Running ./configure')
+        subprocess.check_call([
+            './configure', '--config-cache', '--quiet',
+            '--with-pydebug'
+        ])
+
+    log.info('Running make')
+    subprocess.check_call(['make', '--quiet'])
+
+
+def main():
+    args = parser.parse_args()
+    if not args.openssl and not args.libressl:
+        args.openssl = list(OPENSSL_RECENT_VERSIONS)
+        args.libressl = list(LIBRESSL_RECENT_VERSIONS)
+        if not args.disable_ancient:
+            args.openssl.extend(OPENSSL_OLD_VERSIONS)
+            args.libressl.extend(LIBRESSL_OLD_VERSIONS)
+
+    logging.basicConfig(
+        level=logging.DEBUG if args.debug else logging.INFO,
+        format="*** %(levelname)s %(message)s"
+    )
+
+    start = datetime.now()
+
+    for name in ['python', 'setup.py', 'Modules/_ssl.c']:
+        if not os.path.isfile(name):
+            parser.error(
+                "Must be executed from CPython build dir"
+            )
+    if not os.path.samefile('python', sys.executable):
+        parser.error(
+            "Must be executed with ./python from CPython build dir"
+        )
+
+    # check for configure and run make
+    configure_make()
+
+    # download and register builder
+    builds = []
+
+    for version in args.openssl:
+        build = BuildOpenSSL(version)
+        build.install()
+        builds.append(build)
+
+    for version in args.libressl:
+        build = BuildLibreSSL(version)
+        build.install()
+        builds.append(build)
+
+    for build in builds:
+        try:
+            build.recompile_pymods()
+            build.check_pyssl()
+            if not args.compile_only:
+                build.run_python_tests(
+                    tests=args.tests,
+                    network=args.network,
+                )
+        except Exception as e:
+            log.exception("%s failed", build)
+            print("{} failed: {}".format(build, e), file=sys.stderr)
+            sys.exit(2)
+
+    print("\n{} finished in {}".format(
+        "Tests" if not args.compile_only else "Builds",
+        datetime.now() - start
+    ))
+    print('Python: ', sys.version)
+    if args.compile_only:
+        print('Build only')
+    elif args.tests:
+        print('Executed Tests:', ' '.join(args.tests))
+    else:
+        print('Executed all SSL tests.')
+
+    print('OpenSSL / LibreSSL versions:')
+    for build in builds:
+        print("    * {0.library} {0.version}".format(build))
+
+
+if __name__ == "__main__":
+    main()
diff --git a/Tools/ssl/test_multiple_versions.py b/Tools/ssl/test_multiple_versions.py
deleted file mode 100644 (file)
index fc7a967..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-#./python
-"""Run Python tests with multiple installations of OpenSSL
-
-The script
-
-  (1) downloads OpenSSL tar bundle
-  (2) extracts it to ../openssl/src/openssl-VERSION/
-  (3) compiles OpenSSL
-  (4) installs OpenSSL into ../openssl/VERSION/
-  (5) forces a recompilation of Python modules using the
-      header and library files from ../openssl/VERSION/
-  (6) runs Python's test suite
-
-The script must be run with Python's build directory as current working
-directory:
-
-    ./python Tools/ssl/test_multiple_versions.py
-
-The script uses LD_RUN_PATH, LD_LIBRARY_PATH, CPPFLAGS and LDFLAGS to bend
-search paths for header files and shared libraries. It's known to work on
-Linux with GCC 4.x.
-
-(c) 2013 Christian Heimes <christian@python.org>
-"""
-import logging
-import os
-import tarfile
-import shutil
-import subprocess
-import sys
-from urllib import urlopen
-
-log = logging.getLogger("multissl")
-
-OPENSSL_VERSIONS = [
-    "0.9.7m", "0.9.8i", "0.9.8l", "0.9.8m", "0.9.8y", "1.0.0k", "1.0.1e"
-]
-FULL_TESTS = [
-    "test_asyncio", "test_ftplib", "test_hashlib", "test_httplib",
-    "test_imaplib", "test_nntplib", "test_poplib", "test_smtplib",
-    "test_smtpnet", "test_urllib2_localnet", "test_venv"
-]
-MINIMAL_TESTS = ["test_ssl", "test_hashlib"]
-CADEFAULT = True
-HERE = os.path.abspath(os.getcwd())
-DEST_DIR = os.path.abspath(os.path.join(HERE, os.pardir, "openssl"))
-
-
-class BuildSSL(object):
-    url_template = "https://www.openssl.org/source/openssl-{}.tar.gz"
-
-    module_files = ["Modules/_ssl.c",
-                    "Modules/socketmodule.c",
-                    "Modules/_hashopenssl.c"]
-
-    def __init__(self, version, openssl_compile_args=(), destdir=DEST_DIR):
-        self._check_python_builddir()
-        self.version = version
-        self.openssl_compile_args = openssl_compile_args
-        # installation directory
-        self.install_dir = os.path.join(destdir, version)
-        # source file
-        self.src_file = os.path.join(destdir, "src",
-                                     "openssl-{}.tar.gz".format(version))
-        # build directory (removed after install)
-        self.build_dir = os.path.join(destdir, "src",
-                                      "openssl-{}".format(version))
-
-    @property
-    def openssl_cli(self):
-        """openssl CLI binary"""
-        return os.path.join(self.install_dir, "bin", "openssl")
-
-    @property
-    def openssl_version(self):
-        """output of 'bin/openssl version'"""
-        env = os.environ.copy()
-        env["LD_LIBRARY_PATH"] = self.lib_dir
-        cmd = [self.openssl_cli, "version"]
-        return self._subprocess_output(cmd, env=env)
-
-    @property
-    def pyssl_version(self):
-        """Value of ssl.OPENSSL_VERSION"""
-        env = os.environ.copy()
-        env["LD_LIBRARY_PATH"] = self.lib_dir
-        cmd = ["./python", "-c", "import ssl; print(ssl.OPENSSL_VERSION)"]
-        return self._subprocess_output(cmd, env=env)
-
-    @property
-    def include_dir(self):
-        return os.path.join(self.install_dir, "include")
-
-    @property
-    def lib_dir(self):
-        return os.path.join(self.install_dir, "lib")
-
-    @property
-    def has_openssl(self):
-        return os.path.isfile(self.openssl_cli)
-
-    @property
-    def has_src(self):
-        return os.path.isfile(self.src_file)
-
-    def _subprocess_call(self, cmd, stdout=subprocess.DEVNULL, env=None,
-                         **kwargs):
-        log.debug("Call '{}'".format(" ".join(cmd)))
-        return subprocess.check_call(cmd, stdout=stdout, env=env, **kwargs)
-
-    def _subprocess_output(self, cmd, env=None, **kwargs):
-        log.debug("Call '{}'".format(" ".join(cmd)))
-        out = subprocess.check_output(cmd, env=env)
-        return out.strip().decode("utf-8")
-
-    def _check_python_builddir(self):
-        if not os.path.isfile("python") or not os.path.isfile("setup.py"):
-            raise ValueError("Script must be run in Python build directory")
-
-    def _download_openssl(self):
-        """Download OpenSSL source dist"""
-        src_dir = os.path.dirname(self.src_file)
-        if not os.path.isdir(src_dir):
-            os.makedirs(src_dir)
-        url = self.url_template.format(self.version)
-        log.info("Downloading OpenSSL from {}".format(url))
-        req = urlopen(url, cadefault=CADEFAULT)
-        # KISS, read all, write all
-        data = req.read()
-        log.info("Storing {}".format(self.src_file))
-        with open(self.src_file, "wb") as f:
-            f.write(data)
-
-    def _unpack_openssl(self):
-        """Unpack tar.gz bundle"""
-        # cleanup
-        if os.path.isdir(self.build_dir):
-            shutil.rmtree(self.build_dir)
-        os.makedirs(self.build_dir)
-
-        tf = tarfile.open(self.src_file)
-        base = "openssl-{}/".format(self.version)
-        # force extraction into build dir
-        members = tf.getmembers()
-        for member in members:
-            if not member.name.startswith(base):
-                raise ValueError(member.name)
-            member.name = member.name[len(base):]
-        log.info("Unpacking files to {}".format(self.build_dir))
-        tf.extractall(self.build_dir, members)
-
-    def _build_openssl(self):
-        """Now build openssl"""
-        log.info("Running build in {}".format(self.install_dir))
-        cwd = self.build_dir
-        cmd = ["./config", "shared", "--prefix={}".format(self.install_dir)]
-        cmd.extend(self.openssl_compile_args)
-        self._subprocess_call(cmd, cwd=cwd)
-        self._subprocess_call(["make"], cwd=cwd)
-
-    def _install_openssl(self, remove=True):
-        self._subprocess_call(["make", "install"], cwd=self.build_dir)
-        if remove:
-            shutil.rmtree(self.build_dir)
-
-    def install_openssl(self):
-        if not self.has_openssl:
-            if not self.has_src:
-                self._download_openssl()
-            else:
-                log.debug("Already has src {}".format(self.src_file))
-            self._unpack_openssl()
-            self._build_openssl()
-            self._install_openssl()
-        else:
-            log.info("Already has installation {}".format(self.install_dir))
-        # validate installation
-        version = self.openssl_version
-        if self.version not in version:
-            raise ValueError(version)
-
-    def touch_pymods(self):
-        # force a rebuild of all modules that use OpenSSL APIs
-        for fname in self.module_files:
-            os.utime(fname)
-
-    def recompile_pymods(self):
-        log.info("Using OpenSSL build from {}".format(self.build_dir))
-        # overwrite header and library search paths
-        env = os.environ.copy()
-        env["CPPFLAGS"] = "-I{}".format(self.include_dir)
-        env["LDFLAGS"] = "-L{}".format(self.lib_dir)
-        # set rpath
-        env["LD_RUN_PATH"] = self.lib_dir
-
-        log.info("Rebuilding Python modules")
-        self.touch_pymods()
-        cmd = ["./python", "setup.py", "build"]
-        self._subprocess_call(cmd, env=env)
-
-    def check_pyssl(self):
-        version = self.pyssl_version
-        if self.version not in version:
-            raise ValueError(version)
-
-    def run_pytests(self, *args):
-        cmd = ["./python", "-m", "test"]
-        cmd.extend(args)
-        self._subprocess_call(cmd, stdout=None)
-
-    def run_python_tests(self, *args):
-        self.recompile_pymods()
-        self.check_pyssl()
-        self.run_pytests(*args)
-
-
-def main(*args):
-    builders = []
-    for version in OPENSSL_VERSIONS:
-        if version in ("0.9.8i", "0.9.8l"):
-            openssl_compile_args = ("no-asm",)
-        else:
-            openssl_compile_args = ()
-        builder = BuildSSL(version, openssl_compile_args)
-        builder.install_openssl()
-        builders.append(builder)
-
-    for builder in builders:
-        builder.run_python_tests(*args)
-    # final touch
-    builder.touch_pymods()
-
-
-if __name__ == "__main__":
-    logging.basicConfig(level=logging.INFO,
-                        format="*** %(levelname)s %(message)s")
-    args = sys.argv[1:]
-    if not args:
-        args = ["-unetwork", "-v"]
-        args.extend(FULL_TESTS)
-    main(*args)
index 2a745e57466cae1af014f239e5b91a8fc1fd64d8..5fadcb1e44575ead0491bcbcf351fca7be54837b 100644 (file)
@@ -12,9 +12,9 @@
 # PARTICULAR PURPOSE.
 
 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
-dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
-dnl serial 11 (pkg-config-0.29.1)
-dnl
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
 dnl
@@ -288,3 +288,71 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
 AS_VAR_IF([$1], [""], [$5], [$4])dnl
 ])dnl PKG_CHECK_VAR
 
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+           [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+            [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+    [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+            [auto],[PKG_CHECK_MODULES([$1],[$2],
+                                        [m4_n([def_action_if_found]) $3],
+                                        [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl   [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
index 4c0435e98d249f81d083c814d71c0baabec44010..4a047e69bda1fee42887b327d1bee76ecee2a88f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1457,7 +1457,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-universalsdk[=SDKDIR]
-                          Build against Mac OS X 10.4u SDK (ppc/i386)
+                          Build fat binary against Mac OS X SDK
   --enable-framework[=INSTALLDIR]
                           Build (MacOSX|Darwin) framework
   --enable-shared         disable/enable building shared python library
@@ -1477,7 +1477,8 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-universal-archs=ARCH
                           select architectures for universal build ("32-bit",
-                          "64-bit", "3-way", "intel" or "all")
+                          "64-bit", "3-way", "intel", "intel-32", "intel-64",
+                          or "all")
   --with-framework-name=FRAMEWORK
                           specify an alternate name of the framework built
                           with --enable-framework
@@ -2963,7 +2964,7 @@ $as_echo_n "checking for python interpreter for cross build... " >&6; }
        fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
 $as_echo "$interp" >&6; }
-       PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$interp
+       PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
     fi
 elif test "$cross_compiling" = maybe; then
     as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5
@@ -3039,10 +3040,16 @@ if test "${enable_universalsdk+set}" = set; then :
   enableval=$enable_universalsdk;
        case $enableval in
        yes)
-               enableval=/Developer/SDKs/MacOSX10.4u.sdk
-               if test ! -d "${enableval}"
+               # Locate the best usable SDK, see Mac/README.txt for more
+               # information
+               enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
+               if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
                then
-                       enableval=/
+                       enableval=/Developer/SDKs/MacOSX10.4u.sdk
+                       if test ! -d "${enableval}"
+                       then
+                               enableval=/
+                       fi
                fi
                ;;
        esac
@@ -3081,7 +3088,20 @@ fi
 
 ARCH_RUN_32BIT=""
 
+# For backward compatibility reasons we prefer to select '32-bit' if available,
+# otherwise use 'intel'
 UNIVERSAL_ARCHS="32-bit"
+if test "`uname -s`" = "Darwin"
+then
+       if test -n "${UNIVERSALSDK}"
+       then
+               if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
+               then
+                       UNIVERSAL_ARCHS="intel"
+               fi
+       fi
+fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-universal-archs" >&5
 $as_echo_n "checking for --with-universal-archs... " >&6; }
@@ -3089,24 +3109,18 @@ $as_echo_n "checking for --with-universal-archs... " >&6; }
 # Check whether --with-universal-archs was given.
 if test "${with_universal_archs+set}" = set; then :
   withval=$with_universal_archs;
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5
-$as_echo "$withval" >&6; }
        UNIVERSAL_ARCHS="$withval"
-        if test "${enable_universalsdk}" ; then
-               :
-       else
-               as_fn_error $? "--with-universal-archs without --enable-universalsdk. See Mac/README" "$LINENO" 5
-       fi
-
-else
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: 32-bit" >&5
-$as_echo "32-bit" >&6; }
 
 fi
 
-
-
+if test -n "${UNIVERSALSDK}"
+then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${UNIVERSAL_ARCHS}" >&5
+$as_echo "${UNIVERSAL_ARCHS}" >&6; }
+else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
 # Check whether --with-framework-name was given.
@@ -6084,119 +6098,137 @@ $as_echo "$ac_cv_no_strict_aliasing_ok" >&6; }
        SCO_SV*)
            BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
            ;;
-       # is there any other compiler on Darwin besides gcc?
-       Darwin*)
-           # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
-           # used to be here, but non-Apple gcc doesn't accept them.
-           if test "${CC}" = gcc
-           then
-               { $as_echo "$as_me:${as_lineno-$LINENO}: checking which compiler should be used" >&5
+    # is there any other compiler on Darwin besides gcc?
+    Darwin*)
+        # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
+        # used to be here, but non-Apple gcc doesn't accept them.
+        if test "${CC}" = gcc
+        then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking which compiler should be used" >&5
 $as_echo_n "checking which compiler should be used... " >&6; }
-               case "${UNIVERSALSDK}" in
-               */MacOSX10.4u.sdk)
-                       # Build using 10.4 SDK, force usage of gcc when the
-                       # compiler is gcc, otherwise the user will get very
-                       # confusing error messages when building on OSX 10.6
-                       CC=gcc-4.0
-                       CPP=cpp-4.0
-                       ;;
-               esac
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+            case "${UNIVERSALSDK}" in
+            */MacOSX10.4u.sdk)
+                # Build using 10.4 SDK, force usage of gcc when the
+                # compiler is gcc, otherwise the user will get very
+                # confusing error messages when building on OSX 10.6
+                CC=gcc-4.0
+                CPP=cpp-4.0
+                ;;
+            esac
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
 $as_echo "$CC" >&6; }
-           fi
-
-           # Calculate the right deployment target for this build.
-           #
-               cur_target_major=`sw_vers -productVersion | \
-                               sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'`
-               cur_target_minor=`sw_vers -productVersion | \
-                               sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'`
-               cur_target="${cur_target_major}.${cur_target_minor}"
-               if test ${cur_target_major} -eq 10 && \
-                  test ${cur_target_minor} -ge 3
-               then
-                   cur_target=10.3
-                   if test ${enable_universalsdk}; then
-                           if test "${UNIVERSAL_ARCHS}" = "all"; then
-                                   # Ensure that the default platform for a
-                                   # 4-way universal build is OSX 10.5,
-                                   # that's the first OS release where
-                                   # 4-way builds make sense.
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "intel"; then
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
-                                   cur_target='10.5'
-                           fi
-                   else
-                           if test `/usr/bin/arch` = "i386"; then
-                                   # On Intel macs default to a deployment
-                                   # target of 10.4, that's the first OSX
-                                   # release with Intel support.
-                                   cur_target="10.4"
-                           fi
-                   fi
-           fi
-           CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
-
-           # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
-           # environment with a value that is the same as what we'll use
-           # in the Makefile to ensure that we'll get the same compiler
-           # environment during configure and build time.
-           MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
-           export MACOSX_DEPLOYMENT_TARGET
-           EXPORT_MACOSX_DEPLOYMENT_TARGET=''
-
-           if test "${enable_universalsdk}"; then
-               UNIVERSAL_ARCH_FLAGS=""
-               if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
-                  ARCH_RUN_32BIT=""
-                  LIPO_32BIT_FLAGS=""
-
-                elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
-                  LIPO_32BIT_FLAGS=""
-                  ARCH_RUN_32BIT="true"
-
-                elif test "$UNIVERSAL_ARCHS" = "all" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
-
-                elif test "$UNIVERSAL_ARCHS" = "intel" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386"
-
-                elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
-
-                else
-                  as_fn_error $? "proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way" "$LINENO" 5
-
-                fi
-
-
-               CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
-               if test "${UNIVERSALSDK}" != "/"
-               then
-                       CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
-                       LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-                       CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
-               fi
-
-           fi
+        fi
 
+        if test "${enable_universalsdk}"
+        then
+            case "$UNIVERSAL_ARCHS" in
+            32-bit)
+               UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            64-bit)
+               UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            all)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
+               ;;
+            intel)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386"
+               ;;
+            intel-32)
+               UNIVERSAL_ARCH_FLAGS="-arch i386"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            intel-64)
+               UNIVERSAL_ARCH_FLAGS="-arch x86_64"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            3-way)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
+               ;;
+            *)
+               as_fn_error $? "proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way" "$LINENO" 5
+               ;;
+            esac
+
+            if test "${UNIVERSALSDK}" != "/"
+            then
+                CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
+                LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
+                CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
+            else
+                CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
+                LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
+            fi
+        fi
 
-           ;;
+        # Calculate an appropriate deployment target for this build:
+        # The deployment target value is used explicitly to enable certain
+        # features are enabled (such as builtin libedit support for readline)
+        # through the use of Apple's Availability Macros and is used as a
+        # component of the string returned by distutils.get_platform().
+        #
+        # Use the value from:
+        # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
+        # 2. the operating system version of the build machine if >= 10.6
+        # 3. If running on OS X 10.3 through 10.5, use the legacy tests
+        #       below to pick either 10.3, 10.4, or 10.5 as the target.
+        # 4. If we are running on OS X 10.2 or earlier, good luck!
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking which MACOSX_DEPLOYMENT_TARGET to use" >&5
+$as_echo_n "checking which MACOSX_DEPLOYMENT_TARGET to use... " >&6; }
+        cur_target_major=`sw_vers -productVersion | \
+                sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'`
+        cur_target_minor=`sw_vers -productVersion | \
+                sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'`
+        cur_target="${cur_target_major}.${cur_target_minor}"
+        if test ${cur_target_major} -eq 10 && \
+           test ${cur_target_minor} -ge 3 && \
+           test ${cur_target_minor} -le 5
+        then
+            # OS X 10.3 through 10.5
+            cur_target=10.3
+            if test ${enable_universalsdk}
+            then
+                case "$UNIVERSAL_ARCHS" in
+                all|3-way|intel|64-bit)
+                    # These configurations were first supported in 10.5
+                    cur_target='10.5'
+                    ;;
+                esac
+            else
+                if test `/usr/bin/arch` = "i386"
+                then
+                    # 10.4 was the first release to support Intel archs
+                    cur_target="10.4"
+                fi
+            fi
+        fi
+        CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
+
+        # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
+        # environment with a value that is the same as what we'll use
+        # in the Makefile to ensure that we'll get the same compiler
+        # environment during configure and build time.
+        MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
+        export MACOSX_DEPLOYMENT_TARGET
+        EXPORT_MACOSX_DEPLOYMENT_TARGET=''
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACOSX_DEPLOYMENT_TARGET" >&5
+$as_echo "$MACOSX_DEPLOYMENT_TARGET" >&6; }
+
+        # end of Darwin* tests
+        ;;
        OSF*)
            BASECFLAGS="$BASECFLAGS -mieee"
            ;;
@@ -7034,7 +7066,7 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
 
 fi
 
-for ac_header in asm/types.h conio.h direct.h dlfcn.h errno.h \
+for ac_header in asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
 fcntl.h grp.h \
 ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
@@ -7045,7 +7077,7 @@ sys/param.h sys/poll.h sys/random.h sys/select.h sys/socket.h sys/statvfs.h sys/
 sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h
+bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -8440,7 +8472,6 @@ fi
                ;;
        esac
 
-       #ARCH_RUN_32BIT="true"
     fi
 
     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
@@ -8617,9 +8648,6 @@ then
                        fi
                else
                        # building for OS X 10.3 and later
-                       if test "${enable_universalsdk}"; then
-                               LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-                       fi
                        LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
                        LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
                        BLDSHARED="$LDSHARED"
@@ -14638,6 +14666,10 @@ $as_echo "#define MVWDELCH_IS_EXPRESSION 1" >>confdefs.h
 
 fi
 
+# Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
+# structs since version 5.7.  If the macro is defined as zero before including
+# [n]curses.h, ncurses will expose fields of the structs regardless of the
+# configuration.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether WINDOW has _flags" >&5
 $as_echo_n "checking whether WINDOW has _flags... " >&6; }
 if ${ac_cv_window_has_flags+:} false; then :
@@ -14645,7 +14677,10 @@ if ${ac_cv_window_has_flags+:} false; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <curses.h>
+
+  #define NCURSES_OPAQUE 0
+  #include <curses.h>
+
 int
 main ()
 {
@@ -14676,6 +14711,36 @@ $as_echo "#define WINDOW_HAS_FLAGS 1" >>confdefs.h
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_pad" >&5
+$as_echo_n "checking for is_pad... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef is_pad
+void *x=is_pad
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_IS_PAD 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_term_resized" >&5
 $as_echo_n "checking for is_term_resized... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14751,6 +14816,216 @@ else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for immedok" >&5
+$as_echo_n "checking for immedok... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef immedok
+void *x=immedok
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_IMMEDOK 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for syncok" >&5
+$as_echo_n "checking for syncok... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef syncok
+void *x=syncok
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_SYNCOK 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchgat" >&5
+$as_echo_n "checking for wchgat... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef wchgat
+void *x=wchgat
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_WCHGAT 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for filter" >&5
+$as_echo_n "checking for filter... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef filter
+void *x=filter
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_FILTER 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for has_key" >&5
+$as_echo_n "checking for has_key... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef has_key
+void *x=has_key
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_HAS_KEY 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for typeahead" >&5
+$as_echo_n "checking for typeahead... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef typeahead
+void *x=typeahead
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_TYPEAHEAD 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for use_env" >&5
+$as_echo_n "checking for use_env... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <curses.h>
+int
+main ()
+{
+
+#ifndef use_env
+void *x=use_env
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_CURSES_USE_ENV 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 # last curses configure check
index 780f2758c839e3092e6ca90e150cedb5727d6c78..913d5469d06e34735ee1a5a6387ce76d10f0392f 100644 (file)
@@ -113,14 +113,20 @@ CONFIG_ARGS="$ac_configure_args"
 
 AC_MSG_CHECKING([for --enable-universalsdk])
 AC_ARG_ENABLE(universalsdk,
-       AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
+       AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build fat binary against Mac OS X SDK]),
 [
        case $enableval in
        yes)
-               enableval=/Developer/SDKs/MacOSX10.4u.sdk
-               if test ! -d "${enableval}"
+               # Locate the best usable SDK, see Mac/README.txt for more
+               # information
+               enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
+               if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
                then
-                       enableval=/
+                       enableval=/Developer/SDKs/MacOSX10.4u.sdk
+                       if test ! -d "${enableval}"
+                       then
+                               enableval=/
+                       fi
                fi
                ;;
        esac
@@ -137,7 +143,7 @@ AC_ARG_ENABLE(universalsdk,
                fi
                ;;
        esac
-       
+
 ],[
        UNIVERSALSDK=
        enable_universalsdk=
@@ -153,25 +159,34 @@ AC_SUBST(UNIVERSALSDK)
 AC_SUBST(ARCH_RUN_32BIT)
 ARCH_RUN_32BIT=""
 
+# For backward compatibility reasons we prefer to select '32-bit' if available,
+# otherwise use 'intel'
 UNIVERSAL_ARCHS="32-bit"
+if test "`uname -s`" = "Darwin"
+then
+       if test -n "${UNIVERSALSDK}"
+       then
+               if test -z "`/usr/bin/file -L "${UNIVERSALSDK}/usr/lib/libSystem.dylib" | grep ppc`"
+               then
+                       UNIVERSAL_ARCHS="intel"
+               fi
+       fi
+fi
+
 AC_SUBST(LIPO_32BIT_FLAGS)
 AC_MSG_CHECKING(for --with-universal-archs)
 AC_ARG_WITH(universal-archs,
-    AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
+    AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all")]),
 [
-       AC_MSG_RESULT($withval)
        UNIVERSAL_ARCHS="$withval"
-        if test "${enable_universalsdk}" ; then
-               :
-       else
-               AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
-       fi
 ],
-[
-       AC_MSG_RESULT(32-bit)
-])
-
-
+[])
+if test -n "${UNIVERSALSDK}"
+then
+       AC_MSG_RESULT(${UNIVERSAL_ARCHS})
+else
+       AC_MSG_RESULT(no)
+fi
 
 AC_ARG_WITH(framework-name,
               AS_HELP_STRING([--with-framework-name=FRAMEWORK],
@@ -1136,117 +1151,133 @@ yes)
        SCO_SV*)
            BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
            ;;
-       # is there any other compiler on Darwin besides gcc?
-       Darwin*)
-           # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
-           # used to be here, but non-Apple gcc doesn't accept them.
-           if test "${CC}" = gcc
-           then
-               AC_MSG_CHECKING(which compiler should be used)
-               case "${UNIVERSALSDK}" in
-               */MacOSX10.4u.sdk)
-                       # Build using 10.4 SDK, force usage of gcc when the 
-                       # compiler is gcc, otherwise the user will get very
-                       # confusing error messages when building on OSX 10.6
-                       CC=gcc-4.0
-                       CPP=cpp-4.0
-                       ;;
-               esac
-               AC_MSG_RESULT($CC)
-           fi
-
-           # Calculate the right deployment target for this build.
-           #
-               cur_target_major=`sw_vers -productVersion | \
-                               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
-               cur_target_minor=`sw_vers -productVersion | \
-                               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
-               cur_target="${cur_target_major}.${cur_target_minor}"
-               if test ${cur_target_major} -eq 10 && \
-                  test ${cur_target_minor} -ge 3
-               then
-                   cur_target=10.3
-                   if test ${enable_universalsdk}; then
-                           if test "${UNIVERSAL_ARCHS}" = "all"; then
-                                   # Ensure that the default platform for a 
-                                   # 4-way universal build is OSX 10.5, 
-                                   # that's the first OS release where 
-                                   # 4-way builds make sense.
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "intel"; then
-                                   cur_target='10.5'
-
-                           elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
-                                   cur_target='10.5'
-                           fi
-                   else
-                           if test `/usr/bin/arch` = "i386"; then
-                                   # On Intel macs default to a deployment
-                                   # target of 10.4, that's the first OSX
-                                   # release with Intel support.
-                                   cur_target="10.4"
-                           fi
-                   fi
-           fi
-           CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
-           
-           # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
-           # environment with a value that is the same as what we'll use
-           # in the Makefile to ensure that we'll get the same compiler
-           # environment during configure and build time.
-           MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
-           export MACOSX_DEPLOYMENT_TARGET
-           EXPORT_MACOSX_DEPLOYMENT_TARGET=''
-
-           if test "${enable_universalsdk}"; then
-               UNIVERSAL_ARCH_FLAGS=""
-               if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
-                  ARCH_RUN_32BIT=""
-                  LIPO_32BIT_FLAGS=""
-
-                elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
-                  LIPO_32BIT_FLAGS=""
-                  ARCH_RUN_32BIT="true"
-
-                elif test "$UNIVERSAL_ARCHS" = "all" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
-
-                elif test "$UNIVERSAL_ARCHS" = "intel" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386"
-
-                elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
-                  UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
-                  LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
-                  ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
-
-                else
-                  AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
-
-                fi
-
-
-               CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
-               if test "${UNIVERSALSDK}" != "/" 
-               then
-                       CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
-                       LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-                       CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
-               fi
-
-           fi
+    # is there any other compiler on Darwin besides gcc?
+    Darwin*)
+        # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
+        # used to be here, but non-Apple gcc doesn't accept them.
+        if test "${CC}" = gcc
+        then
+            AC_MSG_CHECKING(which compiler should be used)
+            case "${UNIVERSALSDK}" in
+            */MacOSX10.4u.sdk)
+                # Build using 10.4 SDK, force usage of gcc when the
+                # compiler is gcc, otherwise the user will get very
+                # confusing error messages when building on OSX 10.6
+                CC=gcc-4.0
+                CPP=cpp-4.0
+                ;;
+            esac
+            AC_MSG_RESULT($CC)
+        fi
 
+        if test "${enable_universalsdk}"
+        then
+            case "$UNIVERSAL_ARCHS" in
+            32-bit)
+               UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            64-bit)
+               UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            all)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
+               ;;
+            intel)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386"
+               ;;
+            intel-32)
+               UNIVERSAL_ARCH_FLAGS="-arch i386"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            intel-64)
+               UNIVERSAL_ARCH_FLAGS="-arch x86_64"
+               LIPO_32BIT_FLAGS=""
+               ARCH_RUN_32BIT=""
+               ;;
+            3-way)
+               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
+               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
+               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
+               ;;
+            *)
+               AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
+               ;;
+            esac
+
+            if test "${UNIVERSALSDK}" != "/"
+            then
+                CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
+                LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
+                CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
+            else
+                CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
+                LDFLAGS="${UNIVERSAL_ARCH_FLAGS} ${LDFLAGS}"
+            fi
+        fi
 
-           ;;
+        # Calculate an appropriate deployment target for this build:
+        # The deployment target value is used explicitly to enable certain
+        # features are enabled (such as builtin libedit support for readline)
+        # through the use of Apple's Availability Macros and is used as a
+        # component of the string returned by distutils.get_platform().
+        #
+        # Use the value from:
+        # 1. the MACOSX_DEPLOYMENT_TARGET environment variable if specified
+        # 2. the operating system version of the build machine if >= 10.6
+        # 3. If running on OS X 10.3 through 10.5, use the legacy tests
+        #       below to pick either 10.3, 10.4, or 10.5 as the target.
+        # 4. If we are running on OS X 10.2 or earlier, good luck!
+
+        AC_MSG_CHECKING(which MACOSX_DEPLOYMENT_TARGET to use)
+        cur_target_major=`sw_vers -productVersion | \
+                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+        cur_target_minor=`sw_vers -productVersion | \
+                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+        cur_target="${cur_target_major}.${cur_target_minor}"
+        if test ${cur_target_major} -eq 10 && \
+           test ${cur_target_minor} -ge 3 && \
+           test ${cur_target_minor} -le 5
+        then
+            # OS X 10.3 through 10.5
+            cur_target=10.3
+            if test ${enable_universalsdk}
+            then
+                case "$UNIVERSAL_ARCHS" in
+                all|3-way|intel|64-bit)
+                    # These configurations were first supported in 10.5
+                    cur_target='10.5'
+                    ;;
+                esac
+            else
+                if test `/usr/bin/arch` = "i386"
+                then
+                    # 10.4 was the first release to support Intel archs
+                    cur_target="10.4"
+                fi
+            fi
+        fi
+        CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
+
+        # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
+        # environment with a value that is the same as what we'll use
+        # in the Makefile to ensure that we'll get the same compiler
+        # environment during configure and build time.
+        MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
+        export MACOSX_DEPLOYMENT_TARGET
+        EXPORT_MACOSX_DEPLOYMENT_TARGET=''
+        AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET)
+
+        # end of Darwin* tests
+        ;;
        OSF*)
            BASECFLAGS="$BASECFLAGS -mieee"
            ;;
@@ -1383,7 +1414,6 @@ if test "$Py_OPT" = 'true' ; then
   # compile working code using it and both test_distutils and test_gdb are
   # broken when you do managed to get a toolchain that works with it.  People
   # who want LTO need to use --with-lto themselves.
-  Py_LTO='true'
   DEF_MAKE_ALL_RULE="profile-opt"
   REQUIRE_PGO="yes"
   DEF_MAKE_RULE="build_all"
@@ -1691,7 +1721,7 @@ dnl AC_MSG_RESULT($cpp_type)
 
 # checks for header files
 AC_HEADER_STDC
-AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
+AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
 fcntl.h grp.h \
 ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
@@ -1702,7 +1732,7 @@ sys/param.h sys/poll.h sys/random.h sys/select.h sys/socket.h sys/statvfs.h sys/
 sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
+bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
 AC_HEADER_DIRENT
 AC_HEADER_MAJOR
 
@@ -2034,7 +2064,6 @@ case $ac_sys_system/$ac_sys_release in
                ;;
        esac
 
-       #ARCH_RUN_32BIT="true"
     fi
 
     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
@@ -2199,9 +2228,6 @@ then
                        fi
                else
                        # building for OS X 10.3 and later
-                       if test "${enable_universalsdk}"; then
-                               LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-                       fi
                        LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
                        LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
                        BLDSHARED="$LDSHARED"
@@ -4517,9 +4543,16 @@ then
   [Define if mvwdelch in curses.h is an expression.])
 fi
 
+# Issue #25720: ncurses has introduced the NCURSES_OPAQUE symbol making opaque
+# structs since version 5.7.  If the macro is defined as zero before including
+# [n]curses.h, ncurses will expose fields of the structs regardless of the
+# configuration.
 AC_MSG_CHECKING(whether WINDOW has _flags)
 AC_CACHE_VAL(ac_cv_window_has_flags,
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+  #define NCURSES_OPAQUE 0
+  #include <curses.h>
+]], [[
   WINDOW *w;
   w->_flags = 0;
 ]])],
@@ -4534,6 +4567,17 @@ then
   [Define if WINDOW in curses.h offers a field _flags.])
 fi
 
+AC_MSG_CHECKING(for is_pad)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef is_pad
+void *x=is_pad
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_IS_PAD, 1, Define if you have the 'is_pad' function or macro.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
 AC_MSG_CHECKING(for is_term_resized)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
   [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
@@ -4554,6 +4598,83 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm
    AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)]
 )
+
+AC_MSG_CHECKING(for immedok)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef immedok
+void *x=immedok
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_IMMEDOK, 1, Define if you have the 'immedok' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for syncok)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef syncok
+void *x=syncok
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_SYNCOK, 1, Define if you have the 'syncok' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for wchgat)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef wchgat
+void *x=wchgat
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_WCHGAT, 1, Define if you have the 'wchgat' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for filter)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef filter
+void *x=filter
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_FILTER, 1, Define if you have the 'filter' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for has_key)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef has_key
+void *x=has_key
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_HAS_KEY, 1, Define if you have the 'has_key' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for typeahead)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef typeahead
+void *x=typeahead
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_TYPEAHEAD, 1, Define if you have the 'typeahead' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
+AC_MSG_CHECKING(for use_env)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
+#ifndef use_env
+void *x=use_env
+#endif
+]])],
+  [AC_DEFINE(HAVE_CURSES_USE_ENV, 1, Define if you have the 'use_env' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
 # last curses configure check
 CPPFLAGS=$ac_save_cppflags
 
index 98a76a55f443cce1b5baddddb8fa006467d383b1..11c4a66873c11030dcf8142a79b3585eb4143ec9 100644 (file)
 /* Define to 1 if you have the `copysign' function. */
 #undef HAVE_COPYSIGN
 
+/* Define to 1 if you have the <crypt.h> header file. */
+#undef HAVE_CRYPT_H
+
 /* Define to 1 if you have the `ctermid' function. */
 #undef HAVE_CTERMID
 
 /* Define if you have the 'ctermid_r' function. */
 #undef HAVE_CTERMID_R
 
+/* Define if you have the 'filter' function. */
+#undef HAVE_CURSES_FILTER
+
 /* Define to 1 if you have the <curses.h> header file. */
 #undef HAVE_CURSES_H
 
+/* Define if you have the 'has_key' function. */
+#undef HAVE_CURSES_HAS_KEY
+
+/* Define if you have the 'immedok' function. */
+#undef HAVE_CURSES_IMMEDOK
+
+/* Define if you have the 'is_pad' function or macro. */
+#undef HAVE_CURSES_IS_PAD
+
 /* Define if you have the 'is_term_resized' function. */
 #undef HAVE_CURSES_IS_TERM_RESIZED
 
 /* Define if you have the 'resize_term' function. */
 #undef HAVE_CURSES_RESIZE_TERM
 
+/* Define if you have the 'syncok' function. */
+#undef HAVE_CURSES_SYNCOK
+
+/* Define if you have the 'typeahead' function. */
+#undef HAVE_CURSES_TYPEAHEAD
+
+/* Define if you have the 'use_env' function. */
+#undef HAVE_CURSES_USE_ENV
+
+/* Define if you have the 'wchgat' function. */
+#undef HAVE_CURSES_WCHGAT
+
 /* Define to 1 if you have the declaration of `isfinite', and to 0 if you
    don't. */
 #undef HAVE_DECL_ISFINITE
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
+/* Define to 1 if you have the <sys/sysmacros.h> header file. */
+#undef HAVE_SYS_SYSMACROS_H
+
 /* Define to 1 if you have the <sys/termio.h> header file. */
 #undef HAVE_SYS_TERMIO_H
 
index 5503486ccbf688bb789bfc7113a9fc63dbc233ff..33cecc6875739c507c5f3236077e2cc0c47c4e22 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1346,19 +1346,11 @@ class PyBuildExt(build_ext):
             else:
                 missing.append('resource')
 
-            # Sun yellow pages. Some systems have the functions in libc.
-            if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and
-                find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
-                if (self.compiler.find_library_file(lib_dirs, 'nsl')):
-                    libs = ['nsl']
-                else:
-                    libs = []
-                exts.append( Extension('nis', ['nismodule.c'],
-                                       libraries = libs) )
+            nis = self._detect_nis(inc_dirs, lib_dirs)
+            if nis is not None:
+                exts.append(nis)
             else:
                 missing.append('nis')
-        else:
-            missing.extend(['nis', 'resource', 'termios'])
 
         # Curses support, requiring the System V version of curses, often
         # provided by the ncurses library.
@@ -2157,6 +2149,55 @@ class PyBuildExt(build_ext):
             ext.libraries.append(ffi_lib)
             self.use_system_libffi = True
 
+        if sysconfig.get_config_var('HAVE_LIBDL'):
+            # for dlopen, see bpo-32647
+            ext.libraries.append('dl')
+
+    def _detect_nis(self, inc_dirs, lib_dirs):
+        if host_platform in {'win32', 'cygwin', 'qnx6'}:
+            return None
+
+        libs = []
+        library_dirs = []
+        includes_dirs = []
+
+        # bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28
+        # moved headers and libraries to libtirpc and libnsl. The headers
+        # are in tircp and nsl sub directories.
+        rpcsvc_inc = find_file(
+            'rpcsvc/yp_prot.h', inc_dirs,
+            [os.path.join(inc_dir, 'nsl') for inc_dir in inc_dirs]
+        )
+        rpc_inc = find_file(
+            'rpc/rpc.h', inc_dirs,
+            [os.path.join(inc_dir, 'tirpc') for inc_dir in inc_dirs]
+        )
+        if rpcsvc_inc is None or rpc_inc is None:
+            # not found
+            return None
+        includes_dirs.extend(rpcsvc_inc)
+        includes_dirs.extend(rpc_inc)
+
+        if self.compiler.find_library_file(lib_dirs, 'nsl'):
+            libs.append('nsl')
+        else:
+            # libnsl-devel: check for libnsl in nsl/ subdirectory
+            nsl_dirs = [os.path.join(lib_dir, 'nsl') for lib_dir in lib_dirs]
+            libnsl = self.compiler.find_library_file(nsl_dirs, 'nsl')
+            if libnsl is not None:
+                library_dirs.append(os.path.dirname(libnsl))
+                libs.append('nsl')
+
+        if self.compiler.find_library_file(lib_dirs, 'tirpc'):
+            libs.append('tirpc')
+
+        return Extension(
+            'nis', ['nismodule.c'],
+            libraries=libs,
+            library_dirs=library_dirs,
+            include_dirs=includes_dirs
+        )
+
 
 class PyBuildInstall(install):
     # Suppress the warning about installation into the lib_dynload