Skip to content

Commit 17279ae

Browse files
Merge branch 'master' into pymodule-add
2 parents 76b6063 + 7a27c7e commit 17279ae

Some content is hidden

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

70 files changed

+6576
-5589
lines changed

‎Doc/c-api/type.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,5 @@ The following functions and structs are used to create
265265
266266
The desired value of the slot. In most cases, this is a pointer
267267
to a function.
268+
269+
Slots other than ``Py_tp_doc`` may not be ``NULL``.

‎Doc/library/asyncio-policy.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ implementation used by the asyncio event loop:
209209
It works reliably even when the asyncio event loop is run in a non-main OS thread.
210210

211211
There is no noticeable overhead when handling a big number of children (*O(1)* each
212-
time a child terminates), but stating a thread per process requires extra memory.
212+
time a child terminates), but starting a thread per process requires extra memory.
213213

214214
This watcher is used by default.
215215

‎Doc/library/http.client.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ The module provides the following classes:
9999
:attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or
100100
when *cert_file* is passed with a custom *context*.
101101

102+
.. versionchanged:: 3.10
103+
This class now sends an ALPN extension with protocol indicator
104+
``http/1.1`` when no *context* is given. Custom *context* should set
105+
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
106+
102107
.. deprecated:: 3.6
103108

104109
*key_file* and *cert_file* are deprecated in favor of *context*.

‎Doc/library/os.rst‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,6 +3276,102 @@ features:
32763276
.. versionadded:: 3.8
32773277

32783278

3279+
.. function:: eventfd(initval[, flags=os.EFD_CLOEXEC])
3280+
3281+
Create and return an event file descriptor. The file descriptors supports
3282+
raw :func:`read` and :func:`write` with a buffer size of 8,
3283+
:func:`~select.select`, :func:`~select.poll` and similar. See man page
3284+
:manpage:`eventfd(2)` for more information. By default, the
3285+
new file descriptor is :ref:`non-inheritable <fd_inheritance>`.
3286+
3287+
*initval* is the initial value of the event counter. The initial value
3288+
must be an 32 bit unsigned integer. Please note that the initial value is
3289+
limited to a 32 bit unsigned int although the event counter is an unsigned
3290+
64 bit integer with a maximum value of 2\ :sup:`64`\ -\ 2.
3291+
3292+
*flags* can be constructed from :const:`EFD_CLOEXEC`,
3293+
:const:`EFD_NONBLOCK`, and :const:`EFD_SEMAPHORE`.
3294+
3295+
If :const:`EFD_SEMAPHORE` is specified and the event counter is non-zero,
3296+
:func:`eventfd_read` returns 1 and decrements the counter by one.
3297+
3298+
If :const:`EFD_SEMAPHORE` is not specified and the event counter is
3299+
non-zero, :func:`eventfd_read` returns the current event counter value and
3300+
resets the counter to zero.
3301+
3302+
If the event counter is zero and :const:`EFD_NONBLOCK` is not
3303+
specified, :func:`eventfd_read` blocks.
3304+
3305+
:func:`eventfd_write` increments the event counter. Write blocks if the
3306+
write operation would increment the counter to a value larger than
3307+
2\ :sup:`64`\ -\ 2.
3308+
3309+
Example::
3310+
3311+
import os
3312+
3313+
# semaphore with start value '1'
3314+
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
3315+
try:
3316+
# acquire semaphore
3317+
v = os.eventfd_read(fd)
3318+
try:
3319+
do_work()
3320+
finally:
3321+
# release semaphore
3322+
os.eventfd_write(fd, v)
3323+
finally:
3324+
os.close(fd)
3325+
3326+
.. availability:: Linux 2.6.27 or newer with glibc 2.8 or newer.
3327+
3328+
.. versionadded:: 3.10
3329+
3330+
.. function:: eventfd_read(fd)
3331+
3332+
Read value from an :func:`eventfd` file descriptor and return a 64 bit
3333+
unsigned int. The function does not verify that *fd* is an :func:`eventfd`.
3334+
3335+
.. availability:: See :func:`eventfd`
3336+
3337+
.. versionadded:: 3.10
3338+
3339+
.. function:: eventfd_write(fd, value)
3340+
3341+
Add value to an :func:`eventfd` file descriptor. *value* must be a 64 bit
3342+
unsigned int. The function does not verify that *fd* is an :func:`eventfd`.
3343+
3344+
.. availability:: See :func:`eventfd`
3345+
3346+
.. versionadded:: 3.10
3347+
3348+
.. data:: EFD_CLOEXEC
3349+
3350+
Set close-on-exec flag for new :func:`eventfd` file descriptor.
3351+
3352+
.. availability:: See :func:`eventfd`
3353+
3354+
.. versionadded:: 3.10
3355+
3356+
.. data:: EFD_NONBLOCK
3357+
3358+
Set :const:`O_NONBLOCK` status flag for new :func:`eventfd` file
3359+
descriptor.
3360+
3361+
.. availability:: See :func:`eventfd`
3362+
3363+
.. versionadded:: 3.10
3364+
3365+
.. data:: EFD_SEMAPHORE
3366+
3367+
Provide semaphore-like semantics for reads from a :func:`eventfd` file
3368+
descriptor. On read the internal counter is decremented by one.
3369+
3370+
.. availability:: Linux 2.6.30 or newer with glibc 2.8 or newer.
3371+
3372+
.. versionadded:: 3.10
3373+
3374+
32793375
Linux extended attributes
32803376
~~~~~~~~~~~~~~~~~~~~~~~~~
32813377

‎Doc/library/threading.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ This module defines the following functions:
7171

7272
.. versionadded:: 3.8
7373

74+
.. data:: __excepthook__
75+
76+
Holds the original value of :func:`threading.excepthook`. It is saved so that the
77+
original value can be restored in case they happen to get replaced with
78+
broken or alternative objects.
79+
80+
.. versionadded:: 3.10
7481

7582
.. function:: get_ident()
7683

‎Doc/library/types.rst‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ Additional Utility Classes and Functions
409409
return "{}({})".format(type(self).__name__, ", ".join(items))
410410

411411
def __eq__(self, other):
412-
return self.__dict__ == other.__dict__
412+
if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):
413+
return self.__dict__ == other.__dict__
414+
return NotImplemented
413415

414416
``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.
415417
However, for a structured record type use :func:`~collections.namedtuple`

‎Doc/library/urllib.request.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ The :mod:`urllib.request` module defines the following functions:
109109
.. versionchanged:: 3.4.3
110110
*context* was added.
111111

112+
.. versionchanged:: 3.10
113+
HTTPS connection now send an ALPN extension with protocol indicator
114+
``http/1.1`` when no *context* is given. Custom *context* should set
115+
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
116+
112117
.. deprecated:: 3.6
113118

114119
*cafile*, *capath* and *cadefault* are deprecated in favor of *context*.

‎Doc/library/zipimport.rst‎

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ doesn't contain :file:`.pyc` files, importing may be rather slow.
4444
follows the specification in :pep:`273`, but uses an implementation written by Just
4545
van Rossum that uses the import hooks described in :pep:`302`.
4646

47-
:pep:`302` - New Import Hooks
48-
The PEP to add the import hooks that help this module work.
47+
:mod:`importlib` - The implementation of the import machinery
48+
Package providing the relevant protocols for all importers to
49+
implement.
4950

5051

5152
This module defines an exception:
@@ -73,14 +74,49 @@ zipimporter Objects
7374
:exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid ZIP
7475
archive.
7576

76-
.. method:: find_module(fullname[, path])
77+
.. method:: create_module(spec)
78+
79+
Implementation of :meth:`importlib.abc.Loader.create_module` that returns
80+
:const:`None` to explicitly request the default semantics.
81+
82+
.. versionadded:: 3.10
83+
84+
85+
.. method:: exec_module(module)
86+
87+
Implementation of :meth:`importlib.abc.Loader.exec_module`.
88+
89+
.. versionadded:: 3.10
90+
91+
92+
.. method:: find_loader(fullname, path=None)
93+
94+
An implementation of :meth:`importlib.abc.PathEntryFinder.find_loader`.
95+
96+
.. deprecated:: 3.10
97+
98+
Use :meth:`find_spec` instead.
99+
100+
101+
.. method:: find_module(fullname, path=None)
77102

78103
Search for a module specified by *fullname*. *fullname* must be the fully
79104
qualified (dotted) module name. It returns the zipimporter instance itself
80105
if the module was found, or :const:`None` if it wasn't. The optional
81106
*path* argument is ignored---it's there for compatibility with the
82107
importer protocol.
83108

109+
.. deprecated:: 3.10
110+
111+
Use :meth:`find_spec` instead.
112+
113+
114+
.. method:: find_spec(fullname, target=None)
115+
116+
An implementation of :meth:`importlib.abc.PathEntryFinder.find_spec`.
117+
118+
.. versionadded:: 3.10
119+
84120

85121
.. method:: get_code(fullname)
86122

@@ -126,6 +162,10 @@ zipimporter Objects
126162
qualified (dotted) module name. It returns the imported module, or raises
127163
:exc:`ZipImportError` if it wasn't found.
128164

165+
.. deprecated:: 3.10
166+
167+
Use :meth:`exec_module` instead.
168+
129169

130170
.. attribute:: archive
131171

‎Doc/tools/extensions/c_annotations.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def add_annotations(self, app, doctree):
7979
classes=['stableabi']))
8080
if par['objtype'] != 'function':
8181
continue
82-
if not par[0].has_key('names') or not par[0]['names']:
82+
if not par[0].has_key('ids') or not par[0]['ids']:
8383
continue
84-
name = par[0]['names'][0]
84+
name = par[0]['ids'][0]
8585
if name.startswith("c."):
8686
name = name[2:]
8787
entry = self.get(name)

‎Doc/whatsnew/3.10.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ os
229229
Added :func:`os.cpu_count()` support for VxWorks RTOS.
230230
(Contributed by Peixing Xin in :issue:`41440`.)
231231

232+
Added a new function :func:`os.eventfd` and related helpers to wrap the
233+
``eventfd2`` syscall on Linux.
234+
(Contributed by Christian Heimes in :issue:`41001`.)
235+
232236
py_compile
233237
----------
234238

@@ -263,6 +267,11 @@ retrieve the functions set by :func:`threading.settrace` and
263267
:func:`threading.setprofile` respectively.
264268
(Contributed by Mario Corchero in :issue:`42251`.)
265269

270+
Add :data:`threading.__excepthook__` to allow retrieving the original value
271+
of :func:`threading.excepthook` in case it is set to a broken or a different
272+
value.
273+
(Contributed by Mario Corchero in :issue:`42308`.)
274+
266275
traceback
267276
---------
268277

@@ -294,6 +303,13 @@ Add a :class:`~xml.sax.handler.LexicalHandler` class to the
294303
:mod:`xml.sax.handler` module.
295304
(Contributed by Jonathan Gossage and Zackery Spytz in :issue:`35018`.)
296305

306+
zipimport
307+
---------
308+
Add methods related to :pep:`451`: :meth:`~zipimport.zipimporter.find_spec`,
309+
:meth:`zipimport.zipimporter.create_module`, and
310+
:meth:`zipimport.zipimporter.exec_module`.
311+
(Contributed by Brett Cannon in :issue:`42131`.
312+
297313

298314
Optimizations
299315
=============

0 commit comments

Comments
 (0)