summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-07-07 14:35:02 -0500
committerZachary Ware <zachary.ware@gmail.com>2014-07-07 14:35:02 -0500
commite55c07614b4f6d4961a2d3fc9af4cf92c2b2615c (patch)
tree6eabbaa47b0066ea2480864b78e69c645daed3da /Doc
parentbb715c3208e98a5abf245de2fcfd7e93e28614e0 (diff)
parent8eb1f397f7637f49e102198ef49e156e229b09de (diff)
downloadcpython-e55c07614b4f6d4961a2d3fc9af4cf92c2b2615c.tar.gz
Issue #17846: Merge with 3.4
Diffstat (limited to 'Doc')
-rw-r--r--Doc/README.txt2
-rw-r--r--Doc/c-api/memory.rst44
-rw-r--r--Doc/c-api/number.rst17
-rw-r--r--Doc/c-api/typeobj.rst3
-rw-r--r--Doc/distutils/apiref.rst4
-rw-r--r--Doc/distutils/builtdist.rst2
-rw-r--r--Doc/glossary.rst7
-rw-r--r--Doc/howto/clinic.rst8
-rw-r--r--Doc/howto/pyporting.rst2
-rw-r--r--Doc/howto/regex.rst2
-rw-r--r--Doc/howto/sockets.rst2
-rw-r--r--Doc/library/argparse.rst2
-rw-r--r--Doc/library/asynchat.rst34
-rw-r--r--Doc/library/cmd.rst2
-rw-r--r--Doc/library/code.rst2
-rw-r--r--Doc/library/codecs.rst12
-rw-r--r--Doc/library/collections.abc.rst2
-rw-r--r--Doc/library/collections.rst5
-rw-r--r--Doc/library/concurrent.futures.rst2
-rw-r--r--Doc/library/configparser.rst6
-rw-r--r--Doc/library/copyreg.rst2
-rw-r--r--Doc/library/csv.rst1
-rw-r--r--Doc/library/datetime.rst11
-rw-r--r--Doc/library/dbm.rst9
-rw-r--r--Doc/library/decimal.rst15
-rw-r--r--Doc/library/difflib.rst16
-rw-r--r--Doc/library/dis.rst10
-rw-r--r--Doc/library/doctest.rst12
-rw-r--r--Doc/library/formatter.rst2
-rw-r--r--Doc/library/heapq.rst14
-rw-r--r--Doc/library/http.server.rst2
-rw-r--r--Doc/library/imghdr.rst10
-rw-r--r--Doc/library/importlib.rst58
-rw-r--r--Doc/library/inspect.rst36
-rw-r--r--Doc/library/io.rst31
-rw-r--r--Doc/library/ipaddress.rst36
-rw-r--r--Doc/library/itertools.rst18
-rw-r--r--Doc/library/json.rst53
-rw-r--r--Doc/library/logging.handlers.rst2
-rw-r--r--Doc/library/multiprocessing.rst3
-rw-r--r--Doc/library/operator.rst18
-rw-r--r--Doc/library/os.rst39
-rw-r--r--Doc/library/pathlib.rst19
-rw-r--r--Doc/library/pkgutil.rst4
-rw-r--r--Doc/library/plistlib.rst2
-rw-r--r--Doc/library/random.rst3
-rw-r--r--Doc/library/resource.rst2
-rw-r--r--Doc/library/select.rst2
-rw-r--r--Doc/library/selectors.rst11
-rw-r--r--Doc/library/shutil.rst44
-rw-r--r--Doc/library/signal.rst10
-rw-r--r--Doc/library/site.rst20
-rw-r--r--Doc/library/smtpd.rst24
-rw-r--r--Doc/library/smtplib.rst39
-rw-r--r--Doc/library/socket.rst28
-rw-r--r--Doc/library/socketserver.rst4
-rw-r--r--Doc/library/ssl.rst55
-rw-r--r--Doc/library/stat.rst28
-rw-r--r--Doc/library/subprocess.rst1
-rw-r--r--Doc/library/tempfile.rst7
-rw-r--r--Doc/library/threading.rst2
-rw-r--r--Doc/library/tkinter.ttk.rst2
-rw-r--r--Doc/library/token.rst1
-rw-r--r--Doc/library/tracemalloc.rst2
-rw-r--r--Doc/library/turtle.rst6
-rw-r--r--Doc/library/types.rst4
-rw-r--r--Doc/library/unicodedata.rst8
-rw-r--r--Doc/library/unittest.mock.rst47
-rw-r--r--Doc/library/urllib.request.rst4
-rw-r--r--Doc/library/weakref.rst4
-rw-r--r--Doc/library/webbrowser.rst2
-rw-r--r--Doc/library/wsgiref.rst9
-rw-r--r--Doc/library/xml.dom.rst2
-rw-r--r--Doc/library/xmlrpc.client.rst23
-rw-r--r--Doc/reference/datamodel.rst60
-rw-r--r--Doc/reference/expressions.rst17
-rw-r--r--Doc/reference/simple_stmts.rst2
-rw-r--r--Doc/tools/sphinxext/indexsidebar.html3
-rw-r--r--Doc/tools/sphinxext/pyspecific.py2
-rw-r--r--Doc/tools/sphinxext/susp-ignored.csv4
-rw-r--r--Doc/tutorial/datastructures.rst5
-rw-r--r--Doc/tutorial/interpreter.rst14
-rw-r--r--Doc/tutorial/stdlib.rst2
-rw-r--r--Doc/tutorial/stdlib2.rst2
-rw-r--r--Doc/whatsnew/2.1.rst2
-rw-r--r--Doc/whatsnew/3.3.rst6
-rw-r--r--Doc/whatsnew/3.5.rst345
-rw-r--r--Doc/whatsnew/index.rst1
88 files changed, 1190 insertions, 252 deletions
diff --git a/Doc/README.txt b/Doc/README.txt
index 6df12ab157..fed1f749c0 100644
--- a/Doc/README.txt
+++ b/Doc/README.txt
@@ -3,7 +3,7 @@ Python Documentation README
This directory contains the reStructuredText (reST) sources to the Python
documentation. You don't need to build them yourself, prebuilt versions are
-available at <https://docs.python.org/3.4/download.html>.
+available at <https://docs.python.org/dev/download.html>.
Documentation on authoring Python documentation, including information about
both style and markup, is available in the "Documenting Python" chapter of the
diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst
index a82e1c2f2c..5d78f385ee 100644
--- a/Doc/c-api/memory.rst
+++ b/Doc/c-api/memory.rst
@@ -92,8 +92,8 @@ functions are thread-safe, the :term:`GIL <global interpreter lock>` does not
need to be held.
The default raw memory block allocator uses the following functions:
-:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when
-requesting zero bytes.
+:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call
+``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes.
.. versionadded:: 3.4
@@ -106,6 +106,17 @@ requesting zero bytes.
been initialized in any way.
+.. c:function:: void* PyMem_RawCalloc(size_t nelem, size_t elsize)
+
+ Allocates *nelem* elements each whose size in bytes is *elsize* and returns
+ a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the
+ request fails. The memory is initialized to zeros. Requesting zero elements
+ or elements of size zero bytes returns a distinct non-*NULL* pointer if
+ possible, as if ``PyMem_RawCalloc(1, 1)`` had been called instead.
+
+ .. versionadded:: 3.5
+
+
.. c:function:: void* PyMem_RawRealloc(void *p, size_t n)
Resizes the memory block pointed to by *p* to *n* bytes. The contents will
@@ -136,8 +147,8 @@ behavior when requesting zero bytes, are available for allocating and releasing
memory from the Python heap.
The default memory block allocator uses the following functions:
-:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when
-requesting zero bytes.
+:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call
+``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes.
.. warning::
@@ -152,6 +163,17 @@ requesting zero bytes.
been called instead. The memory will not have been initialized in any way.
+.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)
+
+ Allocates *nelem* elements each whose size in bytes is *elsize* and returns
+ a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the
+ request fails. The memory is initialized to zeros. Requesting zero elements
+ or elements of size zero bytes returns a distinct non-*NULL* pointer if
+ possible, as if ``PyMem_Calloc(1, 1)`` had been called instead.
+
+ .. versionadded:: 3.5
+
+
.. c:function:: void* PyMem_Realloc(void *p, size_t n)
Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
@@ -210,7 +232,7 @@ Customize Memory Allocators
.. versionadded:: 3.4
-.. c:type:: PyMemAllocator
+.. c:type:: PyMemAllocatorEx
Structure used to describe a memory block allocator. The structure has
four fields:
@@ -222,11 +244,19 @@ Customize Memory Allocators
+----------------------------------------------------------+---------------------------------------+
| ``void* malloc(void *ctx, size_t size)`` | allocate a memory block |
+----------------------------------------------------------+---------------------------------------+
+ | ``void* calloc(void *ctx, size_t nelem, size_t elsize)`` | allocate a memory block initialized |
+ | | with zeros |
+ +----------------------------------------------------------+---------------------------------------+
| ``void* realloc(void *ctx, void *ptr, size_t new_size)`` | allocate or resize a memory block |
+----------------------------------------------------------+---------------------------------------+
| ``void free(void *ctx, void *ptr)`` | free a memory block |
+----------------------------------------------------------+---------------------------------------+
+ .. versionchanged:: 3.5
+ The :c:type:`PyMemAllocator` structure was renamed to
+ :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
+
+
.. c:type:: PyMemAllocatorDomain
Enum used to identify an allocator domain. Domains:
@@ -239,12 +269,12 @@ Customize Memory Allocators
:c:func:`PyObject_Realloc` and :c:func:`PyObject_Free`
-.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocator *allocator)
+.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)
Get the memory block allocator of the specified domain.
-.. c:function:: void PyMem_SetAllocator(PyMemAllocatorDomain domain, PyMemAllocator *allocator)
+.. c:function:: void PyMem_SetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)
Set the memory block allocator of the specified domain.
diff --git a/Doc/c-api/number.rst b/Doc/c-api/number.rst
index 21951c38c0..9bcb649c9d 100644
--- a/Doc/c-api/number.rst
+++ b/Doc/c-api/number.rst
@@ -30,6 +30,14 @@ Number Protocol
the equivalent of the Python expression ``o1 * o2``.
+.. c:function:: PyObject* PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2)
+
+ Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on
+ failure. This is the equivalent of the Python expression ``o1 @ o2``.
+
+ .. versionadded:: 3.5
+
+
.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is
@@ -146,6 +154,15 @@ Number Protocol
the Python statement ``o1 *= o2``.
+.. c:function:: PyObject* PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2)
+
+ Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on
+ failure. The operation is done *in-place* when *o1* supports it. This is
+ the equivalent of the Python statement ``o1 @= o2``.
+
+ .. versionadded:: 3.5
+
+
.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure.
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index 497af23bdf..b627d95f74 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -1141,6 +1141,9 @@ Number Object Structures
binaryfunc nb_inplace_true_divide;
unaryfunc nb_index;
+
+ binaryfunc nb_matrix_multiply;
+ binaryfunc nb_inplace_matrix_multiply;
} PyNumberMethods;
.. note::
diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst
index e1357fa90d..4c38a07a69 100644
--- a/Doc/distutils/apiref.rst
+++ b/Doc/distutils/apiref.rst
@@ -1099,13 +1099,13 @@ other utility module.
during the build of Python), not the OS version of the current system.
For universal binary builds on Mac OS X the architecture value reflects
- the univeral binary status instead of the architecture of the current
+ the universal binary status instead of the architecture of the current
processor. For 32-bit universal binaries the architecture is ``fat``,
for 64-bit universal binaries the architecture is ``fat64``, and
for 4-way universal binaries the architecture is ``universal``. Starting
from Python 2.7 and Python 3.2 the architecture ``fat3`` is used for
a 3-way universal build (ppc, i386, x86_64) and ``intel`` is used for
- a univeral build with the i386 and x86_64 architectures
+ a universal build with the i386 and x86_64 architectures
Examples of returned values on Mac OS X:
diff --git a/Doc/distutils/builtdist.rst b/Doc/distutils/builtdist.rst
index 83c68ae20c..a67c68e21a 100644
--- a/Doc/distutils/builtdist.rst
+++ b/Doc/distutils/builtdist.rst
@@ -355,7 +355,7 @@ support this option, so the command::
would create a 64bit installation executable on your 32bit version of Windows.
To cross-compile, you must download the Python source code and cross-compile
-Python itself for the platform you are targetting - it is not possible from a
+Python itself for the platform you are targeting - it is not possible from a
binary installation of Python (as the .lib etc file for other platforms are
not included.) In practice, this means the user of a 32 bit operating
system will need to use Visual Studio 2008 to open the
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index f71a1f72e5..08ee9dbea4 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -444,12 +444,13 @@ Glossary
A number of tools in Python accept key functions to control how elements
are ordered or grouped. They include :func:`min`, :func:`max`,
- :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,
- :func:`heapq.nlargest`, and :func:`itertools.groupby`.
+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.merge`,
+ :func:`heapq.nsmallest`, :func:`heapq.nlargest`, and
+ :func:`itertools.groupby`.
There are several ways to create a key function. For example. the
:meth:`str.lower` method can serve as a key function for case insensitive
- sorts. Alternatively, an ad-hoc key function can be built from a
+ sorts. Alternatively, a key function can be built from a
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
the :mod:`operator` module provides three key function constructors:
:func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
diff --git a/Doc/howto/clinic.rst b/Doc/howto/clinic.rst
index 750ddbe074..ca8e1cb87b 100644
--- a/Doc/howto/clinic.rst
+++ b/Doc/howto/clinic.rst
@@ -886,7 +886,7 @@ Argument Clinic generates code that does it for you (in the parsing function).
Advanced converters
-------------------
-Remeber those format units you skipped for your first
+Remember those format units you skipped for your first
time because they were advanced? Here's how to handle those too.
The trick is, all those format units take arguments--either
@@ -1020,12 +1020,12 @@ any of the default arguments you can omit the parentheses.
the ``"as"`` should come before the return converter.)
There's one additional complication when using return converters: how do you
-indicate an error has occured? Normally, a function returns a valid (non-``NULL``)
+indicate an error has occurred? Normally, a function returns a valid (non-``NULL``)
pointer for success, and ``NULL`` for failure. But if you use an integer return converter,
all integers are valid. How can Argument Clinic detect an error? Its solution: each return
converter implicitly looks for a special value that indicates an error. If you return
that value, and an error has been set (``PyErr_Occurred()`` returns a true
-value), then the generated code will propogate the error. Otherwise it will
+value), then the generated code will propagate the error. Otherwise it will
encode the value you return like normal.
Currently Argument Clinic supports only a few return converters::
@@ -1573,7 +1573,7 @@ The fourth new directive is ``set``::
``line_prefix`` is a string that will be prepended to every line of Clinic's output;
``line_suffix`` is a string that will be appended to every line of Clinic's output.
-Both of these suport two format strings:
+Both of these support two format strings:
``{block comment start}``
Turns into the string ``/*``, the start-comment text sequence for C files.
diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst
index 9d7e8598c1..17fc81bfa6 100644
--- a/Doc/howto/pyporting.rst
+++ b/Doc/howto/pyporting.rst
@@ -60,7 +60,7 @@ If your project is on the Cheeseshop_/PyPI_, make sure it has the proper
`trove classifiers`_ to signify what versions of Python it **currently**
supports. At minimum you should specify the major version(s), e.g.
``Programming Language :: Python :: 2`` if your project currently only supports
-Python 2. It is preferrable that you be as specific as possible by listing every
+Python 2. It is preferable that you be as specific as possible by listing every
major/minor version of Python that you support, e.g. if your project supports
Python 2.6 and 2.7, then you want the classifiers of::
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index fbe763b3f2..9ae04d718d 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -852,7 +852,7 @@ keep track of the group numbers. There are two features which help with this
problem. Both of them use a common syntax for regular expression extensions, so
we'll look at that first.
-Perl 5 is well-known for its powerful additions to standard regular expressions.
+Perl 5 is well known for its powerful additions to standard regular expressions.
For these new features the Perl developers couldn't choose new single-keystroke metacharacters
or new special sequences beginning with ``\`` without making Perl's regular
expressions confusingly different from standard REs. If they chose ``&`` as a
diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst
index d5aff9081d..04394d49f0 100644
--- a/Doc/howto/sockets.rst
+++ b/Doc/howto/sockets.rst
@@ -234,7 +234,7 @@ messages to be sent back to back (without some kind of reply), and you pass
following message. You'll need to put that aside and hold onto it, until it's
needed.
-Prefixing the message with it's length (say, as 5 numeric characters) gets more
+Prefixing the message with its length (say, as 5 numeric characters) gets more
complex, because (believe it or not), you may not get all 5 characters in one
``recv``. In playing around, you'll get away with it; but in high network loads,
your code will very quickly break unless you use two ``recv`` loops - the first
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index b1b5135eac..36dc5f384b 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1873,7 +1873,7 @@ Customizing file parsing
Arguments that are read from a file (see the *fromfile_prefix_chars*
keyword argument to the :class:`ArgumentParser` constructor) are read one
- argument per line. :meth:`convert_arg_line_to_args` can be overriden for
+ argument per line. :meth:`convert_arg_line_to_args` can be overridden for
fancier reading.
This method takes a single argument *arg_line* which is a string read from
diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst
index c6fa06162e..794da8cced 100644
--- a/Doc/library/asynchat.rst
+++ b/Doc/library/asynchat.rst
@@ -147,40 +147,6 @@ connection requests.
by the channel after :meth:`found_terminator` is called.
-asynchat - Auxiliary Classes
-------------------------------------------
-
-.. class:: fifo(list=None)
-
- A :class:`fifo` holding data which has been pushed by the application but
- not yet popped for writing to the channel. A :class:`fifo` is a list used
- to hold data and/or producers until they are required. If the *list*
- argument is provided then it should contain producers or data items to be
- written to the channel.
-
-
- .. method:: is_empty()
-
- Returns ``True`` if and only if the fifo is empty.
-
-
- .. method:: first()
-
- Returns the least-recently :meth:`push`\ ed item from the fifo.
-
-
- .. method:: push(data)
-
- Adds the given data (which may be a string or a producer object) to the
- producer fifo.
-
-
- .. method:: pop()
-
- If the fifo is not empty, returns ``True, first()``, deleting the popped
- item. Returns ``False, None`` for an empty fifo.
-
-
.. _asynchat-example:
asynchat Example
diff --git a/Doc/library/cmd.rst b/Doc/library/cmd.rst
index 97229280c3..6d57b77ccf 100644
--- a/Doc/library/cmd.rst
+++ b/Doc/library/cmd.rst
@@ -252,7 +252,7 @@ immediate playback::
'Move turtle to an absolute position with changing orientation. GOTO 100 200'
goto(*parse(arg))
def do_home(self, arg):
- 'Return turtle to the home postion: HOME'
+ 'Return turtle to the home position: HOME'
home()
def do_circle(self, arg):
'Draw circle with given radius an options extent and steps: CIRCLE 50'
diff --git a/Doc/library/code.rst b/Doc/library/code.rst
index 5b5d7cc8c1..99bdedc065 100644
--- a/Doc/library/code.rst
+++ b/Doc/library/code.rst
@@ -4,6 +4,7 @@
.. module:: code
:synopsis: Facilities to implement read-eval-print loops.
+**Source code:** :source:`Lib/code.py`
The ``code`` module provides facilities to implement read-eval-print loops in
Python. Two classes and convenience functions are included which can be used to
@@ -165,4 +166,3 @@ interpreter objects as well as the following additions.
newline. When the user enters the EOF key sequence, :exc:`EOFError` is raised.
The base implementation reads from ``sys.stdin``; a subclass may replace this
with a different implementation.
-
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index fb3af3bf37..36144e9ef2 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -7,6 +7,7 @@
.. sectionauthor:: Marc-André Lemburg <mal@lemburg.com>
.. sectionauthor:: Martin v. Löwis <martin@v.loewis.de>
+**Source code:** :source:`Lib/codecs.py`
.. index::
single: Unicode
@@ -22,10 +23,9 @@ manages the codec and error handling lookup process.
It defines the following functions:
-.. function:: encode(obj, [encoding[, errors]])
+.. function:: encode(obj, encoding='utf-8', errors='strict')
- Encodes *obj* using the codec registered for *encoding*. The default
- encoding is ``utf-8``.
+ Encodes *obj* using the codec registered for *encoding*.
*Errors* may be given to set the desired error handling scheme. The
default error handler is ``strict`` meaning that encoding errors raise
@@ -33,10 +33,9 @@ It defines the following functions:
:exc:`UnicodeEncodeError`). Refer to :ref:`codec-base-classes` for more
information on codec error handling.
-.. function:: decode(obj, [encoding[, errors]])
+.. function:: decode(obj, encoding='utf-8', errors='strict')
- Decodes *obj* using the codec registered for *encoding*. The default
- encoding is ``utf-8``.
+ Decodes *obj* using the codec registered for *encoding*.
*Errors* may be given to set the desired error handling scheme. The
default error handler is ``strict`` meaning that decoding errors raise
@@ -1420,4 +1419,3 @@ This module implements a variant of the UTF-8 codec: On encoding a UTF-8 encoded
BOM will be prepended to the UTF-8 encoded bytes. For the stateful encoder this
is only done once (on the first write to the byte stream). For decoding an
optional UTF-8 encoded BOM at the start of the data will be skipped.
-
diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst
index 0bb26f938f..5f7888a27d 100644
--- a/Doc/library/collections.abc.rst
+++ b/Doc/library/collections.abc.rst
@@ -179,7 +179,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
(3)
The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash value
for the set; however, :meth:`__hash__` is not defined because not all sets
- are hashable or immutable. To add set hashabilty using mixins,
+ are hashable or immutable. To add set hashability using mixins,
inherit from both :meth:`Set` and :meth:`Hashable`, then define
``__hash__ = Set._hash``.
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index f5fe12a739..3ec3240795 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -978,12 +978,15 @@ The :class:`OrderedDict` constructor and :meth:`update` method both accept
keyword arguments, but their order is lost because Python's function call
semantics pass-in keyword arguments using a regular unordered dictionary.
+.. versionchanged:: 3.5
+ The items, keys, and values :term:`views <view>` of :class:`OrderedDict` now
+ support reverse iteration using :func:`reversed`.
:class:`OrderedDict` Examples and Recipes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Since an ordered dictionary remembers its insertion order, it can be used
-in conjuction with sorting to make a sorted dictionary::
+in conjunction with sorting to make a sorted dictionary::
>>> # regular unsorted dictionary
>>> d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2}
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
index 0495737e8b..08c926a6d4 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -175,6 +175,8 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
An :class:`Executor` subclass that executes calls asynchronously using a pool
of at most *max_workers* processes. If *max_workers* is ``None`` or not
given, it will default to the number of processors on the machine.
+ If *max_workers* is lower or equal to ``0``, then a :exc:`ValueError`
+ will be raised.
.. versionchanged:: 3.3
When one of the worker processes terminates abruptly, a
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 024d27cb84..4d65a821d7 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -11,6 +11,8 @@
.. sectionauthor:: Christopher G. Petrilli <petrilli@amber.org>
.. sectionauthor:: Łukasz Langa <lukasz@langa.pl>
+**Source code:** :source:`Lib/configparser.py`
+
.. index::
pair: .ini; file
pair: configuration; file
@@ -386,7 +388,7 @@ However, there are a few differences that should be taken into account:
* All sections include ``DEFAULTSECT`` values as well which means that
``.clear()`` on a section may not leave the section visibly empty. This is
because default values cannot be deleted from the section (because technically
- they are not there). If they are overriden in the section, deleting causes
+ they are not there). If they are overridden in the section, deleting causes
the default value to be visible again. Trying to delete a default value
causes a ``KeyError``.
@@ -667,7 +669,7 @@ the :meth:`__init__` options:
More advanced customization may be achieved by overriding default values of
these parser attributes. The defaults are defined on the classes, so they
-may be overriden by subclasses or by attribute assignment.
+may be overridden by subclasses or by attribute assignment.
.. attribute:: BOOLEAN_STATES
diff --git a/Doc/library/copyreg.rst b/Doc/library/copyreg.rst
index 50d5879ae5..18306c7f99 100644
--- a/Doc/library/copyreg.rst
+++ b/Doc/library/copyreg.rst
@@ -9,7 +9,7 @@
module: pickle
module: copy
-The :mod:`copyreg` module offers a way to define fuctions used while pickling
+The :mod:`copyreg` module offers a way to define functions used while pickling
specific objects. The :mod:`pickle` and :mod:`copy` modules use those functions
when pickling/copying those objects. The module provides configuration
information about object constructors which are not classes.
diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst
index ccc9dc6e4c..616df55ed0 100644
--- a/Doc/library/csv.rst
+++ b/Doc/library/csv.rst
@@ -5,6 +5,7 @@
:synopsis: Write and read tabular data to and from delimited files.
.. sectionauthor:: Skip Montanaro <skip@pobox.com>
+**Source code:** :source:`Lib/csv.py`
.. index::
single: csv
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index e1b9e108f6..a25d63ff00 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -7,6 +7,8 @@
.. sectionauthor:: Tim Peters <tim@zope.com>
.. sectionauthor:: A.M. Kuchling <amk@amk.ca>
+**Source code:** :source:`Lib/datetime.py`
+
.. XXX what order should the types be discussed in?
The :mod:`datetime` module supplies classes for manipulating dates and times in
@@ -1376,10 +1378,13 @@ Supported operations:
* efficient pickling
-* in Boolean contexts, a :class:`.time` object is considered to be true if and
- only if, after converting it to minutes and subtracting :meth:`utcoffset` (or
- ``0`` if that's ``None``), the result is non-zero.
+In boolean contexts, a :class:`.time` object is always considered to be true.
+.. versionchanged:: 3.5
+ Before Python 3.5, a :class:`.time` object was considered to be false if it
+ represented midnight in UTC. This behavior was considered obscure and
+ error-prone and has been removed in Python 3.5. See :issue:`13936` for full
+ details.
Instance methods:
diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
index e6a82d67ce..3f3c43d438 100644
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -325,13 +325,18 @@ The module defines the following:
dumbdbm database is created, files with :file:`.dat` and :file:`.dir` extensions
are created.
- The optional *flag* argument is currently ignored; the database is always opened
- for update, and will be created if it does not exist.
+ The optional *flag* argument supports only the semantics of ``'c'``
+ and ``'n'`` values. Other values will default to database being always
+ opened for update, and will be created if it does not exist.
The optional *mode* argument is the Unix mode of the file, used only when the
database has to be created. It defaults to octal ``0o666`` (and will be modified
by the prevailing umask).
+ .. versionchanged:: 3.5
+ :func:`.open` always creates a new database when the flag has the value
+ ``'n'``.
+
In addition to the methods provided by the
:class:`collections.abc.MutableMapping` class, :class:`dumbdbm` objects
provide the following methods:
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index 059ae7cb16..705298536b 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -12,6 +12,8 @@
.. moduleauthor:: Stefan Krah <skrah at bytereef.org>
.. sectionauthor:: Raymond D. Hettinger <python at rcn.com>
+**Source code:** :source:`Lib/decimal.py`
+
.. import modules for testing inline doctests with the Sphinx doctest builder
.. testsetup:: *
@@ -742,7 +744,7 @@ Decimal objects
* ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number).
* ``"sNaN"``, indicating that the operand is a signaling NaN.
- .. method:: quantize(exp, rounding=None, context=None, watchexp=True)
+ .. method:: quantize(exp, rounding=None, context=None)
Return a value equal to the first operand after rounding and having the
exponent of the second operand.
@@ -765,14 +767,8 @@ Decimal objects
``context`` argument; if neither argument is given the rounding mode of
the current thread's context is used.
- If *watchexp* is set (default), then an error is returned whenever the
- resulting exponent is greater than :attr:`Emax` or less than
- :attr:`Etiny`.
-
- .. deprecated:: 3.3
- *watchexp* is an implementation detail from the pure Python version
- and is not present in the C version. It will be removed in version
- 3.4, where it defaults to ``True``.
+ An error is returned whenever the resulting exponent is greater than
+ :attr:`Emax` or less than :attr:`Etiny`.
.. method:: radix()
@@ -2092,4 +2088,3 @@ Alternatively, inputs can be rounded upon creation using the
>>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678')
Decimal('1.2345')
-
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index 2a75d2cb15..707f179baa 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -7,6 +7,8 @@
.. sectionauthor:: Tim Peters <tim_one@users.sourceforge.net>
.. Markup by Fred L. Drake, Jr. <fdrake@acm.org>
+**Source code:** :source:`Lib/difflib.py`
+
.. testsetup::
import sys
@@ -25,7 +27,9 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
little fancier than, an algorithm published in the late 1980's by Ratcliff and
Obershelp under the hyperbolic name "gestalt pattern matching." The idea is to
find the longest contiguous matching subsequence that contains no "junk"
- elements (the Ratcliff and Obershelp algorithm doesn't address junk). The same
+ elements; these "junk" elements are ones that are uninteresting in some
+ sense, such as blank lines or whitespace. (Handling junk is an
+ extension to the Ratcliff and Obershelp algorithm.) The same
idea is then applied recursively to the pieces of the sequences to the left and
to the right of the matching subsequence. This does not yield minimal edit
sequences, but does tend to yield matches that "look right" to people.
@@ -208,7 +212,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
delta (a :term:`generator` generating the delta lines).
- Optional keyword parameters *linejunk* and *charjunk* are for filter functions
+ Optional keyword parameters *linejunk* and *charjunk* are filtering functions
(or ``None``):
*linejunk*: A function that accepts a single string argument, and returns
@@ -222,7 +226,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
*charjunk*: A function that accepts a character (a string of length 1), and
returns if the character is junk, or false if not. The default is module-level
function :func:`IS_CHARACTER_JUNK`, which filters out whitespace characters (a
- blank or tab; note: bad idea to include newline in this!).
+ blank or tab; it's a bad idea to include newline in this!).
:file:`Tools/scripts/ndiff.py` is a command-line front-end to this function.
@@ -622,6 +626,12 @@ The :class:`Differ` class has this constructor:
length 1), and returns true if the character is junk. The default is ``None``,
meaning that no character is considered junk.
+ These junk-filtering functions speed up matching to find
+ differences and do not cause any differing lines or characters to
+ be ignored. Read the description of the
+ :meth:`~SequenceMatcher.find_longest_match` method's *isjunk*
+ parameter for an explanation.
+
:class:`Differ` objects are used (deltas generated) via a single method:
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index d86550f182..fbabe35772 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -364,6 +364,11 @@ result back on the stack.
Implements ``TOS = TOS1 * TOS``.
+.. opcode:: BINARY_MATRIX_MULTIPLY
+
+ Implements ``TOS = TOS1 @ TOS``.
+
+
.. opcode:: BINARY_FLOOR_DIVIDE
Implements ``TOS = TOS1 // TOS``.
@@ -436,6 +441,11 @@ the original TOS1.
Implements in-place ``TOS = TOS1 * TOS``.
+.. opcode:: INPLACE_MATRIX_MULTIPLY
+
+ Implements in-place ``TOS = TOS1 @ TOS``.
+
+
.. opcode:: INPLACE_FLOOR_DIVIDE
Implements in-place ``TOS = TOS1 // TOS``.
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index 50626e9b0c..fb63fde3e4 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -1058,15 +1058,9 @@ from text files and modules with doctests:
This function uses the same search technique as :func:`testmod`.
- .. note::
- Unlike :func:`testmod` and :class:`DocTestFinder`, this function raises
- a :exc:`ValueError` if *module* contains no docstrings. You can prevent
- this error by passing a :class:`DocTestFinder` instance as the
- *test_finder* argument with its *exclude_empty* keyword argument set
- to ``False``::
-
- >>> finder = doctest.DocTestFinder(exclude_empty=False)
- >>> suite = doctest.DocTestSuite(test_finder=finder)
+ .. versionchanged:: 3.5
+ :func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if *module*
+ contains no docstrings instead of raising :exc:`ValueError`.
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
diff --git a/Doc/library/formatter.rst b/Doc/library/formatter.rst
index 1847a8094b..a515f74f64 100644
--- a/Doc/library/formatter.rst
+++ b/Doc/library/formatter.rst
@@ -5,7 +5,7 @@
:synopsis: Generic output formatter and device interface.
:deprecated:
-.. deprecated:: 3.4
+.. deprecated-removed:: 3.4 3.6
Due to lack of usage, the formatter module has been deprecated and is slated
for removal in Python 3.6.
diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst
index 4f1a682a87..2a41434094 100644
--- a/Doc/library/heapq.rst
+++ b/Doc/library/heapq.rst
@@ -81,7 +81,7 @@ The following functions are provided:
The module also offers three general purpose functions based on heaps.
-.. function:: merge(*iterables)
+.. function:: merge(*iterables, key=None, reverse=False)
Merge multiple sorted inputs into a single sorted output (for example, merge
timestamped entries from multiple log files). Returns an :term:`iterator`
@@ -91,6 +91,18 @@ The module also offers three general purpose functions based on heaps.
not pull the data into memory all at once, and assumes that each of the input
streams is already sorted (smallest to largest).
+ Has two optional arguments which must be specified as keyword arguments.
+
+ *key* specifies a :term:`key function` of one argument that is used to
+ extract a comparison key from each input element. The default value is
+ ``None`` (compare the elements directly).
+
+ *reverse* is a boolean value. If set to ``True``, then the input elements
+ are merged as if each comparison were reversed.
+
+ .. versionchanged:: 3.5
+ Added the optional *key* and *reverse* parameters.
+
.. function:: nlargest(n, iterable, key=None)
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst
index 0d8e7fe6c7..ec5464332e 100644
--- a/Doc/library/http.server.rst
+++ b/Doc/library/http.server.rst
@@ -220,7 +220,7 @@ of which this module provides three different variants:
.. method:: send_response_only(code, message=None)
- Sends the reponse header only, used for the purposes when ``100
+ Sends the response header only, used for the purposes when ``100
Continue`` response is sent by the server to the client. The headers not
buffered and sent directly the output stream.If the *message* is not
specified, the HTTP message corresponding the response *code* is sent.
diff --git a/Doc/library/imghdr.rst b/Doc/library/imghdr.rst
index 9e8952339c..c60df24c5a 100644
--- a/Doc/library/imghdr.rst
+++ b/Doc/library/imghdr.rst
@@ -48,6 +48,16 @@ from :func:`what`:
+------------+-----------------------------------+
| ``'png'`` | Portable Network Graphics |
+------------+-----------------------------------+
+| ``'webp'`` | WebP files |
++------------+-----------------------------------+
+| ``'exr'`` | OpenEXR Files |
++------------+-----------------------------------+
+
+.. versionadded:: 3.5
+ The *exr* format was added.
+
+.. versionchanged:: 3.5
+ The *webp* type was added.
You can extend the list of file types :mod:`imghdr` can recognize by appending
to this variable:
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 09a5d710b5..0ca84909a1 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -499,7 +499,7 @@ ABC hierarchy::
.. versionchanged:: 3.4
Raises :exc:`ImportError` instead of :exc:`NotImplementedError`.
- .. method:: source_to_code(data, path='<string>')
+ .. staticmethod:: source_to_code(data, path='<string>')
Create a code object from Python source.
@@ -508,8 +508,14 @@ ABC hierarchy::
the "path" to where the source code originated from, which can be an
abstract concept (e.g. location in a zip file).
+ With the subsequent code object one can execute it in a module by
+ running ``exec(code, module.__dict__)``.
+
.. versionadded:: 3.4
+ .. versionchanged:: 3.5
+ Made the method static.
+
.. method:: exec_module(module)
Implementation of :meth:`Loader.exec_module`.
@@ -1123,6 +1129,21 @@ an :term:`importer`.
.. versionadded:: 3.4
+.. function:: module_from_spec(spec)
+
+ Create a new module based on **spec**.
+
+ If the module object is from ``spec.loader.create_module()``, then any
+ pre-existing attributes will not be reset. Also, no :exc:`AttributeError`
+ will be raised if triggered while accessing **spec** or setting an attribute
+ on the module.
+
+ This function is preferred over using :class:`types.ModuleType` to create a
+ new module as **spec** is used to set as many import-controlled attributes on
+ the module as possible.
+
+ .. versionadded:: 3.5
+
.. decorator:: module_for_loader
A :term:`decorator` for :meth:`importlib.abc.Loader.load_module`
@@ -1201,3 +1222,38 @@ an :term:`importer`.
module will be file-based.
.. versionadded:: 3.4
+
+.. class:: LazyLoader(loader)
+
+ A class which postpones the execution of the loader of a module until the
+ module has an attribute accessed.
+
+ This class **only** works with loaders that define
+ :meth:`importlib.abc.Loader.exec_module` as control over what module type
+ is used for the module is required. For the same reasons, the loader
+ **cannot** define :meth:`importlib.abc.Loader.create_module`. Finally,
+ modules which substitute the object placed into :attr:`sys.modules` will
+ not work as there is no way to properly replace the module references
+ throughout the interpreter safely; :exc:`ValueError` is raised if such a
+ substitution is detected.
+
+ .. note::
+ For projects where startup time is critical, this class allows for
+ potentially minimizing the cost of loading a module if it is never used.
+ For projects where startup time is not essential then use of this class is
+ **heavily** discouraged due to error messages created during loading being
+ postponed and thus occurring out of context.
+
+ .. versionadded:: 3.5
+
+ .. classmethod:: factory(loader)
+
+ A static method which returns a callable that creates a lazy loader. This
+ is meant to be used in situations where the loader is passed by class
+ instead of by instance.
+ ::
+
+ suffixes = importlib.machinery.SOURCE_SUFFIXES
+ loader = importlib.machinery.SourceFileLoader
+ lazy_loader = importlib.util.LazyLoader.factory(loader)
+ finder = importlib.machinery.FileFinder(path, [(lazy_loader, suffixes)])
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 0c087123e8..359f83374a 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -159,6 +159,16 @@ attributes:
| | | arguments and local |
| | | variables |
+-----------+-----------------+---------------------------+
+| generator | __name__ | name |
++-----------+-----------------+---------------------------+
+| | __qualname__ | qualified name |
++-----------+-----------------+---------------------------+
+| | gi_frame | frame |
++-----------+-----------------+---------------------------+
+| | gi_running | is the generator running? |
++-----------+-----------------+---------------------------+
+| | gi_code | code |
++-----------+-----------------+---------------------------+
| builtin | __doc__ | documentation string |
+-----------+-----------------+---------------------------+
| | __name__ | original name of this |
@@ -169,6 +179,12 @@ attributes:
| | | ``None`` |
+-----------+-----------------+---------------------------+
+.. versionchanged:: 3.5
+
+ Add ``__qualname__`` attribute to generators. The ``__name__`` attribute of
+ generators is now set from the function name, instead of the code name, and
+ it can now be modified.
+
.. function:: getmembers(object[, predicate])
@@ -462,6 +478,9 @@ function.
Signature objects are *immutable*. Use :meth:`Signature.replace` to make a
modified copy.
+ .. versionchanged:: 3.5
+ Signature objects are picklable and hashable.
+
.. attribute:: Signature.empty
A special class-level marker to specify absence of a return annotation.
@@ -506,12 +525,29 @@ function.
>>> str(new_sig)
"(a, b) -> 'new return anno'"
+ .. classmethod:: Signature.from_callable(obj)
+
+ Return a :class:`Signature` (or its subclass) object for a given callable
+ ``obj``. This method simplifies subclassing of :class:`Signature`:
+
+ ::
+
+ class MySignature(Signature):
+ pass
+ sig = MySignature.from_callable(min)
+ assert isinstance(sig, MySignature)
+
+ .. versionadded:: 3.5
+
.. class:: Parameter(name, kind, \*, default=Parameter.empty, annotation=Parameter.empty)
Parameter objects are *immutable*. Instead of modifying a Parameter object,
you can use :meth:`Parameter.replace` to create a modified copy.
+ .. versionchanged:: 3.5
+ Parameter objects are picklable and hashable.
+
.. attribute:: Parameter.empty
A special class-level marker to specify absence of default values and
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 0c7d3c7f6b..03e3fd4437 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -391,8 +391,8 @@ I/O Base Classes
.. method:: readinto(b)
Read up to ``len(b)`` bytes into :class:`bytearray` *b* and return the
- number of bytes read. If the object is in non-blocking mode and no
- bytes are available, ``None`` is returned.
+ number of bytes read. If the object is in non-blocking mode and no bytes
+ are available, ``None`` is returned.
.. method:: write(b)
@@ -465,9 +465,10 @@ I/O Base Classes
.. method:: read1(size=-1)
- Read and return up to *size* bytes, with at most one call to the underlying
- raw stream's :meth:`~RawIOBase.read` method. This can be useful if you
- are implementing your own buffering on top of a :class:`BufferedIOBase`
+ Read and return up to *size* bytes, with at most one call to the
+ underlying raw stream's :meth:`~RawIOBase.read` (or
+ :meth:`~RawIOBase.readinto`) method. This can be useful if you are
+ implementing your own buffering on top of a :class:`BufferedIOBase`
object.
.. method:: readinto(b)
@@ -478,8 +479,19 @@ I/O Base Classes
Like :meth:`read`, multiple reads may be issued to the underlying raw
stream, unless the latter is interactive.
- A :exc:`BlockingIOError` is raised if the underlying raw stream is in
- non blocking-mode, and has no data available at the moment.
+ A :exc:`BlockingIOError` is raised if the underlying raw stream is in non
+ blocking-mode, and has no data available at the moment.
+
+ .. method:: readinto1(b)
+
+ Read up to ``len(b)`` bytes into bytearray *b*, ,using at most one call to
+ the underlying raw stream's :meth:`~RawIOBase.read` (or
+ :meth:`~RawIOBase.readinto`) method. Return the number of bytes read.
+
+ A :exc:`BlockingIOError` is raised if the underlying raw stream is in non
+ blocking-mode, and has no data available at the moment.
+
+ .. versionadded:: 3.5
.. method:: write(b)
@@ -596,6 +608,11 @@ than raw I/O does.
In :class:`BytesIO`, this is the same as :meth:`read`.
+ .. method:: readinto1()
+
+ In :class:`BytesIO`, this is the same as :meth:`readinto`.
+
+ .. versionadded:: 3.5
.. class:: BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst
index 9625e71b04..d48fac95f4 100644
--- a/Doc/library/ipaddress.rst
+++ b/Doc/library/ipaddress.rst
@@ -103,7 +103,7 @@ write code that handles both IP versions correctly.
1. A string in decimal-dot notation, consisting of four decimal integers in
the inclusive range 0-255, separated by dots (e.g. ``192.168.0.1``). Each
integer represents an octet (byte) in the address. Leading zeroes are
- tolerated only for values less then 8 (as there is no ambiguity
+ tolerated only for values less than 8 (as there is no ambiguity
between the decimal and octal interpretations of such strings).
2. An integer that fits into 32 bits.
3. An integer packed into a :class:`bytes` object of length 4 (most
@@ -146,6 +146,20 @@ write code that handles both IP versions correctly.
the appropriate length (most significant octet first). This is 4 bytes
for IPv4 and 16 bytes for IPv6.
+ .. attribute:: reverse_pointer
+
+ The name of the reverse DNS PTR record for the IP address, e.g.::
+
+ >>> ipaddress.ip_address("127.0.0.1").reverse_pointer
+ '1.0.0.127.in-addr.arpa'
+ >>> ipaddress.ip_address("2001:db8::1").reverse_pointer
+ '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
+
+ This is the name that could be used for performing a PTR lookup, not the
+ resolved hostname itself.
+
+ .. versionadded:: 3.5
+
.. attribute:: is_multicast
``True`` if the address is reserved for multicast use. See
@@ -226,6 +240,7 @@ write code that handles both IP versions correctly.
:class:`IPv4Address` class:
.. attribute:: packed
+ .. attribute:: reverse_pointer
.. attribute:: version
.. attribute:: max_prefixlen
.. attribute:: is_multicast
@@ -377,6 +392,12 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
3. An integer packed into a :class:`bytes` object of length 4, big-endian.
The interpretation is similar to an integer *address*.
+ 4. A two-tuple of an address description and a netmask, where the address
+ description is either a string, a 32-bits integer, a 4-bytes packed
+ integer, or an existing IPv4Address object; and the netmask is either
+ an integer representing the prefix length (e.g. ``24``) or a string
+ representing the prefix mask (e.g. ``255.255.255.0``).
+
An :exc:`AddressValueError` is raised if *address* is not a valid IPv4
address. A :exc:`NetmaskValueError` is raised if the mask is not valid for
an IPv4 address.
@@ -389,6 +410,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
objects will raise :exc:`TypeError` if the argument's IP version is
incompatible to ``self``
+ .. versionchanged:: 3.5
+
+ Added the two-tuple form for the *address* constructor parameter.
+
.. attribute:: version
.. attribute:: max_prefixlen
@@ -553,6 +578,11 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
3. An integer packed into a :class:`bytes` object of length 16, bit-endian.
The interpretation is similar to an integer *address*.
+ 4. A two-tuple of an address description and a netmask, where the address
+ description is either a string, a 128-bits integer, a 16-bytes packed
+ integer, or an existing IPv4Address object; and the netmask is an
+ integer representing the prefix length.
+
An :exc:`AddressValueError` is raised if *address* is not a valid IPv6
address. A :exc:`NetmaskValueError` is raised if the mask is not valid for
an IPv6 address.
@@ -561,6 +591,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
then :exc:`ValueError` is raised. Otherwise, the host bits are masked out
to determine the appropriate network address.
+ .. versionchanged:: 3.5
+
+ Added the two-tuple form for the *address* constructor parameter.
+
.. attribute:: version
.. attribute:: max_prefixlen
.. attribute:: is_multicast
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index f489535c53..c5ba2eb596 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -87,10 +87,15 @@ loops that truncate the stream.
.. function:: accumulate(iterable[, func])
- Make an iterator that returns accumulated sums. Elements may be any addable
- type including :class:`~decimal.Decimal` or :class:`~fractions.Fraction`.
- If the optional *func* argument is supplied, it should be a function of two
- arguments and it will be used instead of addition.
+ Make an iterator that returns accumulated sums, or accumulated
+ results of other binary functions (specified via the optional
+ *func* argument). If *func* is supplied, it should be a function
+ of two arguments. Elements of the input *iterable* may be any type
+ that can be accepted as arguments to *func*. (For example, with
+ the default operation of addition, elements may be any addable
+ type including :class:`~decimal.Decimal` or
+ :class:`~fractions.Fraction`.) If the input iterable is empty, the
+ output iterable will also be empty.
Equivalent to::
@@ -657,6 +662,11 @@ which incur interpreter overhead.
"Return function(0), function(1), ..."
return map(function, count(start))
+ def tail(n, iterable):
+ "Return an iterator over the last n items"
+ # tail(3, 'ABCDEFG') --> E F G
+ return iter(collections.deque(iterable, maxlen=n))
+
def consume(iterator, n):
"Advance the iterator n-steps ahead. If n is none, consume entirely."
# Use functions that consume iterators at C speed.
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 5d97ee88fc..d6bdd8a4f8 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -104,6 +104,8 @@ Using json.tool from the shell to validate and pretty-print::
$ echo '{1.2:3.4}' | python -mjson.tool
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
+See :ref:`json-commandline` for detailed documentation.
+
.. highlight:: python3
.. note::
@@ -563,3 +565,54 @@ the last name-value pair for a given name::
{'x': 3}
The *object_pairs_hook* parameter can be used to alter this behavior.
+
+.. highlight:: bash
+
+.. _json-commandline:
+
+Command Line Interface
+----------------------
+
+The :mod:`json.tool` module provides a simple command line interface to validate
+and pretty-print JSON objects.
+
+If the optional :option:`infile` and :option:`outfile` arguments are not
+specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively::
+
+ $ echo '{"json": "obj"}' | python -m json.tool
+ {
+ "json": "obj"
+ }
+ $ echo '{1.2:3.4}' | python -m json.tool
+ Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
+
+
+Command line options
+^^^^^^^^^^^^^^^^^^^^
+
+.. cmdoption:: infile
+
+ The JSON file to be validated or pretty-printed::
+
+ $ python -m json.tool mp_films.json
+ [
+ {
+ "title": "And Now for Something Completely Different",
+ "year": 1971
+ },
+ {
+ "title": "Monty Python and the Holy Grail",
+ "year": 1975
+ }
+ ]
+
+ If *infile* is not specified, read from :attr:`sys.stdin`.
+
+.. cmdoption:: outfile
+
+ Write the output of the *infile* to the given *outfile*. Otherwise, write it
+ to :attr:`sys.stdout`.
+
+.. cmdoption:: -h, --help
+
+ Show the help message.
diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst
index a2b14de1b0..8c6d24b168 100644
--- a/Doc/library/logging.handlers.rst
+++ b/Doc/library/logging.handlers.rst
@@ -435,7 +435,7 @@ sends logging output to a network socket. The base class uses a TCP socket.
.. method:: createSocket()
Tries to create a socket; on failure, uses an exponential back-off
- algorithm. On intial failure, the handler will drop the message it was
+ algorithm. On initial failure, the handler will drop the message it was
trying to send. When subsequent messages are handled by the same
instance, it will not try connecting until some time has passed. The
default parameters are such that the initial delay is one second, and if
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 276339842c..243b10129a 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -1322,6 +1322,9 @@ processes.
Note that accessing the ctypes object through the wrapper can be a lot slower
than accessing the raw ctypes object.
+ .. versionchanged:: 3.5
+ Synchronized objects support the :term:`context manager` protocol.
+
The table below compares the syntax for creating shared ctypes objects from
shared memory with the normal ctypes syntax. (In the table ``MyStruct`` is some
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index 3bcbaa4b86..3654d133a8 100644
--- a/Doc/library/operator.rst
+++ b/Doc/library/operator.rst
@@ -138,6 +138,14 @@ The mathematical and bitwise operations are the most numerous:
Return ``a * b``, for *a* and *b* numbers.
+.. function:: matmul(a, b)
+ __matmul__(a, b)
+
+ Return ``a @ b``.
+
+ .. versionadded:: 3.5
+
+
.. function:: neg(obj)
__neg__(obj)
@@ -400,6 +408,8 @@ Python syntax and the functions in the :mod:`operator` module.
+-----------------------+-------------------------+---------------------------------------+
| Multiplication | ``a * b`` | ``mul(a, b)`` |
+-----------------------+-------------------------+---------------------------------------+
+| Matrix Multiplication | ``a @ b`` | ``matmul(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
| Negation (Arithmetic) | ``- a`` | ``neg(a)`` |
+-----------------------+-------------------------+---------------------------------------+
| Negation (Logical) | ``not a`` | ``not_(a)`` |
@@ -508,6 +518,14 @@ will perform the update, so no subsequent assignment is necessary:
``a = imul(a, b)`` is equivalent to ``a *= b``.
+.. function:: imatmul(a, b)
+ __imatmul__(a, b)
+
+ ``a = imatmul(a, b)`` is equivalent to ``a @= b``.
+
+ .. versionadded:: 3.5
+
+
.. function:: ior(a, b)
__ior__(a, b)
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 36dfc89146..9752fb3d1c 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1088,8 +1088,16 @@ or `the MSDN <http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Window
All platforms support sockets as *out* file descriptor, and some platforms
allow other types (e.g. regular file, pipe) as well.
+ Cross-platform applications should not use *headers*, *trailers* and *flags*
+ arguments.
+
Availability: Unix.
+ .. note::
+
+ For a higher-level wrapper of :func:`sendfile`, see
+ :mod:`socket.socket.sendfile`.
+
.. versionadded:: 3.3
@@ -1891,6 +1899,11 @@ features:
* :attr:`st_gen` - file generation number
* :attr:`st_birthtime` - time of file creation
+ On Windows systems, the following attribute is also available:
+
+ * :attr:`st_file_attributes` - Windows file attribute bits (see the
+ ``FILE_ATTRIBUTE_*`` constants in the :mod:`stat` module)
+
.. note::
The exact meaning and resolution of the :attr:`st_atime`,
@@ -1944,6 +1957,9 @@ features:
and the :attr:`st_atime_ns`, :attr:`st_mtime_ns`,
and :attr:`st_ctime_ns` members.
+ .. versionadded:: 3.5
+ Added the :attr:`st_file_attributes` member on Windows.
+
.. function:: stat_float_times([newvalue])
@@ -2727,10 +2743,27 @@ written in Python, such as a mail server's external command delivery program.
Availability: Unix.
-.. function:: popen(...)
+.. function:: popen(command, mode='r', buffering=-1)
+
+ Open a pipe to or from *command*. The return value is an open file object
+ connected to the pipe, which can be read or written depending on whether *mode*
+ is ``'r'`` (default) or ``'w'``. The *buffering* argument has the same meaning as
+ the corresponding argument to the built-in :func:`open` function. The
+ returned file object reads or writes text strings rather than bytes.
+
+ The ``close`` method returns :const:`None` if the subprocess exited
+ successfully, or the subprocess's return code if there was an
+ error. On POSIX systems, if the return code is positive it
+ represents the return value of the process left-shifted by one
+ byte. If the return code is negative, the process was terminated
+ by the signal given by the negated value of the return code. (For
+ example, the return value might be ``- signal.SIGKILL`` if the
+ subprocess was killed.) On Windows systems, the return value
+ contains the signed integer return code from the child process.
- Run child processes, returning opened pipes for communications. These functions
- are described in section :ref:`os-newstreams`.
+ This is implemented using :class:`subprocess.Popen`; see that class's
+ documentation for more powerful ways to manage and communicate with
+ subprocesses.
.. function:: spawnl(mode, path, ...)
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index ec1dc4f616..0a2a4e3be0 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -884,6 +884,25 @@ call fails (for example because the path doesn't exist):
Remove this directory. The directory must be empty.
+.. method:: Path.samefile(other_path)
+
+ Return whether this path points to the same file as *other_path*, which
+ can be either a Path object, or a string. The semantics are similar
+ to :func:`os.path.samefile` and :func:`os.path.samestat`.
+
+ An :exc:`OSError` can be raised if either file cannot be accessed for some
+ reason.
+
+ >>> p = Path('spam')
+ >>> q = Path('eggs')
+ >>> p.samefile(q)
+ False
+ >>> p.samefile('spam')
+ True
+
+ .. versionadded:: 3.5
+
+
.. method:: Path.symlink_to(target, target_is_directory=False)
Make this path a symbolic link to *target*. Under Windows,
diff --git a/Doc/library/pkgutil.rst b/Doc/library/pkgutil.rst
index 13ea7b9b33..5d3295db7e 100644
--- a/Doc/library/pkgutil.rst
+++ b/Doc/library/pkgutil.rst
@@ -58,7 +58,7 @@ support.
.. deprecated:: 3.3
This emulation is no longer needed, as the standard import mechanism
- is now fully PEP 302 compliant and available in :mod:`importlib`
+ is now fully PEP 302 compliant and available in :mod:`importlib`.
.. class:: ImpLoader(fullname, file, filename, etc)
@@ -67,7 +67,7 @@ support.
.. deprecated:: 3.3
This emulation is no longer needed, as the standard import mechanism
- is now fully PEP 302 compliant and available in :mod:`importlib`
+ is now fully PEP 302 compliant and available in :mod:`importlib`.
.. function:: find_loader(fullname)
diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst
index 6a2d6b4971..b0d5bcf105 100644
--- a/Doc/library/plistlib.rst
+++ b/Doc/library/plistlib.rst
@@ -129,7 +129,7 @@ The following functions are deprecated:
and binary) file object. Returns the unpacked root object (which usually
is a dictionary).
- This function calls :func:`load` to do the actual work, the the documentation
+ This function calls :func:`load` to do the actual work, see the documentation
of :func:`that function <load>` for an explanation of the keyword arguments.
.. note::
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 11dd367f8a..f8b772749f 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -46,8 +46,7 @@ from sources provided by the operating system.
.. warning::
The pseudo-random generators of this module should not be used for
- security purposes. Use :func:`os.urandom` or :class:`SystemRandom` if
- you require a cryptographically secure pseudo-random number generator.
+ security purposes.
Bookkeeping functions:
diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst
index f8112cc0e4..7c0e4caf75 100644
--- a/Doc/library/resource.rst
+++ b/Doc/library/resource.rst
@@ -45,7 +45,7 @@ this module for those platforms.
.. data:: RLIM_INFINITY
- Constant used to represent the the limit for an unlimited resource.
+ Constant used to represent the limit for an unlimited resource.
.. function:: getrlimit(resource)
diff --git a/Doc/library/select.rst b/Doc/library/select.rst
index 973a0cc7d6..a5e0c133e9 100644
--- a/Doc/library/select.rst
+++ b/Doc/library/select.rst
@@ -210,7 +210,7 @@ object.
.. warning::
Registering a file descriptor that's already registered is not an
- error, but the result is undefined. The appropiate action is to
+ error, but the result is undefined. The appropriate action is to
unregister or modify it first. This is an important difference
compared with :c:func:`poll`.
diff --git a/Doc/library/selectors.rst b/Doc/library/selectors.rst
index 98377c890f..8bd9e1ce2e 100644
--- a/Doc/library/selectors.rst
+++ b/Doc/library/selectors.rst
@@ -45,6 +45,7 @@ Classes hierarchy::
+-- SelectSelector
+-- PollSelector
+-- EpollSelector
+ +-- DevpollSelector
+-- KqueueSelector
@@ -207,6 +208,16 @@ below:
This returns the file descriptor used by the underlying
:func:`select.epoll` object.
+.. class:: DevpollSelector()
+
+ :func:`select.devpoll`-based selector.
+
+ .. method:: fileno()
+
+ This returns the file descriptor used by the underlying
+ :func:`select.devpoll` object.
+
+ .. versionadded:: 3.5
.. class:: KqueueSelector()
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index e4f348cd82..7a623677d3 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -191,7 +191,8 @@ Directory and files operations
match one of the glob-style *patterns* provided. See the example below.
-.. function:: copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False)
+.. function:: copytree(src, dst, symlinks=False, ignore=None, \
+ copy_function=copy2, ignore_dangling_symlinks=False)
Recursively copy an entire directory tree rooted at *src*, returning the
destination directory. The destination
@@ -282,7 +283,7 @@ Directory and files operations
.. versionadded:: 3.3
-.. function:: move(src, dst)
+.. function:: move(src, dst, copy_function=copy2)
Recursively move a file or directory (*src*) to another location (*dst*)
and return the destination.
@@ -295,15 +296,26 @@ Directory and files operations
:func:`os.rename` semantics.
If the destination is on the current filesystem, then :func:`os.rename` is
- used. Otherwise, *src* is copied (using :func:`shutil.copy2`) to *dst* and
- then removed. In case of symlinks, a new symlink pointing to the target of
- *src* will be created in or as *dst* and *src* will be removed.
+ used. Otherwise, *src* is copied to *dst* using *copy_function* and then
+ removed. In case of symlinks, a new symlink pointing to the target of *src*
+ will be created in or as *dst* and *src* will be removed.
+
+ If *copy_function* is given, it must be a callable that takes two arguments
+ *src* and *dst*, and will be used to copy *src* to *dest* if
+ :func:`os.rename` cannot be used. If the source is a directory,
+ :func:`copytree` is called, passing it the :func:`copy_function`. The
+ default *copy_function* is :func:`copy2`. Using :func:`copy` as the
+ *copy_function* allows the move to succeed when it is not possible to also
+ copy the metadata, at the expense of not copying any of the metadata.
.. versionchanged:: 3.3
Added explicit symlink handling for foreign filesystems, thus adapting
it to the behavior of GNU's :program:`mv`.
Now returns *dst*.
+ .. versionchanged:: 3.5
+ Added the *copy_function* keyword argument.
+
.. function:: disk_usage(path)
Return disk usage statistics about the given path as a :term:`named tuple`
@@ -341,7 +353,7 @@ Directory and files operations
On Windows, the current directory is always prepended to the *path* whether
or not you use the default or provide your own, which is the behavior the
- command shell uses when finding executables. Additionaly, when finding the
+ command shell uses when finding executables. Additionally, when finding the
*cmd* in the *path*, the ``PATHEXT`` environment variable is checked. For
example, if you call ``shutil.which("python")``, :func:`which` will search
``PATHEXT`` to know that it should look for ``python.exe`` within the *path*
@@ -421,6 +433,26 @@ Another example that uses the *ignore* argument to add a logging call::
copytree(source, destination, ignore=_logpath)
+.. _shutil-rmtree-example:
+
+rmtree example
+~~~~~~~~~~~~~~
+
+This example shows how to remove a directory tree on Windows where some
+of the files have their read-only bit set. It uses the onerror callback
+to clear the readonly bit and reattempt the remove. Any subsequent failure
+will propagate. ::
+
+ import os, stat
+ import shutil
+
+ def remove_readonly(func, path, _):
+ "Clear the readonly bit and reattempt the removal"
+ os.chmod(path, stat.S_IWRITE)
+ func(path)
+
+ shutil.rmtree(directory, onerror=remove_readonly)
+
.. _archiving-operations:
Archiving operations
diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst
index 84e283683d..a97ce66ef5 100644
--- a/Doc/library/signal.rst
+++ b/Doc/library/signal.rst
@@ -65,6 +65,16 @@ Besides, only the main thread is allowed to set a new signal handler.
Module contents
---------------
+.. versionchanged:: 3.5
+ signal (SIG*), handler (:const:`SIG_DFL`, :const:`SIG_IGN`) and sigmask
+ (:const:`SIG_BLOCK`, :const:`SIG_UNBLOCK`, :const:`SIG_SETMASK`)
+ related constants listed below were turned into
+ :class:`enums <enum.IntEnum>`.
+ :func:`getsignal`, :func:`pthread_sigmask`, :func:`sigpending` and
+ :func:`sigwait` functions return human-readable
+ :class:`enums <enum.IntEnum>`.
+
+
The variables defined in the :mod:`signal` module are:
diff --git a/Doc/library/site.rst b/Doc/library/site.rst
index e57b8ccc2d..43daf790b7 100644
--- a/Doc/library/site.rst
+++ b/Doc/library/site.rst
@@ -26,24 +26,23 @@ additions, call the :func:`site.main` function.
:option:`-S`.
.. index::
- pair: site-python; directory
pair: site-packages; directory
It starts by constructing up to four directories from a head and a tail part.
For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads
are skipped. For the tail part, it uses the empty string and then
:file:`lib/site-packages` (on Windows) or
-:file:`lib/python{X.Y}/site-packages` and then :file:`lib/site-python` (on
-Unix and Macintosh). For each of the distinct head-tail combinations, it sees
-if it refers to an existing directory, and if so, adds it to ``sys.path`` and
-also inspects the newly added path for configuration files.
+:file:`lib/python{X.Y}/site-packages` (on Unix and Macintosh). For each
+of the distinct head-tail combinations, it sees if it refers to an existing
+directory, and if so, adds it to ``sys.path`` and also inspects the newly
+added path for configuration files.
-.. deprecated:: 3.4
- Support for the "site-python" directory will be removed in 3.5.
+.. versionchanged:: 3.5
+ Support for the "site-python" directory has been removed.
If a file named "pyvenv.cfg" exists one directory above sys.executable,
sys.prefix and sys.exec_prefix are set to that directory and
-it is also checked for site-packages and site-python (sys.base_prefix and
+it is also checked for site-packages (sys.base_prefix and
sys.base_exec_prefix will always be the "real" prefixes of the Python
installation). If "pyvenv.cfg" (a bootstrap configuration file) contains
the key "include-system-site-packages" set to anything other than "false"
@@ -184,7 +183,7 @@ Module contents
unless the Python interpreter was started with the :option:`-S` flag.
.. versionchanged:: 3.3
- This function used to be called unconditionnally.
+ This function used to be called unconditionally.
.. function:: addsitedir(sitedir, known_paths=None)
@@ -195,8 +194,7 @@ Module contents
.. function:: getsitepackages()
- Return a list containing all global site-packages directories (and possibly
- site-python).
+ Return a list containing all global site-packages directories.
.. versionadded:: 3.2
diff --git a/Doc/library/smtpd.rst b/Doc/library/smtpd.rst
index 3ebed06260..0f4a0bf512 100644
--- a/Doc/library/smtpd.rst
+++ b/Doc/library/smtpd.rst
@@ -28,7 +28,7 @@ SMTPServer Objects
.. class:: SMTPServer(localaddr, remoteaddr, data_size_limit=33554432,\
- map=None)
+ map=None, decode_data=True)
Create a new :class:`SMTPServer` object, which binds to local address
*localaddr*. It will treat *remoteaddr* as an upstream SMTP relayer. It
@@ -41,6 +41,11 @@ SMTPServer Objects
A dictionary can be specified in *map* to avoid using a global socket map.
+ *decode_data* specifies whether the data portion of the SMTP transaction
+ should be decoded using UTF-8. The default is ``True`` for backward
+ compatibility reasons, but will change to ``False`` in Python 3.6. Specify
+ the keyword value explicitly to avoid the :exc:`DeprecationWarning`.
+
.. method:: process_message(peer, mailfrom, rcpttos, data)
Raise :exc:`NotImplementedError` exception. Override this in subclasses to
@@ -51,6 +56,10 @@ SMTPServer Objects
containing the contents of the e-mail (which should be in :rfc:`2822`
format).
+ If the *decode_data* constructor keyword is set to ``True``, the *data*
+ argument will be a unicode string. If it is set to ``False``, it
+ will be a bytes object.
+
.. attribute:: channel_class
Override this in subclasses to use a custom :class:`SMTPChannel` for
@@ -59,6 +68,9 @@ SMTPServer Objects
.. versionchanged:: 3.4
The *map* argument was added.
+ .. versionchanged:: 3.5 the *decode_data* argument was added, and *localaddr*
+ and *remoteaddr* may now contain IPv6 addresses.
+
DebuggingServer Objects
-----------------------
@@ -97,7 +109,7 @@ SMTPChannel Objects
-------------------
.. class:: SMTPChannel(server, conn, addr, data_size_limit=33554432,\
- map=None))
+ map=None, decode_data=True)
Create a new :class:`SMTPChannel` object which manages the communication
between the server and a single SMTP client.
@@ -110,9 +122,17 @@ SMTPChannel Objects
A dictionary can be specified in *map* to avoid using a global socket map.
+ *decode_data* specifies whether the data portion of the SMTP transaction
+ should be decoded using UTF-8. The default is ``True`` for backward
+ compatibility reasons, but will change to ``False`` in Python 3.6. Specify
+ the keyword value explicitly to avoid the :exc:`DeprecationWarning`.
+
To use a custom SMTPChannel implementation you need to override the
:attr:`SMTPServer.channel_class` of your :class:`SMTPServer`.
+ .. versionchanged:: 3.5
+ the *decode_data* argument was added.
+
The :class:`SMTPChannel` has the following instance variables:
.. attribute:: smtp_server
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst
index 8e1bfb57f9..74de77b94e 100644
--- a/Doc/library/smtplib.rst
+++ b/Doc/library/smtplib.rst
@@ -240,8 +240,7 @@ An :class:`SMTP` instance has the following methods:
the server is stored as the :attr:`ehlo_resp` attribute, :attr:`does_esmtp`
is set to true or false depending on whether the server supports ESMTP, and
:attr:`esmtp_features` will be a dictionary containing the names of the
- SMTP service extensions this server supports, and their
- parameters (if any).
+ SMTP service extensions this server supports, and their parameters (if any).
Unless you wish to use :meth:`has_extn` before sending mail, it should not be
necessary to call this method explicitly. It will be implicitly called by
@@ -291,6 +290,42 @@ An :class:`SMTP` instance has the following methods:
:exc:`SMTPException`
No suitable authentication method was found.
+ Each of the authentication methods supported by :mod:`smtplib` are tried in
+ turn if they are advertised as supported by the server (see :meth:`auth`
+ for a list of supported authentication methods).
+
+
+.. method:: SMTP.auth(mechanism, authobject)
+
+ Issue an ``SMTP`` ``AUTH`` command for the specified authentication
+ *mechanism*, and handle the challenge response via *authobject*.
+
+ *mechanism* specifies which authentication mechanism is to
+ be used as argument to the ``AUTH`` command; the valid values are
+ those listed in the ``auth`` element of :attr:`esmtp_features`.
+
+ *authobject* must be a callable object taking a single argument:
+
+ data = authobject(challenge)
+
+ It will be called to process the server's challenge response; the
+ *challenge* argument it is passed will be a ``bytes``. It should return
+ ``bytes`` *data* that will be base64 encoded and sent to the server.
+
+ The ``SMTP`` class provides ``authobjects`` for the ``CRAM-MD5``, ``PLAIN``,
+ and ``LOGIN`` mechanisms; they are named ``SMTP.auth_cram_md5``,
+ ``SMTP.auth_plain``, and ``SMTP.auth_login`` respectively. They all require
+ that the ``user`` and ``password`` properties of the ``SMTP`` instance are
+ set to appropriate values.
+
+ User code does not normally need to call ``auth`` directly, but can instead
+ call the :meth:`login` method, which will try each of the above mechanisms in
+ turn, in the order listed. ``auth`` is exposed to facilitate the
+ implementation of authentication methods not (or not yet) supported directly
+ by :mod:`smtplib`.
+
+ .. versionadded:: 3.5
+
.. method:: SMTP.starttls(keyfile=None, certfile=None, context=None)
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 54c6badb13..ceeb776795 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -906,12 +906,15 @@ to sockets.
On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl`
functions may be used; they accept a socket object as their first argument.
-.. method:: socket.listen(backlog)
+.. method:: socket.listen([backlog])
- Listen for connections made to the socket. The *backlog* argument specifies the
- maximum number of queued connections and should be at least 0; the maximum value
- is system-dependent (usually 5), the minimum value is forced to 0.
+ Enable a server to accept connections. If *backlog* is specified, it must
+ be at least 0 (if it is lower, it is set to 0); it specifies the number of
+ unaccepted connections that the system will allow before refusing new
+ connections. If not specified, a default reasonable value is chosen.
+ .. versionchanged:: 3.5
+ The *backlog* parameter is now optional.
.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, \
errors=None, newline=None)
@@ -1145,6 +1148,21 @@ to sockets.
.. versionadded:: 3.3
+.. method:: socket.sendfile(file, offset=0, count=None)
+
+ Send a file until EOF is reached by using high-performance
+ :mod:`os.sendfile` and return the total number of bytes which were sent.
+ *file* must be a regular file object opened in binary mode. If
+ :mod:`os.sendfile` is not available (e.g. Windows) or *file* is not a
+ regular file :meth:`send` will be used instead. *offset* tells from where to
+ start reading the file. If specified, *count* is the total number of bytes
+ to transmit as opposed to sending the file until EOF is reached. File
+ position is updated on return or also in case of error in which case
+ :meth:`file.tell() <io.IOBase.tell>` can be used to figure out the number of
+ bytes which were sent. The socket must be of :const:`SOCK_STREAM` type. Non-
+ blocking sockets are not supported.
+
+ .. versionadded:: 3.5
.. method:: socket.set_inheritable(inheritable)
@@ -1444,7 +1462,7 @@ After binding (:const:`CAN_RAW`) or connecting (:const:`CAN_BCM`) the socket, yo
can use the :meth:`socket.send`, and the :meth:`socket.recv` operations (and
their counterparts) on the socket object as usual.
-This example might require special priviledge::
+This example might require special privileges::
import socket
import struct
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index 1ec44389bf..9db36d5510 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -113,7 +113,7 @@ the request handler class :meth:`handle` method.
Another approach to handling multiple simultaneous requests in an environment
that supports neither threads nor :func:`~os.fork` (or where these are too
expensive or inappropriate for the service) is to maintain an explicit table of
-partially finished requests and to use :func:`~select.select` to decide which
+partially finished requests and to use :mod:`selectors` to decide which
request to work on next (or whether to handle a new incoming request). This is
particularly important for stream services where each client can potentially be
connected for a long time (if threads or subprocesses cannot be used). See
@@ -136,7 +136,7 @@ Server Objects
.. method:: BaseServer.fileno()
Return an integer file descriptor for the socket on which the server is
- listening. This function is most commonly passed to :func:`select.select`, to
+ listening. This function is most commonly passed to :mod:`selectors`, to
allow monitoring multiple servers in the same process.
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index b473c45a4b..75b5d28e9e 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -372,22 +372,34 @@ Certificate handling
IDN A-labels such as ``www*.xn--pthon-kva.org`` are still supported,
but ``x*.python.org`` no longer matches ``xn--tda.python.org``.
-.. function:: cert_time_to_seconds(timestring)
+.. function:: cert_time_to_seconds(cert_time)
- Returns a floating-point value containing a normal seconds-after-the-epoch
- time value, given the time-string representing the "notBefore" or "notAfter"
- date from a certificate.
+ Return the time in seconds since the Epoch, given the ``cert_time``
+ string representing the "notBefore" or "notAfter" date from a
+ certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C
+ locale).
- Here's an example::
+ Here's an example:
- >>> import ssl
- >>> ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT")
- 1178694000.0
- >>> import time
- >>> time.ctime(ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT"))
- 'Wed May 9 00:00:00 2007'
+ .. doctest:: newcontext
-.. function:: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None)
+ >>> import ssl
+ >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT")
+ >>> timestamp
+ 1515144883
+ >>> from datetime import datetime
+ >>> print(datetime.utcfromtimestamp(timestamp))
+ 2018-01-05 09:34:43
+
+ "notBefore" or "notAfter" dates must use GMT (:rfc:`5280`).
+
+ .. versionchanged:: 3.5
+ Interpret the input time as a time in UTC as specified by 'GMT'
+ timezone in the input string. Local timezone was used
+ previously. Return an integer (no fractions of a second in the
+ input format)
+
+.. function:: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None)
Given the address ``addr`` of an SSL-protected server, as a (*hostname*,
*port-number*) pair, fetches the server's certificate, and returns it as a
@@ -401,6 +413,10 @@ Certificate handling
.. versionchanged:: 3.3
This function is now IPv6-compatible.
+ .. versionchanged:: 3.5
+ The default *ssl_version* is changed from :data:`PROTOCOL_SSLv3` to
+ :data:`PROTOCOL_SSLv23` for maximum compatibility with modern servers.
+
.. function:: DER_cert_to_PEM_cert(DER_cert_bytes)
Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
@@ -773,6 +789,11 @@ SSL sockets provide the following methods of :ref:`socket-objects`:
(but passing a non-zero ``flags`` argument is not allowed)
- :meth:`~socket.socket.send()`, :meth:`~socket.socket.sendall()` (with
the same limitation)
+- :meth:`~socket.socket.sendfile()` (but :mod:`os.sendfile` will be used
+ for plain-text sockets only, else :meth:`~socket.socket.send()` will be used)
+
+ .. versionadded:: 3.5
+
- :meth:`~socket.socket.shutdown()`
However, since the SSL (and TLS) protocol has its own framing atop
@@ -1005,7 +1026,7 @@ to speed up repeated connections from the same clients.
:data:`CERT_NONE`. At least one of *cafile* or *capath* must be specified.
This method can also load certification revocation lists (CRLs) in PEM or
- or DER format. In order to make use of CRLs, :attr:`SSLContext.verify_flags`
+ DER format. In order to make use of CRLs, :attr:`SSLContext.verify_flags`
must be configured properly.
The *cafile* string, if present, is the path to a file of concatenated
@@ -1602,6 +1623,12 @@ thus several things you need to be aware of:
socket first, and attempts to *read* from the SSL socket may require
a prior *write* to the underlying socket.
+ .. versionchanged:: 3.5
+
+ In earlier Python versions, the :meth:`!SSLSocket.send` method
+ returned zero instead of raising :exc:`SSLWantWriteError` or
+ :exc:`SSLWantReadError`.
+
- Calling :func:`~select.select` tells you that the OS-level socket can be
read from (or written to), but it does not imply that there is sufficient
data at the upper SSL layer. For example, only part of an SSL frame might
@@ -1671,7 +1698,7 @@ Manual settings
Verifying certificates
''''''''''''''''''''''
-When calling the the :class:`SSLContext` constructor directly,
+When calling the :class:`SSLContext` constructor directly,
:const:`CERT_NONE` is the default. Since it does not authenticate the other
peer, it can be insecure, especially in client mode where most of time you
would like to ensure the authenticity of the server you're talking to.
diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst
index 24769f6893..845b2ef7da 100644
--- a/Doc/library/stat.rst
+++ b/Doc/library/stat.rst
@@ -126,7 +126,7 @@ Example::
if __name__ == '__main__':
walktree(sys.argv[1], visitfile)
-An additional utility function is provided to covert a file's mode in a human
+An additional utility function is provided to convert a file's mode in a human
readable string:
.. function:: filemode(mode)
@@ -399,3 +399,29 @@ The following flags can be used in the *flags* argument of :func:`os.chflags`:
The file is a snapshot file.
See the \*BSD or Mac OS systems man page :manpage:`chflags(2)` for more information.
+
+On Windows, the following file attribute constants are available for use when
+testing bits in the ``st_file_attributes`` member returned by :func:`os.stat`.
+See the `Windows API documentation
+<http://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx>`_
+for more detail on the meaning of these constants.
+
+.. data:: FILE_ATTRIBUTE_ARCHIVE
+ FILE_ATTRIBUTE_COMPRESSED
+ FILE_ATTRIBUTE_DEVICE
+ FILE_ATTRIBUTE_DIRECTORY
+ FILE_ATTRIBUTE_ENCRYPTED
+ FILE_ATTRIBUTE_HIDDEN
+ FILE_ATTRIBUTE_INTEGRITY_STREAM
+ FILE_ATTRIBUTE_NORMAL
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
+ FILE_ATTRIBUTE_NO_SCRUB_DATA
+ FILE_ATTRIBUTE_OFFLINE
+ FILE_ATTRIBUTE_READONLY
+ FILE_ATTRIBUTE_REPARSE_POINT
+ FILE_ATTRIBUTE_SPARSE_FILE
+ FILE_ATTRIBUTE_SYSTEM
+ FILE_ATTRIBUTE_TEMPORARY
+ FILE_ATTRIBUTE_VIRTUAL
+
+ .. versionadded:: 3.5
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 854993cba0..d76e29ff7b 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -629,6 +629,7 @@ Instances of the :class:`Popen` class have the following methods:
must be bytes or, if *universal_newlines* was ``True``, a string.
:meth:`communicate` returns a tuple ``(stdoutdata, stderrdata)``.
+ The data will be bytes or, if *universal_newlines* was ``True``, strings.
Note that if you want to send data to the process's stdin, you need to create
the Popen object with ``stdin=PIPE``. Similarly, to get anything other than
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
index d78159d64b..4ad7d9c555 100644
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -54,6 +54,13 @@ The module defines the following user-callable items:
underlying true file object. This file-like object can be used in a
:keyword:`with` statement, just like a normal file.
+ The :py:data:`os.O_TMPFILE` flag is used if it is available and works
+ (Linux-specific, require Linux kernel 3.11 or later).
+
+ .. versionchanged:: 3.5
+
+ The :py:data:`os.O_TMPFILE` flag is now used if available.
+
.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None, delete=True)
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 4a3b3ea00b..03ee769bb0 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -630,7 +630,7 @@ item to the buffer only needs to wake up one consumer thread.
cv.wait()
Therefore, the same rules apply as with :meth:`wait`: The lock must be
- held when called and is re-aquired on return. The predicate is evaluated
+ held when called and is re-acquired on return. The predicate is evaluated
with the lock held.
.. versionadded:: 3.2
diff --git a/Doc/library/tkinter.ttk.rst b/Doc/library/tkinter.ttk.rst
index 6f8bf1c315..b0eefcb702 100644
--- a/Doc/library/tkinter.ttk.rst
+++ b/Doc/library/tkinter.ttk.rst
@@ -1167,7 +1167,7 @@ Ttk Styling
Each widget in :mod:`ttk` is assigned a style, which specifies the set of
elements making up the widget and how they are arranged, along with dynamic
and default settings for element options. By default the style name is the
-same as the widget's class name, but it may be overriden by the widget's style
+same as the widget's class name, but it may be overridden by the widget's style
option. If you don't know the class name of a widget, use the method
:meth:`Misc.winfo_class` (somewidget.winfo_class()).
diff --git a/Doc/library/token.rst b/Doc/library/token.rst
index 4cd709814c..88fb38bc1d 100644
--- a/Doc/library/token.rst
+++ b/Doc/library/token.rst
@@ -93,6 +93,7 @@ The token constants are:
DOUBLESLASH
DOUBLESLASHEQUAL
AT
+ ATEQUAL
RARROW
ELLIPSIS
OP
diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst
index 3405518ab2..f1e260278d 100644
--- a/Doc/library/tracemalloc.rst
+++ b/Doc/library/tracemalloc.rst
@@ -350,7 +350,7 @@ Functions
the *nframe* parameter of the :func:`start` function to store more frames.
The :mod:`tracemalloc` module must be tracing memory allocations to take a
- snapshot, see the the :func:`start` function.
+ snapshot, see the :func:`start` function.
See also the :func:`get_object_traceback` function.
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
index b015530cca..dbb1aa9e1f 100644
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -1809,7 +1809,7 @@ Input methods
Pop up a dialog window for input of a number. title is the title of the
dialog window, prompt is a text mostly describing what numerical information
- to input. default: default value, minval: minimum value for imput,
+ to input. default: default value, minval: minimum value for input,
maxval: maximum value for input
The number input must be in the range minval .. maxval if these are
given. If not, a hint is issued and the dialog remains open for
@@ -1879,7 +1879,7 @@ Settings and special methods
>>> cv = screen.getcanvas()
>>> cv
- <turtle.ScrolledCanvas object at ...>
+ <turtle.ScrolledCanvas object ...>
.. function:: getshapes()
@@ -2397,7 +2397,7 @@ Changes since Python 3.0
Accordingly the latter has got an alias: :meth:`Screen.onkeyrelease`.
- The method :meth:`Screen.mainloop` has been added. So when working only
- with Screen and Turtle objects one must not additonally import
+ with Screen and Turtle objects one must not additionally import
:func:`mainloop` anymore.
- Two input methods has been added :meth:`Screen.textinput` and
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index abdb939d1a..34fffe6863 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -115,6 +115,10 @@ Standard names are defined for the following types:
The type of :term:`modules <module>`. Constructor takes the name of the
module to be created and optionally its :term:`docstring`.
+ .. note::
+ Use :func:`importlib.util.module_from_spec` to create a new module if you
+ wish to set the various import-controlled attributes.
+
.. attribute:: __doc__
The :term:`docstring` of the module. Defaults to ``None``.
diff --git a/Doc/library/unicodedata.rst b/Doc/library/unicodedata.rst
index 3b3d3a0a8f..24ddef8a32 100644
--- a/Doc/library/unicodedata.rst
+++ b/Doc/library/unicodedata.rst
@@ -15,8 +15,8 @@
This module provides access to the Unicode Character Database (UCD) which
defines character properties for all Unicode characters. The data contained in
-this database is compiled from the `UCD version 6.3.0
-<http://www.unicode.org/Public/6.3.0/ucd>`_.
+this database is compiled from the `UCD version 7.0.0
+<http://www.unicode.org/Public/7.0.0/ucd>`_.
The module uses the same names and symbols as defined by Unicode
Standard Annex #44, `"Unicode Character Database"
@@ -166,6 +166,6 @@ Examples:
.. rubric:: Footnotes
-.. [#] http://www.unicode.org/Public/6.3.0/ucd/NameAliases.txt
+.. [#] http://www.unicode.org/Public/7.0.0/ucd/NameAliases.txt
-.. [#] http://www.unicode.org/Public/6.3.0/ucd/NamedSequences.txt
+.. [#] http://www.unicode.org/Public/7.0.0/ucd/NamedSequences.txt
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index cb72a683dd..4f58892443 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -198,7 +198,7 @@ a `MagicMock` for you. You can specify an alternative class of `Mock` using
the `new_callable` argument to `patch`.
-.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, **kwargs)
+.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, unsafe=False, **kwargs)
Create a new `Mock` object. `Mock` takes several optional arguments
that specify the behaviour of the Mock object:
@@ -235,6 +235,12 @@ the `new_callable` argument to `patch`.
this is a new Mock (created on first access). See the
:attr:`return_value` attribute.
+ * `unsafe`: By default if any attribute starts with *assert* or
+ *assret* will raise an `AttributeError`. Passing `unsafe=True` will allow
+ access to these attributes.
+
+ .. versionadded:: 3.5
+
* `wraps`: Item for the mock object to wrap. If `wraps` is not None then
calling the Mock will pass the call through to the wrapped object
(returning the real result). Attribute access on the mock will return a
@@ -315,6 +321,20 @@ the `new_callable` argument to `patch`.
>>> calls = [call(4), call(2), call(3)]
>>> mock.assert_has_calls(calls, any_order=True)
+ .. method:: assert_not_called(*args, **kwargs)
+
+ Assert the mock was never called.
+
+ >>> m = Mock()
+ >>> m.hello.assert_not_called()
+ >>> obj = m.hello()
+ >>> m.hello.assert_not_called()
+ Traceback (most recent call last):
+ ...
+ AssertionError: Expected 'hello' to not have been called. Called 1 times.
+
+ .. versionadded:: 3.5
+
.. method:: reset_mock()
@@ -1031,6 +1051,12 @@ patch
default because it can be dangerous. With it switched on you can write
passing tests against APIs that don't actually exist!
+ .. note::
+
+ .. versionchanged:: 3.5
+ If you are patching builtins in a module then you don't
+ need to pass `create=True`, it will be added by default.
+
Patch can be used as a `TestCase` class decorator. It works by
decorating each test method in the class. This reduces the boilerplate
code when your test methods share a common patchings set. `patch` finds
@@ -1401,6 +1427,21 @@ It is also possible to stop all patches which have been started by using
Stop all active patches. Only stops patches started with `start`.
+.. patch-builtins:
+
+patch builtins
+~~~~~~~~~~~~~~~
+You can patch any builtins within a module. The following example patches
+builtin `ord`:
+
+ >>> @patch('__main__.ord')
+ ... def test(mock_ord):
+ ... mock_ord.return_value = 101
+ ... print(ord('c'))
+ ...
+ >>> test()
+ 101
+
TEST_PREFIX
~~~~~~~~~~~
@@ -2011,7 +2052,7 @@ Mocking context managers with a :class:`MagicMock` is common enough and fiddly
enough that a helper function is useful.
>>> m = mock_open()
- >>> with patch('__main__.open', m, create=True):
+ >>> with patch('__main__.open', m):
... with open('foo', 'w') as h:
... h.write('some stuff')
...
@@ -2026,7 +2067,7 @@ enough that a helper function is useful.
And for reading files:
- >>> with patch('__main__.open', mock_open(read_data='bibble'), create=True) as m:
+ >>> with patch('__main__.open', mock_open(read_data='bibble')) as m:
... with open('foo') as h:
... result = h.read()
...
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
index 019f59cfbc..b588dad3a3 100644
--- a/Doc/library/urllib.request.rst
+++ b/Doc/library/urllib.request.rst
@@ -67,7 +67,7 @@ The :mod:`urllib.request` module defines the following functions:
:class:`http.client.HTTPResponse` object which has the following
:ref:`httpresponse-objects` methods.
- For ftp, file, and data urls and requests explicity handled by legacy
+ For ftp, file, and data urls and requests explicitly handled by legacy
:class:`URLopener` and :class:`FancyURLopener` classes, this function
returns a :class:`urllib.response.addinfourl` object which can work as
:term:`context manager` and has methods such as
@@ -1067,7 +1067,7 @@ The following W3C document, http://www.w3.org/International/O-charset\ , lists
the various ways in which a (X)HTML or a XML document could have specified its
encoding information.
-As the python.org website uses *utf-8* encoding as specified in it's meta tag, we
+As the python.org website uses *utf-8* encoding as specified in its meta tag, we
will use the same for decoding the bytes object. ::
>>> with urllib.request.urlopen('http://www.python.org/') as f:
diff --git a/Doc/library/weakref.rst b/Doc/library/weakref.rst
index 9ca60a903f..cc883b1b51 100644
--- a/Doc/library/weakref.rst
+++ b/Doc/library/weakref.rst
@@ -566,8 +566,8 @@ third party, such as running code when a module is unloaded::
.. note::
- If you create a finalizer object in a daemonic thread just as the
- the program exits then there is the possibility that the finalizer
+ If you create a finalizer object in a daemonic thread just as the program
+ exits then there is the possibility that the finalizer
does not get called at exit. However, in a daemonic thread
:func:`atexit.register`, ``try: ... finally: ...`` and ``with: ...``
do not guarantee that cleanup occurs either.
diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst
index ef63769999..aa5e4ad15d 100644
--- a/Doc/library/webbrowser.rst
+++ b/Doc/library/webbrowser.rst
@@ -20,7 +20,7 @@ available. If text-mode browsers are used, the calling process will block until
the user exits the browser.
If the environment variable :envvar:`BROWSER` exists, it is interpreted as the
-:data:`os.pathsep`-separated list of browsers to try ahead of the the platform
+:data:`os.pathsep`-separated list of browsers to try ahead of the platform
defaults. When the value of a list part contains the string ``%s``, then it is
interpreted as a literal browser command line to be used with the argument URL
substituted for ``%s``; if the part does not contain ``%s``, it is simply
diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst
index 1cef2e9464..223814030f 100644
--- a/Doc/library/wsgiref.rst
+++ b/Doc/library/wsgiref.rst
@@ -184,10 +184,11 @@ This module provides a single class, :class:`Headers`, for convenient
manipulation of WSGI response headers using a mapping-like interface.
-.. class:: Headers(headers)
+.. class:: Headers([headers])
Create a mapping-like object wrapping *headers*, which must be a list of header
- name/value tuples as described in :pep:`3333`.
+ name/value tuples as described in :pep:`3333`. The default value of *headers* is
+ an empty list.
:class:`Headers` objects support typical mapping operations including
:meth:`__getitem__`, :meth:`get`, :meth:`__setitem__`, :meth:`setdefault`,
@@ -251,6 +252,10 @@ manipulation of WSGI response headers using a mapping-like interface.
Content-Disposition: attachment; filename="bud.gif"
+ .. versionchanged:: 3.5
+ *headers* parameter is optional.
+
+
:mod:`wsgiref.simple_server` -- a simple WSGI HTTP server
---------------------------------------------------------
diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst
index 19512ed3f7..4914738dfc 100644
--- a/Doc/library/xml.dom.rst
+++ b/Doc/library/xml.dom.rst
@@ -412,7 +412,7 @@ objects:
.. method:: NodeList.item(i)
Return the *i*'th item from the sequence, if there is one, or ``None``. The
- index *i* is not allowed to be less then zero or greater than or equal to the
+ index *i* is not allowed to be less than zero or greater than or equal to the
length of the sequence.
diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst
index 3cb19d1862..6f14227ea9 100644
--- a/Doc/library/xmlrpc.client.rst
+++ b/Doc/library/xmlrpc.client.rst
@@ -191,6 +191,11 @@ grouped under the reserved :attr:`system` attribute:
no such string is available, an empty string is returned. The documentation
string may contain HTML markup.
+.. versionchanged:: 3.5
+
+ Instances of :class:`ServerProxy` support the :term:`context manager` protocol
+ for closing the underlying transport.
+
A working example follows. The server code::
@@ -208,9 +213,9 @@ The client code for the preceding server::
import xmlrpc.client
- proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
- print("3 is even: %s" % str(proxy.is_even(3)))
- print("100 is even: %s" % str(proxy.is_even(100)))
+ with xmlrpc.client.ServerProxy("http://localhost:8000/") as proxy:
+ print("3 is even: %s" % str(proxy.is_even(3)))
+ print("100 is even: %s" % str(proxy.is_even(100)))
.. _datetime-objects:
@@ -518,14 +523,14 @@ Example of Client Usage
from xmlrpc.client import ServerProxy, Error
# server = ServerProxy("http://localhost:8000") # local server
- server = ServerProxy("http://betty.userland.com")
+ with ServerProxy("http://betty.userland.com") as proxy:
- print(server)
+ print(proxy)
- try:
- print(server.examples.getStateName(41))
- except Error as v:
- print("ERROR", v)
+ try:
+ print(proxy.examples.getStateName(41))
+ except Error as v:
+ print("ERROR", v)
To access an XML-RPC server through a proxy, you need to define a custom
transport. The following example shows how:
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index d401ee06f5..24f3f93e2c 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1969,6 +1969,7 @@ left undefined.
.. method:: object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
+ object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
@@ -1985,15 +1986,16 @@ left undefined.
builtin: pow
builtin: pow
- These methods are called to implement the binary arithmetic operations (``+``,
- ``-``, ``*``, ``/``, ``//``, ``%``, :func:`divmod`, :func:`pow`, ``**``, ``<<``,
- ``>>``, ``&``, ``^``, ``|``). For instance, to evaluate the expression
- ``x + y``, where *x* is an instance of a class that has an :meth:`__add__`
- method, ``x.__add__(y)`` is called. The :meth:`__divmod__` method should be the
- equivalent to using :meth:`__floordiv__` and :meth:`__mod__`; it should not be
- related to :meth:`__truediv__`. Note that :meth:`__pow__` should be defined
- to accept an optional third argument if the ternary version of the built-in
- :func:`pow` function is to be supported.
+ These methods are called to implement the binary arithmetic operations
+ (``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
+ :func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For instance, to
+ evaluate the expression ``x + y``, where *x* is an instance of a class that
+ has an :meth:`__add__` method, ``x.__add__(y)`` is called. The
+ :meth:`__divmod__` method should be the equivalent to using
+ :meth:`__floordiv__` and :meth:`__mod__`; it should not be related to
+ :meth:`__truediv__`. Note that :meth:`__pow__` should be defined to accept
+ an optional third argument if the ternary version of the built-in :func:`pow`
+ function is to be supported.
If one of those methods does not support the operation with the supplied
arguments, it should return ``NotImplemented``.
@@ -2002,6 +2004,7 @@ left undefined.
.. method:: object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
+ object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
@@ -2017,14 +2020,14 @@ left undefined.
builtin: divmod
builtin: pow
- These methods are called to implement the binary arithmetic operations (``+``,
- ``-``, ``*``, ``/``, ``//``, ``%``, :func:`divmod`, :func:`pow`, ``**``,
- ``<<``, ``>>``, ``&``, ``^``, ``|``) with reflected (swapped) operands.
- These functions are only called if the left operand does not support the
- corresponding operation and the operands are of different types. [#]_ For
- instance, to evaluate the expression ``x - y``, where *y* is an instance of
- a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)`` is called if
- ``x.__sub__(y)`` returns *NotImplemented*.
+ These methods are called to implement the binary arithmetic operations
+ (``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
+ :func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``) with reflected
+ (swapped) operands. These functions are only called if the left operand does
+ not support the corresponding operation and the operands are of different
+ types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is
+ an instance of a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)``
+ is called if ``x.__sub__(y)`` returns *NotImplemented*.
.. index:: builtin: pow
@@ -2042,6 +2045,7 @@ left undefined.
.. method:: object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
+ object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
@@ -2053,17 +2057,17 @@ left undefined.
object.__ior__(self, other)
These methods are called to implement the augmented arithmetic assignments
- (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
- ``&=``, ``^=``, ``|=``). These methods should attempt to do the operation
- in-place (modifying *self*) and return the result (which could be, but does
- not have to be, *self*). If a specific method is not defined, the augmented
- assignment falls back to the normal methods. For instance, if *x* is an
- instance of a class with an :meth:`__iadd__` method, ``x += y`` is equivalent
- to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and ``y.__radd__(x)``
- are considered, as with the evaluation of ``x + y``. In certain situations,
- augmented assignment can result in unexpected errors (see
- :ref:`faq-augmented-assignment-tuple-error`), but this behavior is in
- fact part of the data model.
+ (``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``,
+ ``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the
+ operation in-place (modifying *self*) and return the result (which could be,
+ but does not have to be, *self*). If a specific method is not defined, the
+ augmented assignment falls back to the normal methods. For instance, if *x*
+ is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is
+ equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and
+ ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In
+ certain situations, augmented assignment can result in unexpected errors (see
+ :ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact
+ part of the data model.
.. method:: object.__neg__(self)
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index ddc3286f52..27ff04a92d 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -893,8 +893,9 @@ from the power operator, there are only two levels, one for multiplicative
operators and one for additive operators:
.. productionlist::
- m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr`
- : | `m_expr` "%" `u_expr`
+ m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` |
+ : `m_expr` "//" `u_expr`| `m_expr` "/" `u_expr` |
+ : `m_expr` "%" `u_expr`
a_expr: `m_expr` | `a_expr` "+" `m_expr` | `a_expr` "-" `m_expr`
.. index:: single: multiplication
@@ -905,6 +906,13 @@ the other must be a sequence. In the former case, the numbers are converted to a
common type and then multiplied together. In the latter case, sequence
repetition is performed; a negative repetition factor yields an empty sequence.
+.. index:: single: matrix multiplication
+
+The ``@`` (at) operator is intended to be used for matrix multiplication. No
+builtin Python types implement this operator.
+
+.. versionadded:: 3.5
+
.. index::
exception: ZeroDivisionError
single: division
@@ -1348,8 +1356,9 @@ precedence and have a left-to-right chaining feature as described in the
+-----------------------------------------------+-------------------------------------+
| ``+``, ``-`` | Addition and subtraction |
+-----------------------------------------------+-------------------------------------+
-| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |
-| | [#]_ |
+| ``*``, ``@``, ``/``, ``//``, ``%`` | Multiplication, matrix |
+| | multiplication division, |
+| | remainder [#]_ |
+-----------------------------------------------+-------------------------------------+
| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |
+-----------------------------------------------+-------------------------------------+
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index 1748d5ad7d..61ae0993ef 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -281,7 +281,7 @@ operation and an assignment statement:
.. productionlist::
augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`)
augtarget: `identifier` | `attributeref` | `subscription` | `slicing`
- augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
+ augop: "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
: | ">>=" | "<<=" | "&=" | "^=" | "|="
(See section :ref:`primaries` for the syntax definitions of the last three
diff --git a/Doc/tools/sphinxext/indexsidebar.html b/Doc/tools/sphinxext/indexsidebar.html
index 83ba1231c4..690c3d5277 100644
--- a/Doc/tools/sphinxext/indexsidebar.html
+++ b/Doc/tools/sphinxext/indexsidebar.html
@@ -3,8 +3,7 @@
<h3>Docs for other versions</h3>
<ul>
<li><a href="http://docs.python.org/2.7/">Python 2.7 (stable)</a></li>
- <li><a href="http://docs.python.org/3.3/">Python 3.3 (stable)</a></li>
- <li><a href="http://docs.python.org/3.5/">Python 3.5 (in development)</a></li>
+ <li><a href="http://docs.python.org/3.4/">Python 3.4 (stable)</a></li>
<li><a href="http://www.python.org/doc/versions/">Old versions</a></li>
</ul>
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
index 31d8c06dbb..e37ef89fcd 100644
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -10,7 +10,7 @@
"""
ISSUE_URI = 'http://bugs.python.org/issue%s'
-SOURCE_URI = 'http://hg.python.org/cpython/file/3.4/%s'
+SOURCE_URI = 'http://hg.python.org/cpython/file/default/%s'
from docutils import nodes, utils
diff --git a/Doc/tools/sphinxext/susp-ignored.csv b/Doc/tools/sphinxext/susp-ignored.csv
index 1769023941..7acc79bd8a 100644
--- a/Doc/tools/sphinxext/susp-ignored.csv
+++ b/Doc/tools/sphinxext/susp-ignored.csv
@@ -276,9 +276,5 @@ whatsnew/3.2,,:feed,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:
whatsnew/3.2,,:gz,">>> with tarfile.open(name='myarchive.tar.gz', mode='w:gz') as tf:"
whatsnew/3.2,,:location,zope9-location = ${zope9:location}
whatsnew/3.2,,:prefix,zope-conf = ${custom:prefix}/etc/zope.conf
-whatsnew/changelog,,:platform,:platform:
whatsnew/changelog,,:gz,": TarFile opened with external fileobj and ""w:gz"" mode didn't"
-whatsnew/changelog,,:PythonCmd,"With Tk < 8.5 _tkinter.c:PythonCmd() raised UnicodeDecodeError, caused"
-whatsnew/changelog,,::,": Fix FTP tests for IPv6, bind to ""::1"" instead of ""localhost""."
whatsnew/changelog,,::,": Use ""127.0.0.1"" or ""::1"" instead of ""localhost"" as much as"
-whatsnew/changelog,,:password,user:password
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index f2b66f70d8..5e95afa6fc 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -73,10 +73,11 @@ objects:
Return the number of times *x* appears in the list.
-.. method:: list.sort()
+.. method:: list.sort(key=None, reverse=False)
:noindex:
- Sort the items of the list in place.
+ Sort the items of the list in place (the arguments can be used for sort
+ customization, see :func:`sorted` for their explanation).
.. method:: list.reverse()
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst
index 44dc6d19d4..5c23ad74c7 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -10,13 +10,13 @@ Using the Python Interpreter
Invoking the Interpreter
========================
-The Python interpreter is usually installed as :file:`/usr/local/bin/python3.4`
+The Python interpreter is usually installed as :file:`/usr/local/bin/python3.5`
on those machines where it is available; putting :file:`/usr/local/bin` in your
Unix shell's search path makes it possible to start it by typing the command:
.. code-block:: text
- python3.4
+ python3.5
to the shell. [#]_ Since the choice of the directory where the interpreter lives
is an installation option, other places are possible; check with your local
@@ -24,11 +24,11 @@ Python guru or system administrator. (E.g., :file:`/usr/local/python` is a
popular alternative location.)
On Windows machines, the Python installation is usually placed in
-:file:`C:\\Python34`, though you can change this when you're running the
+:file:`C:\\Python35`, though you can change this when you're running the
installer. To add this directory to your path, you can type the following
command into the command prompt in a DOS box::
- set path=%path%;C:\python34
+ set path=%path%;C:\python35
Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on
Windows) at the primary prompt causes the interpreter to exit with a zero exit
@@ -94,8 +94,8 @@ with the *secondary prompt*, by default three dots (``...``). The interpreter
prints a welcome message stating its version number and a copyright notice
before printing the first prompt::
- $ python3.4
- Python 3.4 (default, Mar 16 2014, 09:25:04)
+ $ python3.5
+ Python 3.5 (default, Sep 16 2015, 09:25:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
@@ -148,7 +148,7 @@ Executable Python Scripts
On BSD'ish Unix systems, Python scripts can be made directly executable, like
shell scripts, by putting the line ::
- #! /usr/bin/env python3.4
+ #! /usr/bin/env python3.5
(assuming that the interpreter is on the user's :envvar:`PATH`) at the beginning
of the script and giving the file an executable mode. The ``#!`` must be the
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst
index cd73bc2596..954ef4462f 100644
--- a/Doc/tutorial/stdlib.rst
+++ b/Doc/tutorial/stdlib.rst
@@ -15,7 +15,7 @@ operating system::
>>> import os
>>> os.getcwd() # Return the current working directory
- 'C:\\Python34'
+ 'C:\\Python35'
>>> os.chdir('/server/accesslogs') # Change current working directory
>>> os.system('mkdir today') # Run the command mkdir in the system shell
0
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index c0197ea5ef..497c5842a1 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -277,7 +277,7 @@ applications include caching objects that are expensive to create::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
d['primary'] # entry was automatically removed
- File "C:/python34/lib/weakref.py", line 46, in __getitem__
+ File "C:/python35/lib/weakref.py", line 46, in __getitem__
o = self.data[key]()
KeyError: 'primary'
diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst
index b1ab48e7f4..144ea1c631 100644
--- a/Doc/whatsnew/2.1.rst
+++ b/Doc/whatsnew/2.1.rst
@@ -219,7 +219,7 @@ comparison. I won't cover the C API here, but will refer you to PEP 207, or to
.. seealso::
- :pep:`207` - Rich Comparisions
+ :pep:`207` - Rich Comparisons
Written by Guido van Rossum, heavily based on earlier work by David Ascher, and
implemented by Guido van Rossum.
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
index cda63e4928..7631e7512b 100644
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -1579,7 +1579,7 @@ os
avoid race conditions in multi-threaded programs.
* The :mod:`os` module has a new :func:`~os.sendfile` function which provides
- an efficent "zero-copy" way for copying data from one file (or socket)
+ an efficient "zero-copy" way for copying data from one file (or socket)
descriptor to another. The phrase "zero-copy" refers to the fact that all of
the copying of data between the two descriptors is done entirely by the
kernel, with no copying of data into userspace buffers. :func:`~os.sendfile`
@@ -1908,7 +1908,7 @@ socketserver
:meth:`~socketserver.BaseServer.service_actions` that is called by the
:meth:`~socketserver.BaseServer.serve_forever` method in the service loop.
:class:`~socketserver.ForkingMixIn` now uses this to clean up zombie
-child proceses. (Contributed by Justin Warkentin in :issue:`11109`.)
+child processes. (Contributed by Justin Warkentin in :issue:`11109`.)
sqlite3
@@ -2360,7 +2360,7 @@ Porting Python code
bytecode file, make sure to call :func:`importlib.invalidate_caches` to clear
out the cache for the finders to notice the new file.
-* :exc:`ImportError` now uses the full name of the module that was attemped to
+* :exc:`ImportError` now uses the full name of the module that was attempted to
be imported. Doctests that check ImportErrors' message will need to be
updated to use the full name of the module instead of just the tail of the
name.
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
new file mode 100644
index 0000000000..d19bb258f1
--- /dev/null
+++ b/Doc/whatsnew/3.5.rst
@@ -0,0 +1,345 @@
+****************************
+ What's New In Python 3.5
+****************************
+
+:Release: |release|
+:Date: |today|
+
+.. Rules for maintenance:
+
+ * Anyone can add text to this document. Do not spend very much time
+ on the wording of your changes, because your text will probably
+ get rewritten to some degree.
+
+ * The maintainer will go through Misc/NEWS periodically and add
+ changes; it's therefore more important to add your changes to
+ Misc/NEWS than to this file.
+
+ * This is not a complete list of every single change; completeness
+ is the purpose of Misc/NEWS. Some changes I consider too small
+ or esoteric to include. If such a change is added to the text,
+ I'll just remove it. (This is another reason you shouldn't spend
+ too much time on writing your addition.)
+
+ * If you want to draw your new text to the attention of the
+ maintainer, add 'XXX' to the beginning of the paragraph or
+ section.
+
+ * It's OK to just add a fragmentary note about a change. For
+ example: "XXX Describe the transmogrify() function added to the
+ socket module." The maintainer will research the change and
+ write the necessary text.
+
+ * You can comment out your additions if you like, but it's not
+ necessary (especially when a final release is some months away).
+
+ * Credit the author of a patch or bugfix. Just the name is
+ sufficient; the e-mail address isn't necessary.
+
+ * It's helpful to add the bug/patch number as a comment:
+
+ XXX Describe the transmogrify() function added to the socket
+ module.
+ (Contributed by P.Y. Developer in :issue:`12345`.)
+
+ This saves the maintainer the effort of going through the Mercurial log
+ when researching a change.
+
+This article explains the new features in Python 3.5, compared to 3.4.
+
+For full details, see the :source:`Misc/NEWS` file.
+
+.. note:: Prerelease users should be aware that this document is currently in
+ draft form. It will be updated substantially as Python 3.5 moves towards
+ release, so it's worth checking back even after reading earlier versions.
+
+
+.. seealso::
+
+ .. :pep:`4XX` - Python 3.5 Release Schedule
+
+
+Summary -- Release highlights
+=============================
+
+.. This section singles out the most important changes in Python 3.3.
+ Brevity is key.
+
+New syntax features:
+
+* None yet.
+
+New library modules:
+
+* None yet.
+
+New built-in features:
+
+* None yet.
+
+Implementation improvements:
+
+* When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale),
+ :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the
+ ``surrogateescape`` error handler, instead of the ``strict`` error handler
+ (:issue:`19977`).
+
+Significantly Improved Library Modules:
+
+* None yet.
+
+Security improvements:
+
+* None yet.
+
+Please read on for a comprehensive list of user-facing changes.
+
+
+.. PEP-sized items next.
+
+.. _pep-4XX:
+
+.. PEP 4XX: Virtual Environments
+.. =============================
+
+
+.. (Implemented by Foo Bar.)
+
+.. .. seealso::
+
+ :pep:`4XX` - Python Virtual Environments
+ PEP written by Carl Meyer
+
+
+
+
+Other Language Changes
+======================
+
+Some smaller changes made to the core Python language are:
+
+* None yet.
+
+
+
+New Modules
+===========
+
+.. module name
+.. -----------
+
+* None yet.
+
+
+Improved Modules
+================
+
+doctest
+-------
+
+* :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if
+ *module* contains no docstrings instead of raising :exc:`ValueError`
+ (contributed by Glenn Jones in :issue:`15916`).
+
+imghdr
+------
+
+* :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_
+ format (contributed by Martin vignali and Cladui Popa in :issue:`20295`).
+
+importlib
+---------
+
+* :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in
+ applications where startup time is paramount (contributed by Brett Cannon in
+ :issue:`17621`).
+
+* :func:`importlib.abc.InspectLoader.source_to_code` is now a
+ static method to make it easier to work with source code in a string.
+ With a module object that you want to initialize you can then use
+ ``exec(code, module.__dict__)`` to execute the code in the module.
+
+* :func:`importlib.util.module_from_spec` is now the preferred way to create a
+ new module. Compared to :class:`types.ModuleType`, this new function will set
+ the various import-controlled attributes based on the passed-in spec object.
+
+inspect
+-------
+
+* :class:`inspect.Signature` and :class:`inspect.Parameter` are now
+ picklable and hashable (contributed by Yury Selivanov in :issue:`20726`
+ and :issue:`20334`).
+
+* New class method :meth:`inspect.Signature.from_callable`, which makes
+ subclassing of :class:`~inspect.Signature` easier (contributed
+ by Yury Selivanov and Eric Snow in :issue:`17373`).
+
+ipaddress
+---------
+
+* :class:`ipaddress.IPv4Network` and :class:`ipaddress.IPv6Network` now
+ accept an ``(address, netmask)`` tuple argument, so as to easily construct
+ network objects from existing addresses (contributed by Peter Moody
+ and Antoine Pitrou in :issue:`16531`).
+
+os
+--
+
+* :class:`os.stat_result` now has a ``st_file_attributes`` field on Windows,
+ containing the ``dwFileAttributes`` member of the
+ ``BY_HANDLE_FILE_INFORMATION`` structure returned by
+ ``GetFileInformationByHandle()`` (contributed by Ben Hoyt in
+ :issue:`21719`).
+
+shutil
+------
+
+* :func:`~shutil.move` now accepts a *copy_function* argument, allowing,
+ for example, :func:`~shutil.copy` to be used instead of the default
+ :func:`~shutil.copy2` if there is a need to ignore metadata. (Contributed by
+ Claudiu Popa in :issue:`19840`.)
+
+signal
+------
+
+* Different constants of :mod:`signal` module are now enumeration values using
+ the :mod:`enum` module. This allows meaningful names to be printed during
+ debugging, instead of integer “magic numbers”. (contributed by Giampaolo
+ Rodola' in :issue:`21076`)
+
+smtpd
+-----
+
+* Both :class:`~smtpd.SMTPServer` and :class:`smtpd.SMTPChannel` now accept a
+ *decode_data* keyword to determine if the DATA portion of the SMTP
+ transaction is decoded using the ``utf-8`` codec or is instead provided to
+ :meth:`~smtpd.SMTPServer.process_message` as a byte string. The default
+ is ``True`` for backward compatibility reasons, but will change to ``False``
+ in Python 3.6. (Contributed by Maciej Szulik in :issue:`19662`.)
+
+* It is now possible to provide, directly or via name resolution, IPv6
+ addresses in the :class:`~smtpd.SMTPServer` constructor, and have it
+ successfully connect. (Contributed by Milan Oberkirch in :issue:`14758`.)
+
+smtplib
+-------
+
+* A new :meth:`~smtplib.SMTP.auth` method provides a convenient way to
+ implement custom authentication mechanisms (contributed by Milan Oberkirch in
+ :issue:`15014`).
+
+socket
+------
+
+* New :meth:`socket.socket.sendfile` method allows to send a file over a socket
+ by using high-performance :func:`os.sendfile` function on UNIX resulting in
+ uploads being from 2x to 3x faster than when using plain
+ :meth:`socket.socket.send`.
+ (contributed by Giampaolo Rodola' in :issue:`17552`)
+
+wsgiref
+-------
+
+* *headers* parameter of :class:`wsgiref.headers.Headers` is now optional.
+ (Contributed by Pablo Torres Navarrete and SilentGhost in :issue:`5800`.)
+
+xmlrpc
+------
+
+* :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager`
+ (contributed by Claudiu Popa in :issue:`20627`).
+
+
+Optimizations
+=============
+
+The following performance enhancements have been added:
+
+* Construction of ``bytes(int)`` (filled by zero bytes) is faster and use less
+ memory for large objects. ``calloc()`` is used instead of ``malloc()`` to
+ allocate memory for these objects.
+
+* Some operations on :class:`~ipaddress.IPv4Network` and
+ :class:`~ipaddress.IPv6Network` have been massively sped up, such as
+ :meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`,
+ :func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`.
+ The speed up can range from 3x to 15x.
+ (:issue:`21486`, :issue:`21487`, :issue:`20826`)
+
+
+Build and C API Changes
+=======================
+
+Changes to Python's build process and to the C API include:
+
+* New ``calloc`` functions:
+
+ * :c:func:`PyMem_RawCalloc`
+ * :c:func:`PyMem_Calloc`
+ * :c:func:`PyObject_Calloc`
+ * :c:func:`_PyObject_GC_Calloc`
+
+
+Deprecated
+==========
+
+Unsupported Operating Systems
+-----------------------------
+
+* None yet.
+
+
+Deprecated Python modules, functions and methods
+------------------------------------------------
+
+* The :mod:`formatter` module has now graduated to full deprecation and is still
+ slated for removal in Python 3.6.
+
+* :mod:`smtpd` has in the past always decoded the DATA portion of email
+ messages using the ``utf-8`` codec. This can now be controlled by the new
+ *decode_data* keyword to :class:`~smtpd.SMTPServer`. The default value is
+ ``True``, but this default is deprecated. Specify the *decode_data* keyword
+ with an appropriate value to avoid the deprecation warning.
+
+
+Deprecated functions and types of the C API
+-------------------------------------------
+
+* None yet.
+
+
+Deprecated features
+-------------------
+
+* None yet.
+
+
+Porting to Python 3.5
+=====================
+
+This section lists previously described changes and other bugfixes
+that may require changes to your code.
+
+Changes in the Python API
+-------------------------
+
+* Before Python 3.5, a :class:`datetime.time` object was considered to be false
+ if it represented midnight in UTC. This behavior was considered obscure and
+ error-prone and has been removed in Python 3.5. See :issue:`13936` for full
+ details.
+
+* :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError`
+ or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation
+ would block. Previously, it would return 0. See :issue:`20951`.
+
+* The ``__name__`` attribute of generator is now set from the function name,
+ instead of being set from the code name. Use ``gen.gi_code.co_name`` to
+ retrieve the code name. Generators also have a new ``__qualname__``
+ attribute, the qualified name, which is now used for the representation
+ of a generator (``repr(gen)``). See :issue:`21205`.
+
+Changes in the C API
+--------------------
+
+* The :c:type:`PyMemAllocator` structure was renamed to
+ :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
diff --git a/Doc/whatsnew/index.rst b/Doc/whatsnew/index.rst
index 29902e407c..edb55022bd 100644
--- a/Doc/whatsnew/index.rst
+++ b/Doc/whatsnew/index.rst
@@ -11,6 +11,7 @@ anyone wishing to stay up-to-date after a new release.
.. toctree::
:maxdepth: 2
+ 3.5.rst
3.4.rst
3.3.rst
3.2.rst