Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 643681c

Browse files
author
Anselm Kruis
committed
merge branch 3.5 just after tagging v3.5.1
2 parents 6961b07 + 0c398eb commit 643681c

File tree

117 files changed

+1743
-13542
lines changed

Some content is hidden

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

117 files changed

+1743
-13542
lines changed

.hgtags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,5 @@ cc15d736d860303b9da90d43cd32db39bab048df v3.5.0rc2
178178
66ed52375df802f9d0a34480daaa8ce79fc41313 v3.5.0rc3
179179
2d033fedfa7f1e325fd14ccdaa9cb42155da206f v3.5.0rc4
180180
374f501f4567b7595f2ad7798aa09afa2456bb28 v3.5.0
181+
948ef16a69513ba1ff15c9d7d0b012b949df4c80 v3.5.1rc1
182+
37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1

Doc/howto/clinic.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,18 +1249,18 @@ Here's the simplest example of a custom converter, from ``Modules/zlibmodule.c``
12491249

12501250
/*[python input]
12511251

1252-
class uint_converter(CConverter):
1252+
class capped_uint_converter(CConverter):
12531253
type = 'unsigned int'
1254-
converter = 'uint_converter'
1254+
converter = 'capped_uint_converter'
12551255

12561256
[python start generated code]*/
1257-
/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
1257+
/*[python end generated code: output=da39a3ee5e6b4b0d input=35521e4e733823c7]*/
12581258

1259-
This block adds a converter to Argument Clinic named ``uint``. Parameters
1260-
declared as ``uint`` will be declared as type ``unsigned int``, and will
1261-
be parsed by the ``'O&'`` format unit, which will call the ``uint_converter``
1262-
converter function.
1263-
``uint`` variables automatically support default values.
1259+
This block adds a converter to Argument Clinic named ``capped_uint``. Parameters
1260+
declared as ``capped_uint`` will be declared as type ``unsigned int``, and will
1261+
be parsed by the ``'O&'`` format unit, which will call the
1262+
``capped_uint_converter`` converter function. ``capped_uint`` variables
1263+
automatically support default values.
12641264

12651265
More sophisticated custom converters can insert custom C code to
12661266
handle initialization and cleanup.

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ The abstract grammar is currently defined as follows:
104104
:mod:`ast` Helpers
105105
------------------
106106

107-
Apart from the node classes, :mod:`ast` module defines these utility functions
107+
Apart from the node classes, the :mod:`ast` module defines these utility functions
108108
and classes for traversing abstract syntax trees:
109109

110110
.. function:: parse(source, filename='<unknown>', mode='exec')

Doc/library/asyncio-eventloop.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ Run an event loop
2929

3030
.. method:: BaseEventLoop.run_forever()
3131

32-
Run until :meth:`stop` is called.
32+
Run until :meth:`stop` is called. If :meth:`stop` is called before
33+
:meth:`run_forever()` is called, this polls the I/O selector once
34+
with a timeout of zero, runs all callbacks scheduled in response to
35+
I/O events (and those that were already scheduled), and then exits.
36+
If :meth:`stop` is called while :meth:`run_forever` is running,
37+
this will run the current batch of callbacks and then exit. Note
38+
that callbacks scheduled by callbacks will not run in that case;
39+
they will run the next time :meth:`run_forever` is called.
40+
41+
.. versionchanged:: 3.5.1
3342

3443
.. method:: BaseEventLoop.run_until_complete(future)
3544

@@ -48,10 +57,10 @@ Run an event loop
4857

4958
Stop running the event loop.
5059

51-
Every callback scheduled before :meth:`stop` is called will run.
52-
Callbacks scheduled after :meth:`stop` is called will not run.
53-
However, those callbacks will run if :meth:`run_forever` is called
54-
again later.
60+
This causes :meth:`run_forever` to exit at the next suitable
61+
opportunity (see there for more details).
62+
63+
.. versionchanged:: 3.5.1
5564

5665
.. method:: BaseEventLoop.is_closed()
5766

@@ -61,7 +70,8 @@ Run an event loop
6170

6271
.. method:: BaseEventLoop.close()
6372

64-
Close the event loop. The loop must not be running.
73+
Close the event loop. The loop must not be running. Pending
74+
callbacks will be lost.
6575

6676
This clears the queues and shuts down the executor, but does not wait for
6777
the executor to finish.

Doc/library/asyncio-protocol.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ BaseTransport
4141
protocol's :meth:`connection_lost` method will be called with
4242
:const:`None` as its argument.
4343

44+
.. method:: is_closing(self)
45+
46+
Return ``True`` if the transport is closing or is closed.
47+
48+
.. versionadded:: 3.5.1
4449

4550
.. method:: get_extra_info(name, default=None)
4651

@@ -489,7 +494,7 @@ data and wait until the connection is closed::
489494

490495
def connection_lost(self, exc):
491496
print('The server closed the connection')
492-
print('Stop the event lop')
497+
print('Stop the event loop')
493498
self.loop.stop()
494499

495500
loop = asyncio.get_event_loop()

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,4 +721,4 @@ Task functions
721721
Unlike the functions above, :func:`run_coroutine_threadsafe` requires the
722722
*loop* argument to be passed explicitely.
723723

724-
.. versionadded:: 3.4.4
724+
.. versionadded:: 3.4.4, 3.5.1

Doc/library/collections.rst

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,15 @@ functionality with a subclass. Here is how to add a calculated field and
905905
a fixed-width print format:
906906

907907
>>> class Point(namedtuple('Point', 'x y')):
908-
__slots__ = ()
909-
@property
910-
def hypot(self):
911-
return (self.x ** 2 + self.y ** 2) ** 0.5
912-
def __str__(self):
913-
return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
908+
__slots__ = ()
909+
@property
910+
def hypot(self):
911+
return (self.x ** 2 + self.y ** 2) ** 0.5
912+
def __str__(self):
913+
return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
914914

915915
>>> for p in Point(3, 4), Point(14, 5/7):
916-
print(p)
916+
print(p)
917917
Point: x= 3.000 y= 4.000 hypot= 5.000
918918
Point: x=14.000 y= 0.714 hypot=14.018
919919

@@ -929,10 +929,10 @@ Docstrings can be customized by making direct assignments to the ``__doc__``
929929
fields:
930930

931931
>>> Book = namedtuple('Book', ['id', 'title', 'authors'])
932-
>>> Book.__doc__ = 'Hardcover book in active collection'
932+
>>> Book.__doc__ += ': Hardcover book in active collection'
933933
>>> Book.id.__doc__ = '13-digit ISBN'
934934
>>> Book.title.__doc__ = 'Title of first printing'
935-
>>> Book.author.__doc__ = 'List of authors sorted by last name'
935+
>>> Book.authors.__doc__ = 'List of authors sorted by last name'
936936

937937
Default values can be implemented by using :meth:`_replace` to
938938
customize a prototype instance:
@@ -942,16 +942,6 @@ customize a prototype instance:
942942
>>> johns_account = default_account._replace(owner='John')
943943
>>> janes_account = default_account._replace(owner='Jane')
944944

945-
Enumerated constants can be implemented with named tuples, but it is simpler
946-
and more efficient to use a simple :class:`~enum.Enum`:
947-
948-
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
949-
>>> Status.open, Status.pending, Status.closed
950-
(0, 1, 2)
951-
>>> from enum import Enum
952-
>>> class Status(Enum):
953-
... open, pending, closed = range(3)
954-
955945

956946
.. seealso::
957947

Doc/library/copy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ of lists by assigning a slice of the entire list, for example,
6767

6868
Classes can use the same interfaces to control copying that they use to control
6969
pickling. See the description of module :mod:`pickle` for information on these
70-
methods. In fact, :mod:`copy` module uses the registered pickle functions from
71-
:mod:`copyreg` module.
70+
methods. In fact, the :mod:`copy` module uses the registered
71+
pickle functions from the :mod:`copyreg` module.
7272

7373
.. index::
7474
single: __copy__() (copy protocol)

Doc/library/enum.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -730,18 +730,24 @@ member instances.
730730
Finer Points
731731
^^^^^^^^^^^^
732732

733-
Enum members are instances of an Enum class, and even though they are
734-
accessible as `EnumClass.member`, they are not accessible directly from
735-
the member::
736-
737-
>>> Color.red
738-
<Color.red: 1>
739-
>>> Color.red.blue
740-
Traceback (most recent call last):
733+
:class:`Enum` members are instances of an :class:`Enum` class, and even
734+
though they are accessible as `EnumClass.member`, they should not be accessed
735+
directly from the member as that lookup may fail or, worse, return something
736+
besides the :class:`Enum` member you looking for::
737+
738+
>>> class FieldTypes(Enum):
739+
... name = 0
740+
... value = 1
741+
... size = 2
741742
...
742-
AttributeError: 'Color' object has no attribute 'blue'
743+
>>> FieldTypes.value.size
744+
<FieldTypes.size: 2>
745+
>>> FieldTypes.size.value
746+
2
747+
748+
.. versionchanged:: 3.5
743749

744-
Likewise, the :attr:`__members__` is only available on the class.
750+
The :attr:`__members__` attribute is only available on the class.
745751

746752
If you give your :class:`Enum` subclass extra methods, like the `Planet`_
747753
class above, those methods will show up in a :func:`dir` of the member,

Doc/library/fcntl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The module defines the following functions:
8383
buffer 1024 bytes long which is then passed to :func:`ioctl` and copied back
8484
into the supplied buffer.
8585

86+
If the :c:func:`ioctl` fails, an :exc:`IOError` exception is raised.
87+
8688
An example::
8789

8890
>>> import array, fcntl, struct, termios, os
@@ -104,6 +106,8 @@ The module defines the following functions:
104106
:manpage:`flock(2)` for details. (On some systems, this function is emulated
105107
using :c:func:`fcntl`.)
106108

109+
If the :c:func:`flock` fails, an :exc:`IOError` exception is raised.
110+
107111

108112
.. function:: lockf(fd, cmd, len=0, start=0, whence=0)
109113

Doc/library/ftplib.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ The module defines the following items:
5252
will be used). *source_address* is a 2-tuple ``(host, port)`` for the socket
5353
to bind to as its source address before connecting.
5454

55-
:class:`FTP` class supports the :keyword:`with` statement. Here is a sample
56-
on how using it:
55+
The :class:`FTP` class supports the :keyword:`with` statement, e.g.:
5756

5857
>>> from ftplib import FTP
5958
>>> with FTP("ftp1.at.proftpd.org") as ftp:
@@ -418,8 +417,8 @@ FTP_TLS Objects
418417

419418
.. method:: FTP_TLS.auth()
420419

421-
Set up secure control connection by using TLS or SSL, depending on what
422-
specified in :meth:`ssl_version` attribute.
420+
Set up a secure control connection by using TLS or SSL, depending on what
421+
is specified in the :attr:`ssl_version` attribute.
423422

424423
.. versionchanged:: 3.4
425424
The method now supports hostname check with

Doc/library/glob.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
--------------
1313

1414
The :mod:`glob` module finds all the pathnames matching a specified pattern
15-
according to the rules used by the Unix shell. No tilde expansion is done, but
16-
``*``, ``?``, and character ranges expressed with ``[]`` will be correctly
17-
matched. This is done by using the :func:`os.listdir` and
18-
:func:`fnmatch.fnmatch` functions in concert, and not by actually invoking a
19-
subshell. Note that unlike :func:`fnmatch.fnmatch`, :mod:`glob` treats
20-
filenames beginning with a dot (``.``) as special cases. (For tilde and shell
21-
variable expansion, use :func:`os.path.expanduser` and
15+
according to the rules used by the Unix shell, although results are returned in
16+
arbitrary order. No tilde expansion is done, but ``*``, ``?``, and character
17+
ranges expressed with ``[]`` will be correctly matched. This is done by using
18+
the :func:`os.listdir` and :func:`fnmatch.fnmatch` functions in concert, and
19+
not by actually invoking a subshell. Note that unlike :func:`fnmatch.fnmatch`,
20+
:mod:`glob` treats filenames beginning with a dot (``.``) as special cases.
21+
(For tilde and shell variable expansion, use :func:`os.path.expanduser` and
2222
:func:`os.path.expandvars`.)
2323

2424
For a literal match, wrap the meta-characters in brackets.

Doc/library/linecache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The :mod:`linecache` module defines the following functions:
4949

5050
.. function:: lazycache(filename, module_globals)
5151

52-
Capture enough detail about a non-file based module to permit getting its
52+
Capture enough detail about a non-file-based module to permit getting its
5353
lines later via :func:`getline` even if *module_globals* is None in the later
5454
call. This avoids doing I/O until a line is actually needed, without having
5555
to carry the module globals around indefinitely.

Doc/library/nntplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ The module itself defines the following classes:
6969
connecting to an NNTP server on the local machine and intend to call
7070
reader-specific commands, such as ``group``. If you get unexpected
7171
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*.
72-
:class:`NNTP` class supports the :keyword:`with` statement to
72+
The :class:`NNTP` class supports the :keyword:`with` statement to
7373
unconditionally consume :exc:`OSError` exceptions and to close the NNTP
74-
connection when done. Here is a sample on how using it:
74+
connection when done, e.g.:
7575

7676
>>> from nntplib import NNTP
7777
>>> with NNTP('news.gmane.org') as n:

Doc/library/re.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,15 @@ form.
556556
.. data:: X
557557
VERBOSE
558558

559-
This flag allows you to write regular expressions that look nicer. Whitespace
560-
within the pattern is ignored, except when in a character class or preceded by
561-
an unescaped backslash, and, when a line contains a ``'#'`` neither in a
562-
character class or preceded by an unescaped backslash, all characters from the
563-
leftmost such ``'#'`` through the end of the line are ignored.
564-
565-
That means that the two following regular expression objects that match a
559+
This flag allows you to write regular expressions that look nicer and are
560+
more readable by allowing you to visually separate logical sections of the
561+
pattern and add comments. Whitespace within the pattern is ignored, except
562+
when in a character class or when preceded by an unescaped backslash.
563+
When a line contains a ``#`` that is not in a character class and is not
564+
preceded by an unescaped backslash, all characters from the leftmost such
565+
``#`` through the end of the line are ignored.
566+
567+
This means that the two following regular expression objects that match a
566568
decimal number are functionally equal::
567569

568570
a = re.compile(r"""\d + # the integral part

Doc/library/resource.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,7 @@ These functions are used to retrieve resource usage information:
316316
.. function:: getpagesize()
317317

318318
Returns the number of bytes in a system page. (This need not be the same as the
319-
hardware page size.) This function is useful for determining the number of bytes
320-
of memory a process is using. The third element of the tuple returned by
321-
:func:`getrusage` describes memory usage in pages; multiplying by page size
322-
produces number of bytes.
319+
hardware page size.)
323320

324321
The following :const:`RUSAGE_\*` symbols are passed to the :func:`getrusage`
325322
function to specify which processes information should be provided for.

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ The module defines the following classes, functions and decorators:
478478

479479
Usage::
480480

481-
Employee = typing.NamedTuple('Employee', [('name', str), 'id', int)])
481+
Employee = typing.NamedTuple('Employee', [('name', str), ('id', int)])
482482

483483
This is equivalent to::
484484

Doc/library/urllib.request.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ The code for the sample CGI used in the above example is::
11681168
#!/usr/bin/env python
11691169
import sys
11701170
data = sys.stdin.read()
1171-
print('Content-type: text-plain\n\nGot Data: "%s"' % data)
1171+
print('Content-type: text/plain\n\nGot Data: "%s"' % data)
11721172

11731173
Here is an example of doing a ``PUT`` request using :class:`Request`::
11741174

Doc/library/zlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Decompression objects support the following methods and attributes:
230230
:meth:`decompress` method. Some of the input data may be preserved in internal
231231
buffers for later processing.
232232

233-
If the optional parameter *max_length* is supplied then the return value will be
233+
If the optional parameter *max_length* is non-zero then the return value will be
234234
no longer than *max_length*. This may mean that not all of the compressed input
235235
can be processed; and unconsumed data will be stored in the attribute
236236
:attr:`unconsumed_tail`. This bytestring must be passed to a subsequent call to

Doc/reference/executionmodel.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Execution model
1111

1212
.. _prog_structure:
1313

14-
Structure of a programm
15-
=======================
14+
Structure of a program
15+
======================
1616

1717
.. index:: block
1818

@@ -270,4 +270,3 @@ and :keyword:`raise` statement in section :ref:`raise`.
270270

271271
.. [#] This limitation occurs because the code that is executed by these operations
272272
is not available at the time the module is compiled.
273-

0 commit comments

Comments
 (0)