Skip to content

Commit 6d5e555

Browse files
Merge branch 'master' into disallow-yield-in-comprehencions
2 parents ca6cd26 + 73a7e9b commit 6d5e555

File tree

147 files changed

+1850
-2091
lines changed

Some content is hidden

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

147 files changed

+1850
-2091
lines changed

Doc/c-api/init.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ The following functions can be safely called before Python is initialized:
5858

5959
The following functions **should not be called** before
6060
:c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
61-
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix` and
62-
:c:func:`Py_GetProgramFullPath` and :c:func:`Py_GetPythonHome`.
61+
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
62+
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
63+
:c:func:`PyEval_InitThreads`.
6364

6465

6566
.. _global-conf-vars:

Doc/c-api/memory.rst

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ The following function sets are wrappers to the system allocator. These
100100
functions are thread-safe, the :term:`GIL <global interpreter lock>` does not
101101
need to be held.
102102

103-
The default raw memory block allocator uses the following functions:
104-
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call
105-
``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes.
103+
The :ref:`default raw memory allocator <default-memory-allocators>` uses
104+
the following functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc`
105+
and :c:func:`free`; call ``malloc(1)`` (or ``calloc(1, 1)``) when requesting
106+
zero bytes.
106107

107108
.. versionadded:: 3.4
108109

@@ -165,7 +166,8 @@ The following function sets, modeled after the ANSI C standard, but specifying
165166
behavior when requesting zero bytes, are available for allocating and releasing
166167
memory from the Python heap.
167168
168-
By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
169+
The :ref:`default memory allocator <default-memory-allocators>` uses the
170+
:ref:`pymalloc memory allocator <pymalloc>`.
169171
170172
.. warning::
171173
@@ -270,7 +272,8 @@ The following function sets, modeled after the ANSI C standard, but specifying
270272
behavior when requesting zero bytes, are available for allocating and releasing
271273
memory from the Python heap.
272274
273-
By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
275+
The :ref:`default object allocator <default-memory-allocators>` uses the
276+
:ref:`pymalloc memory allocator <pymalloc>`.
274277
275278
.. warning::
276279
@@ -326,6 +329,31 @@ By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
326329
If *p* is *NULL*, no operation is performed.
327330
328331
332+
.. _default-memory-allocators:
333+
334+
Default Memory Allocators
335+
=========================
336+
337+
Default memory allocators:
338+
339+
=============================== ==================== ================== ===================== ====================
340+
Configuration Name PyMem_RawMalloc PyMem_Malloc PyObject_Malloc
341+
=============================== ==================== ================== ===================== ====================
342+
Release build ``"pymalloc"`` ``malloc`` ``pymalloc`` ``pymalloc``
343+
Debug build ``"pymalloc_debug"`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug
344+
Release build, without pymalloc ``"malloc"`` ``malloc`` ``malloc`` ``malloc``
345+
Release build, without pymalloc ``"malloc_debug"`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug
346+
=============================== ==================== ================== ===================== ====================
347+
348+
Legend:
349+
350+
* Name: value for :envvar:`PYTHONMALLOC` environment variable
351+
* ``malloc``: system allocators from the standard C library, C functions:
352+
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`
353+
* ``pymalloc``: :ref:`pymalloc memory allocator <pymalloc>`
354+
* "+ debug": with debug hooks installed by :c:func:`PyMem_SetupDebugHooks`
355+
356+
329357
Customize Memory Allocators
330358
===========================
331359
@@ -431,7 +459,8 @@ Customize Memory Allocators
431459
displayed if :mod:`tracemalloc` is tracing Python memory allocations and the
432460
memory block was traced.
433461
434-
These hooks are installed by default if Python is compiled in debug
462+
These hooks are :ref:`installed by default <default-memory-allocators>` if
463+
Python is compiled in debug
435464
mode. The :envvar:`PYTHONMALLOC` environment variable can be used to install
436465
debug hooks on a Python compiled in release mode.
437466
@@ -453,9 +482,9 @@ to 512 bytes) with a short lifetime. It uses memory mappings called "arenas"
453482
with a fixed size of 256 KiB. It falls back to :c:func:`PyMem_RawMalloc` and
454483
:c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes.
455484
456-
*pymalloc* is the default allocator of the :c:data:`PYMEM_DOMAIN_MEM` (ex:
457-
:c:func:`PyMem_Malloc`) and :c:data:`PYMEM_DOMAIN_OBJ` (ex:
458-
:c:func:`PyObject_Malloc`) domains.
485+
*pymalloc* is the :ref:`default allocator <default-memory-allocators>` of the
486+
:c:data:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and
487+
:c:data:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains.
459488
460489
The arena allocator uses the following functions:
461490

Doc/includes/shoddy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Shoddy_increment(Shoddy *self, PyObject *unused)
1717
static PyMethodDef Shoddy_methods[] = {
1818
{"increment", (PyCFunction)Shoddy_increment, METH_NOARGS,
1919
PyDoc_STR("increment state counter")},
20-
{NULL, NULL},
20+
{NULL},
2121
};
2222

2323
static int

Doc/library/2to3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ and off individually. They are described here in more detail.
351351
================================== =============================================
352352
From To
353353
================================== =============================================
354-
``operator.isCallable(obj)`` ``hasattr(obj, '__call__')``
354+
``operator.isCallable(obj)`` ``callable(obj)``
355355
``operator.sequenceIncludes(obj)`` ``operator.contains(obj)``
356356
``operator.isSequenceType(obj)`` ``isinstance(obj, collections.abc.Sequence)``
357357
``operator.isMappingType(obj)`` ``isinstance(obj, collections.abc.Mapping)``

Doc/library/asyncio-eventloop.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,7 @@ Wait until a file descriptor received some data using the
967967
:meth:`AbstractEventLoop.add_reader` method and then close the event loop::
968968

969969
import asyncio
970-
try:
971-
from socket import socketpair
972-
except ImportError:
973-
from asyncio.windows_utils import socketpair
970+
from socket import socketpair
974971

975972
# Create a pair of connected file descriptors
976973
rsock, wsock = socketpair()

Doc/library/asyncio-protocol.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,7 @@ Wait until a socket receives data using the
690690
the event loop ::
691691

692692
import asyncio
693-
try:
694-
from socket import socketpair
695-
except ImportError:
696-
from asyncio.windows_utils import socketpair
693+
from socket import socketpair
697694

698695
# Create a pair of connected sockets
699696
rsock, wsock = socketpair()

Doc/library/asyncio-stream.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,7 @@ Coroutine waiting until a socket receives data using the
426426
:func:`open_connection` function::
427427

428428
import asyncio
429-
try:
430-
from socket import socketpair
431-
except ImportError:
432-
from asyncio.windows_utils import socketpair
429+
from socket import socketpair
433430

434431
@asyncio.coroutine
435432
def wait_for_data(loop):

Doc/library/development.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ The list of modules described in this chapter is:
2424
unittest.mock-examples.rst
2525
2to3.rst
2626
test.rst
27+
28+
See also the Python development mode: the :option:`-X` ``dev`` option and
29+
:envvar:`PYTHONDEVMODE` environment variable.

Doc/library/multiprocessing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,8 +1837,8 @@ Running the following commands creates a server for a single shared queue which
18371837
remote clients can access::
18381838

18391839
>>> from multiprocessing.managers import BaseManager
1840-
>>> import queue
1841-
>>> queue = queue.Queue()
1840+
>>> from queue import Queue
1841+
>>> queue = Queue()
18421842
>>> class QueueManager(BaseManager): pass
18431843
>>> QueueManager.register('get_queue', callable=lambda:queue)
18441844
>>> m = QueueManager(address=('', 50000), authkey=b'abracadabra')

Doc/library/re.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,11 @@ form.
689689
splits occur, and the remainder of the string is returned as the final element
690690
of the list. ::
691691

692-
>>> re.split('\W+', 'Words, words, words.')
692+
>>> re.split(r'\W+', 'Words, words, words.')
693693
['Words', 'words', 'words', '']
694-
>>> re.split('(\W+)', 'Words, words, words.')
694+
>>> re.split(r'(\W+)', 'Words, words, words.')
695695
['Words', ', ', 'words', ', ', 'words', '.', '']
696-
>>> re.split('\W+', 'Words, words, words.', 1)
696+
>>> re.split(r'\W+', 'Words, words, words.', 1)
697697
['Words', 'words, words.']
698698
>>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)
699699
['0', '3', '9']
@@ -702,7 +702,7 @@ form.
702702
the string, the result will start with an empty string. The same holds for
703703
the end of the string::
704704

705-
>>> re.split('(\W+)', '...words, words...')
705+
>>> re.split(r'(\W+)', '...words, words...')
706706
['', '...', 'words', ', ', 'words', '...', '']
707707

708708
That way, separator components are always found at the same relative

Doc/library/ssl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ Certificate handling
429429
Matching of IP addresses, when present in the subjectAltName field
430430
of the certificate, is now supported.
431431

432+
.. versionchanged:: 3.7
433+
Allow wildcard when it is the leftmost and the only character
434+
in that segment.
435+
432436
.. function:: cert_time_to_seconds(cert_time)
433437

434438
Return the time in seconds since the Epoch, given the ``cert_time``

Doc/library/sys.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ always available.
334334
:const:`bytes_warning` :option:`-b`
335335
:const:`quiet` :option:`-q`
336336
:const:`hash_randomization` :option:`-R`
337+
:const:`dev_mode` :option:`-X` ``dev``
337338
============================= =============================
338339

339340
.. versionchanged:: 3.2
@@ -345,6 +346,9 @@ always available.
345346
.. versionchanged:: 3.3
346347
Removed obsolete ``division_warning`` attribute.
347348

349+
.. versionchanged:: 3.7
350+
Added ``dev_mode`` attribute for the new :option:`-X` ``dev`` flag.
351+
348352

349353
.. data:: float_info
350354

Doc/library/tracemalloc.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ Traceback
650650

651651
.. class:: Traceback
652652

653-
Sequence of :class:`Frame` instances sorted from the most recent frame to
654-
the oldest frame.
653+
Sequence of :class:`Frame` instances sorted from the oldest frame to the
654+
most recent frame.
655655

656656
A traceback contains at least ``1`` frame. If the ``tracemalloc`` module
657657
failed to get a frame, the filename ``"<unknown>"`` at line number ``0`` is
@@ -663,11 +663,17 @@ Traceback
663663
The :attr:`Trace.traceback` attribute is an instance of :class:`Traceback`
664664
instance.
665665

666-
.. method:: format(limit=None)
666+
.. versionchanged:: 3.7
667+
Frames are now sorted from the oldest to the most recent, instead of most recent to oldest.
667668

668-
Format the traceback as a list of lines with newlines. Use the
669-
:mod:`linecache` module to retrieve lines from the source code. If
670-
*limit* is set, only format the *limit* most recent frames.
669+
.. method:: format(limit=None, most_recent_first=False)
670+
671+
Format the traceback as a list of lines with newlines. Use the
672+
:mod:`linecache` module to retrieve lines from the source code.
673+
If *limit* is set, format the *limit* most recent frames if *limit*
674+
is positive. Otherwise, format the ``abs(limit)`` oldest frames.
675+
If *most_recent_first* is ``True``, the order of the formatted frames
676+
is reversed, returning the most recent frame first instead of last.
671677

672678
Similar to the :func:`traceback.format_tb` function, except that
673679
:meth:`.format` does not include newlines.

Doc/library/typing.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ See :pep:`484` for more details.
146146
``Derived`` is expected. This is useful when you want to prevent logic
147147
errors with minimal runtime cost.
148148

149+
.. versionadded:: 3.5.2
150+
149151
Callable
150152
--------
151153

@@ -494,6 +496,8 @@ The module defines the following classes, functions and decorators:
494496
``Type[Any]`` is equivalent to ``Type`` which in turn is equivalent
495497
to ``type``, which is the root of Python's metaclass hierarchy.
496498

499+
.. versionadded:: 3.5.2
500+
497501
.. class:: Iterable(Generic[T_co])
498502

499503
A generic version of :class:`collections.abc.Iterable`.
@@ -674,6 +678,8 @@ The module defines the following classes, functions and decorators:
674678

675679
A generic version of :class:`collections.defaultdict`.
676680

681+
.. versionadded:: 3.5.2
682+
677683
.. class:: Counter(collections.Counter, Dict[T, int])
678684

679685
A generic version of :class:`collections.Counter`.
@@ -762,6 +768,8 @@ The module defines the following classes, functions and decorators:
762768
def add_unicode_checkmark(text: Text) -> Text:
763769
return text + u' \u2713'
764770

771+
.. versionadded:: 3.5.2
772+
765773
.. class:: io
766774

767775
Wrapper namespace for I/O stream types.
@@ -847,6 +855,8 @@ The module defines the following classes, functions and decorators:
847855
UserId = NewType('UserId', int)
848856
first_user = UserId(1)
849857

858+
.. versionadded:: 3.5.2
859+
850860
.. function:: cast(typ, val)
851861

852862
Cast a value to a type.
@@ -1054,3 +1064,5 @@ The module defines the following classes, functions and decorators:
10541064
"forward reference", to hide the ``expensive_mod`` reference from the
10551065
interpreter runtime. Type annotations for local variables are not
10561066
evaluated, so the second annotation does not need to be enclosed in quotes.
1067+
1068+
.. versionadded:: 3.5.2

Doc/library/uuid.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,18 @@ The :mod:`uuid` module defines the following functions:
156156

157157
Get the hardware address as a 48-bit positive integer. The first time this
158158
runs, it may launch a separate program, which could be quite slow. If all
159-
attempts to obtain the hardware address fail, we choose a random 48-bit number
160-
with its eighth bit set to 1 as recommended in RFC 4122. "Hardware address"
161-
means the MAC address of a network interface, and on a machine with multiple
162-
network interfaces the MAC address of any one of them may be returned.
159+
attempts to obtain the hardware address fail, we choose a random 48-bit
160+
number with the multicast bit (least significant bit of the first octet)
161+
set to 1 as recommended in RFC 4122. "Hardware address" means the MAC
162+
address of a network interface. On a machine with multiple network
163+
interfaces, universally administered MAC addresses (i.e. where the second
164+
least significant bit of the first octet is *unset*) will be preferred over
165+
locally administered MAC addresses, but with no other ordering guarantees.
166+
167+
.. versionchanged:: 3.7
168+
Universally administered MAC addresses are preferred over locally
169+
administered MAC addresses, since the former are guaranteed to be
170+
globally unique, while the latter are not.
163171

164172
.. index:: single: getnode
165173

0 commit comments

Comments
 (0)