Skip to content

Commit bbdc07a

Browse files
authored
Merge branch 'main' into pyio-take-bytes
2 parents d01c925 + 57a0e57 commit bbdc07a

64 files changed

Lines changed: 905 additions & 148 deletions

File tree

Some content is hidden

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

Doc/deprecations/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Deprecations
1313

1414
.. include:: pending-removal-in-3.20.rst
1515

16+
.. include:: pending-removal-in-3.21.rst
17+
1618
.. include:: pending-removal-in-future.rst
1719

1820
.. include:: soft-deprecations.rst
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Pending removal in Python 3.21
2+
------------------------------
3+
4+
* :mod:`ast`:
5+
6+
* Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``,
7+
``AugLoad`` and ``AugStore``, will be removed in Python 3.21. These types
8+
are not generated by the parser or accepted by the code generator.
9+
* The ``dims`` property of ``ast.Tuple`` will be removed in Python 3.21. Use
10+
the ``ast.Tuple.elts`` property instead.

Doc/library/imaplib.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ An :class:`IMAP4` instance has the following methods:
199199

200200
Append *message* to named mailbox.
201201

202+
*flags* may be ``None`` or a string of IMAP flag tokens. Multiple
203+
flags are separated by spaces, for example ``r'\Seen \Answered'``.
204+
If *flags* is not already enclosed in parentheses, parentheses are
205+
added automatically.
206+
202207

203208
.. method:: IMAP4.authenticate(mechanism, authobject)
204209

Doc/library/inspect.rst

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,24 +424,63 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
424424

425425
Return ``True`` if the object is a bound method written in Python.
426426

427+
.. note::
427428

428-
.. function:: ispackage(object)
429+
For example, given this class::
429430

430-
Return ``True`` if the object is a :term:`package`.
431+
>>> class Greeter:
432+
... def say_hello(self):
433+
... print('hello!')
431434

432-
.. versionadded:: 3.14
435+
A bound method (also known as an *instance method*) is created when
436+
accessing ``say_hello`` (a :term:`function` defined in the
437+
``Greeter`` namespace) through an instance of the ``Greeter`` class::
438+
439+
>>> instance = Greeter()
440+
441+
>>> instance.say_hello
442+
<bound method Greeter.say_hello of <__main__.Greeter object ...>>
443+
>>> ismethod(instance.say_hello)
444+
True
445+
>>> isfunction(instance.say_hello)
446+
False
447+
448+
Accessing ``say_hello`` through the ``Greeter`` class will return the
449+
function itself. For this function, :func:`ismethod` will return
450+
``False``, but :func:`isfunction` will return ``True``::
451+
452+
>>> Greeter.say_hello
453+
<function Greeter.say_hello at 0x7f7503854a90>
454+
>>> ismethod(Greeter.say_hello)
455+
False
456+
>>> isfunction(Greeter.say_hello)
457+
True
458+
459+
See :ref:`typesmethods` for details.
433460

434461

435462
.. function:: isfunction(object)
436463

437464
Return ``True`` if the object is a Python function, which includes functions
438465
created by a :term:`lambda` expression.
439466

467+
See the note for :func:`~inspect.ismethod` for an example.
468+
469+
470+
.. function:: ispackage(object)
471+
472+
Return ``True`` if the object is a :term:`package`.
473+
474+
.. versionadded:: 3.14
475+
440476

441477
.. function:: isgeneratorfunction(object)
442478

443479
Return ``True`` if the object is a Python generator function.
444480

481+
It also returns ``True`` for bound methods created from Python generator functions
482+
(see :ref:`typesmethods` for more information).
483+
445484
.. versionchanged:: 3.8
446485
Functions wrapped in :func:`functools.partial` now return ``True`` if the
447486
wrapped function is a Python generator function.

Doc/library/multiprocessing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ To show the individual process IDs involved, here is an expanded example::
100100
For an explanation of why the ``if __name__ == '__main__'`` part is
101101
necessary, see :ref:`multiprocessing-programming`.
102102

103-
The arguments to :class:`Process` usually need to be unpickleable from within
104-
the child process. If you tried typing the above example directly into a REPL it
105-
could lead to an :exc:`AttributeError` in the child process trying to locate the
106-
*f* function in the ``__main__`` module.
103+
The arguments to :class:`Process` usually need to be picklable so they can be
104+
passed to the child process. If you tried typing the above example directly
105+
into a REPL it could lead to an :exc:`AttributeError` in the child process
106+
trying to locate the *f* function in the ``__main__`` module.
107107

108108

109109
.. _multiprocessing-start-methods:

Doc/library/os.rst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,8 @@ features:
25492549
Windows now handles a *mode* of ``0o700``.
25502550

25512551

2552-
.. function:: makedirs(name, mode=0o777, exist_ok=False)
2552+
.. function:: makedirs(name, mode=0o777, exist_ok=False, *, \
2553+
parent_mode=None)
25532554

25542555
.. index::
25552556
single: directory; creating
@@ -2567,6 +2568,12 @@ features:
25672568
If *exist_ok* is ``False`` (the default), a :exc:`FileExistsError` is
25682569
raised if the target directory already exists.
25692570

2571+
If *parent_mode* is not ``None``, it is used as the mode for any
2572+
newly-created, intermediate-level directories. Like *mode*, it is
2573+
combined with the process's umask value; see :ref:`the mkdir()
2574+
description <mkdir_modebits>`. Otherwise, intermediate directories are
2575+
created with the default mode, which is also subject to the umask.
2576+
25702577
.. note::
25712578

25722579
:func:`makedirs` will become confused if the path elements to create
@@ -2593,6 +2600,11 @@ features:
25932600
The *mode* argument no longer affects the file permission bits of
25942601
newly created intermediate-level directories.
25952602

2603+
.. versionadded:: 3.15
2604+
The *parent_mode* parameter. To match the behavior from Python 3.6 and
2605+
earlier (where *mode* was applied to all created directories), pass
2606+
``parent_mode=mode``.
2607+
25962608

25972609
.. function:: mkfifo(path, mode=0o666, *, dir_fd=None)
25982610

@@ -5062,6 +5074,18 @@ written in Python, such as a mail server's external command delivery program.
50625074
.. availability:: Linux >= 5.10
50635075
.. versionadded:: 3.12
50645076

5077+
.. function:: pidfd_getfd(pidfd, targetfd, *, flags=0)
5078+
5079+
Duplicate *targetfd* from the process referred to by the process file
5080+
descriptor *pidfd*, into the calling process. The returned file descriptor
5081+
is :ref:`non-inheritable <fd_inheritance>`.
5082+
5083+
*flags* is reserved, and currently must be ``0``.
5084+
5085+
See the :manpage:`pidfd_getfd(2)` man page for more details.
5086+
5087+
.. availability:: Linux >= 5.6, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
5088+
.. versionadded:: next
50655089

50665090
.. function:: plock(op, /)
50675091

Doc/library/pathlib.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,8 @@ Creating files and directories
15181518
:meth:`~Path.write_bytes` methods are often used to create files.
15191519

15201520

1521-
.. method:: Path.mkdir(mode=0o777, parents=False, exist_ok=False)
1521+
.. method:: Path.mkdir(mode=0o777, parents=False, exist_ok=False, *, \
1522+
parent_mode=None)
15221523

15231524
Create a new directory at this given path. If *mode* is given, it is
15241525
combined with the process's ``umask`` value to determine the file mode
@@ -1529,6 +1530,12 @@ Creating files and directories
15291530
as needed; they are created with the default permissions without taking
15301531
*mode* into account (mimicking the POSIX ``mkdir -p`` command).
15311532

1533+
If *parent_mode* is not ``None``, it is used as the mode for any
1534+
newly-created, intermediate-level directories when *parents* is true.
1535+
Like *mode*, it is combined with the process's ``umask`` value.
1536+
Otherwise, intermediate directories are created with the default
1537+
permissions (also subject to the umask).
1538+
15321539
If *parents* is false (the default), a missing parent raises
15331540
:exc:`FileNotFoundError`.
15341541

@@ -1542,6 +1549,9 @@ Creating files and directories
15421549
.. versionchanged:: 3.5
15431550
The *exist_ok* parameter was added.
15441551

1552+
.. versionadded:: 3.15
1553+
The *parent_mode* parameter.
1554+
15451555

15461556
.. method:: Path.symlink_to(target, target_is_directory=False)
15471557

Doc/library/ssl.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ to speed up repeated connections from the same clients.
20762076
:attr:`~SSLContext.minimum_version` and
20772077
:attr:`SSLContext.options` all affect the supported SSL
20782078
and TLS versions of the context. The implementation does not prevent
2079-
invalid combination. For example a context with
2079+
invalid combinations. For example a context with
20802080
:attr:`OP_NO_TLSv1_2` in :attr:`~SSLContext.options` and
20812081
:attr:`~SSLContext.maximum_version` set to :attr:`TLSVersion.TLSv1_2`
20822082
will not be able to establish a TLS 1.2 connection.
@@ -2891,11 +2891,11 @@ disabled by default.
28912891
::
28922892

28932893
>>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2894-
>>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3
2894+
>>> client_context.minimum_version = ssl.TLSVersion.TLSv1_2
28952895
>>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3
28962896

28972897

2898-
The SSL context created above will only allow TLSv1.3 and later (if
2898+
The SSL client context created above will only allow TLSv1.2 and TLSv1.3 (if
28992899
supported by your system) connections to a server. :const:`PROTOCOL_TLS_CLIENT`
29002900
implies certificate validation and hostname checks by default. You have to
29012901
load certificates into the context.

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,10 @@ os
12851285
glibc versions 2.28 and later.
12861286
(Contributed by Jeffrey Bosboom and Victor Stinner in :gh:`83714`.)
12871287

1288+
* :func:`os.makedirs` function now has a *parent_mode* parameter that allows
1289+
specifying the mode for intermediate directories. This can be used to match
1290+
the behavior from Python 3.6 and earlier by passing ``parent_mode=mode``.
1291+
(Contributed by Zackery Spytz and Gregory P. Smith in :gh:`86533`.)
12881292

12891293
os.path
12901294
-------
@@ -2057,6 +2061,10 @@ importlib.resources
20572061
pathlib
20582062
-------
20592063

2064+
* :meth:`pathlib.Path.mkdir` now has a *parent_mode* parameter that allows
2065+
specifying the mode for intermediate directories when ``parents=True``.
2066+
(Contributed by Gregory P. Smith in :gh:`86533`.)
2067+
20602068
* Removed deprecated :meth:`!pathlib.PurePath.is_reserved`.
20612069
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
20622070
(Contributed by Nikita Sobolev in :gh:`133875`.)

Doc/whatsnew/3.16.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ New modules
8686
Improved modules
8787
================
8888

89-
module_name
90-
-----------
89+
os
90+
--
9191

92-
* TODO
92+
* Add :func:`os.pidfd_getfd` for duplicating a file descriptor from another
93+
process via a pidfd. Available on Linux 5.6+.
94+
(Contributed by Maurycy Pawłowski-Wieroński in :gh:`149464`.)
9395

9496
.. Add improved modules above alphabetically, not here at the end.
9597
@@ -182,9 +184,16 @@ tarfile
182184
Deprecated
183185
==========
184186

185-
* module_name:
186-
TODO
187+
* :mod:`ast`:
187188

189+
* Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``,
190+
``AugLoad`` and ``AugStore``, deprecated since Python 3.9, are no longer
191+
imported by ``from ast import *`` and issue a deprecation warning on
192+
use. The classes are slated for removal in Python 3.21. These types are not
193+
generated by the parser or accepted by the code generator.
194+
* The ``dims`` property of ``ast.Tuple`` objects, deprecated since Python
195+
3.9, now issues a deprecation warning on use. This property is slated for
196+
removal in 3.21. Use ``ast.Tuple.elts`` instead.
188197

189198
.. Add deprecations above alphabetically, not here at the end.
190199

0 commit comments

Comments
 (0)