Skip to content

Commit 85024cc

Browse files
committed
Issue #21906: Merge from 3.4.
2 parents 2611896 + ef8cc0f commit 85024cc

File tree

428 files changed

+44642
-41517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+44642
-41517
lines changed

.hgignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ db_home
1818
platform$
1919
pyconfig.h$
2020
python$
21+
python.bat$
2122
python.exe$
2223
python-config$
2324
python-config.py$

.hgtouch

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Python/importlib.h: Lib/importlib/_bootstrap.py Modules/_freeze_importlib.c
66

7+
Include/opcode.h: Lib/opcode.py Tools/scripts/generate_opcode_h.py
8+
79
Include/Python-ast.h: Parser/Python.asdl Parser/asdl.py Parser/asdl_c.py
810
Python/Python-ast.c: Include/Python-ast.h
911

Doc/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Python Documentation README
33

44
This directory contains the reStructuredText (reST) sources to the Python
55
documentation. You don't need to build them yourself, prebuilt versions are
6-
available at <https://docs.python.org/3.4/download.html>.
6+
available at <https://docs.python.org/dev/download.html>.
77

88
Documentation on authoring Python documentation, including information about
99
both style and markup, is available in the "Documenting Python" chapter of the

Doc/c-api/memory.rst

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ functions are thread-safe, the :term:`GIL <global interpreter lock>` does not
9292
need to be held.
9393

9494
The default raw memory block allocator uses the following functions:
95-
:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when
96-
requesting zero bytes.
95+
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call
96+
``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes.
9797

9898
.. versionadded:: 3.4
9999

@@ -106,6 +106,17 @@ requesting zero bytes.
106106
been initialized in any way.
107107
108108
109+
.. c:function:: void* PyMem_RawCalloc(size_t nelem, size_t elsize)
110+
111+
Allocates *nelem* elements each whose size in bytes is *elsize* and returns
112+
a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the
113+
request fails. The memory is initialized to zeros. Requesting zero elements
114+
or elements of size zero bytes returns a distinct non-*NULL* pointer if
115+
possible, as if ``PyMem_RawCalloc(1, 1)`` had been called instead.
116+
117+
.. versionadded:: 3.5
118+
119+
109120
.. c:function:: void* PyMem_RawRealloc(void *p, size_t n)
110121
111122
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
136147
memory from the Python heap.
137148
138149
The default memory block allocator uses the following functions:
139-
:c:func:`malloc`, :c:func:`realloc` and :c:func:`free`; call ``malloc(1)`` when
140-
requesting zero bytes.
150+
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call
151+
``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes.
141152
142153
.. warning::
143154
@@ -152,6 +163,17 @@ requesting zero bytes.
152163
been called instead. The memory will not have been initialized in any way.
153164
154165
166+
.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)
167+
168+
Allocates *nelem* elements each whose size in bytes is *elsize* and returns
169+
a pointer of type :c:type:`void\*` to the allocated memory, or *NULL* if the
170+
request fails. The memory is initialized to zeros. Requesting zero elements
171+
or elements of size zero bytes returns a distinct non-*NULL* pointer if
172+
possible, as if ``PyMem_Calloc(1, 1)`` had been called instead.
173+
174+
.. versionadded:: 3.5
175+
176+
155177
.. c:function:: void* PyMem_Realloc(void *p, size_t n)
156178
157179
Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
@@ -210,7 +232,7 @@ Customize Memory Allocators
210232
211233
.. versionadded:: 3.4
212234
213-
.. c:type:: PyMemAllocator
235+
.. c:type:: PyMemAllocatorEx
214236
215237
Structure used to describe a memory block allocator. The structure has
216238
four fields:
@@ -222,11 +244,19 @@ Customize Memory Allocators
222244
+----------------------------------------------------------+---------------------------------------+
223245
| ``void* malloc(void *ctx, size_t size)`` | allocate a memory block |
224246
+----------------------------------------------------------+---------------------------------------+
247+
| ``void* calloc(void *ctx, size_t nelem, size_t elsize)`` | allocate a memory block initialized |
248+
| | with zeros |
249+
+----------------------------------------------------------+---------------------------------------+
225250
| ``void* realloc(void *ctx, void *ptr, size_t new_size)`` | allocate or resize a memory block |
226251
+----------------------------------------------------------+---------------------------------------+
227252
| ``void free(void *ctx, void *ptr)`` | free a memory block |
228253
+----------------------------------------------------------+---------------------------------------+
229254
255+
.. versionchanged:: 3.5
256+
The :c:type:`PyMemAllocator` structure was renamed to
257+
:c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.
258+
259+
230260
.. c:type:: PyMemAllocatorDomain
231261
232262
Enum used to identify an allocator domain. Domains:
@@ -239,12 +269,12 @@ Customize Memory Allocators
239269
:c:func:`PyObject_Realloc` and :c:func:`PyObject_Free`
240270
241271
242-
.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocator *allocator)
272+
.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)
243273
244274
Get the memory block allocator of the specified domain.
245275
246276
247-
.. c:function:: void PyMem_SetAllocator(PyMemAllocatorDomain domain, PyMemAllocator *allocator)
277+
.. c:function:: void PyMem_SetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)
248278
249279
Set the memory block allocator of the specified domain.
250280

Doc/c-api/number.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Number Protocol
3030
the equivalent of the Python expression ``o1 * o2``.
3131
3232
33+
.. c:function:: PyObject* PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2)
34+
35+
Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on
36+
failure. This is the equivalent of the Python expression ``o1 @ o2``.
37+
38+
.. versionadded:: 3.5
39+
40+
3341
.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
3442
3543
Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is
@@ -146,6 +154,15 @@ Number Protocol
146154
the Python statement ``o1 *= o2``.
147155
148156
157+
.. c:function:: PyObject* PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2)
158+
159+
Returns the result of matrix multiplication on *o1* and *o2*, or *NULL* on
160+
failure. The operation is done *in-place* when *o1* supports it. This is
161+
the equivalent of the Python statement ``o1 @= o2``.
162+
163+
.. versionadded:: 3.5
164+
165+
149166
.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
150167
151168
Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure.

Doc/c-api/typeobj.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,9 @@ Number Object Structures
11411141
binaryfunc nb_inplace_true_divide;
11421142

11431143
unaryfunc nb_index;
1144+
1145+
binaryfunc nb_matrix_multiply;
1146+
binaryfunc nb_inplace_matrix_multiply;
11441147
} PyNumberMethods;
11451148

11461149
.. note::

Doc/distutils/apiref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,13 @@ other utility module.
10991099
during the build of Python), not the OS version of the current system.
11001100

11011101
For universal binary builds on Mac OS X the architecture value reflects
1102-
the univeral binary status instead of the architecture of the current
1102+
the universal binary status instead of the architecture of the current
11031103
processor. For 32-bit universal binaries the architecture is ``fat``,
11041104
for 64-bit universal binaries the architecture is ``fat64``, and
11051105
for 4-way universal binaries the architecture is ``universal``. Starting
11061106
from Python 2.7 and Python 3.2 the architecture ``fat3`` is used for
11071107
a 3-way universal build (ppc, i386, x86_64) and ``intel`` is used for
1108-
a univeral build with the i386 and x86_64 architectures
1108+
a universal build with the i386 and x86_64 architectures
11091109

11101110
Examples of returned values on Mac OS X:
11111111

Doc/distutils/builtdist.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ support this option, so the command::
355355
would create a 64bit installation executable on your 32bit version of Windows.
356356

357357
To cross-compile, you must download the Python source code and cross-compile
358-
Python itself for the platform you are targetting - it is not possible from a
358+
Python itself for the platform you are targeting - it is not possible from a
359359
binary installation of Python (as the .lib etc file for other platforms are
360360
not included.) In practice, this means the user of a 32 bit operating
361361
system will need to use Visual Studio 2008 to open the

Doc/glossary.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,13 @@ Glossary
444444

445445
A number of tools in Python accept key functions to control how elements
446446
are ordered or grouped. They include :func:`min`, :func:`max`,
447-
:func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,
448-
:func:`heapq.nlargest`, and :func:`itertools.groupby`.
447+
:func:`sorted`, :meth:`list.sort`, :func:`heapq.merge`,
448+
:func:`heapq.nsmallest`, :func:`heapq.nlargest`, and
449+
:func:`itertools.groupby`.
449450

450451
There are several ways to create a key function. For example. the
451452
:meth:`str.lower` method can serve as a key function for case insensitive
452-
sorts. Alternatively, an ad-hoc key function can be built from a
453+
sorts. Alternatively, a key function can be built from a
453454
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
454455
the :mod:`operator` module provides three key function constructors:
455456
:func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and

Doc/howto/clinic.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ Argument Clinic generates code that does it for you (in the parsing function).
886886
Advanced converters
887887
-------------------
888888

889-
Remeber those format units you skipped for your first
889+
Remember those format units you skipped for your first
890890
time because they were advanced? Here's how to handle those too.
891891

892892
The trick is, all those format units take arguments--either
@@ -1020,12 +1020,12 @@ any of the default arguments you can omit the parentheses.
10201020
the ``"as"`` should come before the return converter.)
10211021

10221022
There's one additional complication when using return converters: how do you
1023-
indicate an error has occured? Normally, a function returns a valid (non-``NULL``)
1023+
indicate an error has occurred? Normally, a function returns a valid (non-``NULL``)
10241024
pointer for success, and ``NULL`` for failure. But if you use an integer return converter,
10251025
all integers are valid. How can Argument Clinic detect an error? Its solution: each return
10261026
converter implicitly looks for a special value that indicates an error. If you return
10271027
that value, and an error has been set (``PyErr_Occurred()`` returns a true
1028-
value), then the generated code will propogate the error. Otherwise it will
1028+
value), then the generated code will propagate the error. Otherwise it will
10291029
encode the value you return like normal.
10301030

10311031
Currently Argument Clinic supports only a few return converters::
@@ -1573,7 +1573,7 @@ The fourth new directive is ``set``::
15731573
``line_prefix`` is a string that will be prepended to every line of Clinic's output;
15741574
``line_suffix`` is a string that will be appended to every line of Clinic's output.
15751575

1576-
Both of these suport two format strings:
1576+
Both of these support two format strings:
15771577

15781578
``{block comment start}``
15791579
Turns into the string ``/*``, the start-comment text sequence for C files.

Doc/howto/pyporting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If your project is on the Cheeseshop_/PyPI_, make sure it has the proper
6060
`trove classifiers`_ to signify what versions of Python it **currently**
6161
supports. At minimum you should specify the major version(s), e.g.
6262
``Programming Language :: Python :: 2`` if your project currently only supports
63-
Python 2. It is preferrable that you be as specific as possible by listing every
63+
Python 2. It is preferable that you be as specific as possible by listing every
6464
major/minor version of Python that you support, e.g. if your project supports
6565
Python 2.6 and 2.7, then you want the classifiers of::
6666

Doc/howto/regex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ keep track of the group numbers. There are two features which help with this
852852
problem. Both of them use a common syntax for regular expression extensions, so
853853
we'll look at that first.
854854

855-
Perl 5 is well-known for its powerful additions to standard regular expressions.
855+
Perl 5 is well known for its powerful additions to standard regular expressions.
856856
For these new features the Perl developers couldn't choose new single-keystroke metacharacters
857857
or new special sequences beginning with ``\`` without making Perl's regular
858858
expressions confusingly different from standard REs. If they chose ``&`` as a

Doc/howto/sockets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ messages to be sent back to back (without some kind of reply), and you pass
234234
following message. You'll need to put that aside and hold onto it, until it's
235235
needed.
236236

237-
Prefixing the message with it's length (say, as 5 numeric characters) gets more
237+
Prefixing the message with its length (say, as 5 numeric characters) gets more
238238
complex, because (believe it or not), you may not get all 5 characters in one
239239
``recv``. In playing around, you'll get away with it; but in high network loads,
240240
your code will very quickly break unless you use two ``recv`` loops - the first

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ Customizing file parsing
18731873

18741874
Arguments that are read from a file (see the *fromfile_prefix_chars*
18751875
keyword argument to the :class:`ArgumentParser` constructor) are read one
1876-
argument per line. :meth:`convert_arg_line_to_args` can be overriden for
1876+
argument per line. :meth:`convert_arg_line_to_args` can be overridden for
18771877
fancier reading.
18781878

18791879
This method takes a single argument *arg_line* which is a string read from

Doc/library/asynchat.rst

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -147,40 +147,6 @@ connection requests.
147147
by the channel after :meth:`found_terminator` is called.
148148

149149

150-
asynchat - Auxiliary Classes
151-
------------------------------------------
152-
153-
.. class:: fifo(list=None)
154-
155-
A :class:`fifo` holding data which has been pushed by the application but
156-
not yet popped for writing to the channel. A :class:`fifo` is a list used
157-
to hold data and/or producers until they are required. If the *list*
158-
argument is provided then it should contain producers or data items to be
159-
written to the channel.
160-
161-
162-
.. method:: is_empty()
163-
164-
Returns ``True`` if and only if the fifo is empty.
165-
166-
167-
.. method:: first()
168-
169-
Returns the least-recently :meth:`push`\ ed item from the fifo.
170-
171-
172-
.. method:: push(data)
173-
174-
Adds the given data (which may be a string or a producer object) to the
175-
producer fifo.
176-
177-
178-
.. method:: pop()
179-
180-
If the fifo is not empty, returns ``True, first()``, deleting the popped
181-
item. Returns ``False, None`` for an empty fifo.
182-
183-
184150
.. _asynchat-example:
185151

186152
asynchat Example

Doc/library/cmd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ immediate playback::
252252
'Move turtle to an absolute position with changing orientation. GOTO 100 200'
253253
goto(*parse(arg))
254254
def do_home(self, arg):
255-
'Return turtle to the home postion: HOME'
255+
'Return turtle to the home position: HOME'
256256
home()
257257
def do_circle(self, arg):
258258
'Draw circle with given radius an options extent and steps: CIRCLE 50'

Doc/library/code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.. module:: code
55
:synopsis: Facilities to implement read-eval-print loops.
66

7+
**Source code:** :source:`Lib/code.py`
78

89
The ``code`` module provides facilities to implement read-eval-print loops in
910
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.
165166
newline. When the user enters the EOF key sequence, :exc:`EOFError` is raised.
166167
The base implementation reads from ``sys.stdin``; a subclass may replace this
167168
with a different implementation.
168-

Doc/library/codecs.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
.. sectionauthor:: Marc-André Lemburg <[email protected]>
88
.. sectionauthor:: Martin v. Löwis <[email protected]>
99

10+
**Source code:** :source:`Lib/codecs.py`
1011

1112
.. index::
1213
single: Unicode
@@ -22,21 +23,19 @@ manages the codec and error handling lookup process.
2223

2324
It defines the following functions:
2425

25-
.. function:: encode(obj, [encoding[, errors]])
26+
.. function:: encode(obj, encoding='utf-8', errors='strict')
2627

27-
Encodes *obj* using the codec registered for *encoding*. The default
28-
encoding is ``utf-8``.
28+
Encodes *obj* using the codec registered for *encoding*.
2929

3030
*Errors* may be given to set the desired error handling scheme. The
3131
default error handler is ``strict`` meaning that encoding errors raise
3232
:exc:`ValueError` (or a more codec specific subclass, such as
3333
:exc:`UnicodeEncodeError`). Refer to :ref:`codec-base-classes` for more
3434
information on codec error handling.
3535

36-
.. function:: decode(obj, [encoding[, errors]])
36+
.. function:: decode(obj, encoding='utf-8', errors='strict')
3737

38-
Decodes *obj* using the codec registered for *encoding*. The default
39-
encoding is ``utf-8``.
38+
Decodes *obj* using the codec registered for *encoding*.
4039

4140
*Errors* may be given to set the desired error handling scheme. The
4241
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
14201419
BOM will be prepended to the UTF-8 encoded bytes. For the stateful encoder this
14211420
is only done once (on the first write to the byte stream). For decoding an
14221421
optional UTF-8 encoded BOM at the start of the data will be skipped.
1423-

Doc/library/collections.abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
179179
(3)
180180
The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash value
181181
for the set; however, :meth:`__hash__` is not defined because not all sets
182-
are hashable or immutable. To add set hashabilty using mixins,
182+
are hashable or immutable. To add set hashability using mixins,
183183
inherit from both :meth:`Set` and :meth:`Hashable`, then define
184184
``__hash__ = Set._hash``.
185185

0 commit comments

Comments
 (0)