Skip to content

Commit 2acd7a9

Browse files
Merge branch 'main' into bitfields
2 parents 61b0b7f + 454a6d6 commit 2acd7a9

Some content is hidden

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

68 files changed

+834
-1527
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# It uses the same pattern rule for gitignore file
55
# https://git-scm.com/docs/gitignore#_pattern_format
66

7+
# GitHub
8+
.github/** @ezio-melotti
9+
710
# asyncio
811
**/*asyncio* @1st1 @asvetlov @gvanrossum
912

.github/CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ also suggestions on how you can most effectively help the project.
3838

3939
Please be aware that our workflow does deviate slightly from the typical GitHub
4040
project. Details on how to properly submit a pull request are covered in
41-
`Lifecycle of a Pull Request <https://devguide.python.org/pullrequest/>`_.
41+
`Lifecycle of a Pull Request <https://devguide.python.org/getting-started/pull-request-lifecycle.html>`_.
4242
We utilize various bots and status checks to help with this, so do follow the
4343
comments they leave and their "Details" links, respectively. The key points of
4444
our workflow that are not covered by a bot or status check are:

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
permissions:
2626
contents: read
2727

28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
30+
cancel-in-progress: true
31+
2832
jobs:
2933
check_source:
3034
name: 'Check for source changes'

.github/workflows/build_msi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
permissions:
1919
contents: read
2020

21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
23+
cancel-in-progress: true
24+
2125
jobs:
2226
build:
2327
name: Windows Installer

.github/workflows/doc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ on:
2828
permissions:
2929
contents: read
3030

31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
33+
cancel-in-progress: true
34+
3135
jobs:
3236
build_doc:
3337
name: 'Docs'

.github/workflows/project-updater.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- opened
77
- labeled
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
add-to-project:
1114
name: Add issues to projects

.github/workflows/verify-ensurepip-wheels.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
permissions:
1717
contents: read
1818

19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
1923
jobs:
2024
verify:
2125
runs-on: ubuntu-latest

Doc/c-api/buffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
9999
For :term:`contiguous` arrays, the value points to the beginning of
100100
the memory block.
101101

102-
.. c:member:: void *obj
102+
.. c:member:: PyObject *obj
103103
104104
A new reference to the exporting object. The reference is owned by
105105
the consumer and automatically decremented and set to ``NULL`` by

Doc/c-api/memoryview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ any other object.
5555
*mview* **must** be a memoryview instance; this macro doesn't check its type,
5656
you must do it yourself or you will risk crashes.
5757
58-
.. c:function:: Py_buffer *PyMemoryView_GET_BASE(PyObject *mview)
58+
.. c:function:: PyObject *PyMemoryView_GET_BASE(PyObject *mview)
5959
6060
Return either a pointer to the exporting object that the memoryview is based
6161
on or ``NULL`` if the memoryview has been created by one of the functions

Doc/howto/descriptor.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ afterwards, :meth:`__set_name__` will need to be called manually.
847847
ORM example
848848
-----------
849849

850-
The following code is simplified skeleton showing how data descriptors could
850+
The following code is a simplified skeleton showing how data descriptors could
851851
be used to implement an `object relational mapping
852852
<https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping>`_.
853853

@@ -1535,6 +1535,8 @@ by member descriptors:
15351535
def __get__(self, obj, objtype=None):
15361536
'Emulate member_get() in Objects/descrobject.c'
15371537
# Also see PyMember_GetOne() in Python/structmember.c
1538+
if obj is None:
1539+
return self
15381540
value = obj._slotvalues[self.offset]
15391541
if value is null:
15401542
raise AttributeError(self.name)
@@ -1563,13 +1565,13 @@ variables:
15631565
class Type(type):
15641566
'Simulate how the type metaclass adds member objects for slots'
15651567

1566-
def __new__(mcls, clsname, bases, mapping):
1568+
def __new__(mcls, clsname, bases, mapping, **kwargs):
15671569
'Emulate type_new() in Objects/typeobject.c'
15681570
# type_new() calls PyTypeReady() which calls add_methods()
15691571
slot_names = mapping.get('slot_names', [])
15701572
for offset, name in enumerate(slot_names):
15711573
mapping[name] = Member(name, clsname, offset)
1572-
return type.__new__(mcls, clsname, bases, mapping)
1574+
return type.__new__(mcls, clsname, bases, mapping, **kwargs)
15731575
15741576
The :meth:`object.__new__` method takes care of creating instances that have
15751577
slots instead of an instance dictionary. Here is a rough simulation in pure
@@ -1580,7 +1582,7 @@ Python:
15801582
class Object:
15811583
'Simulate how object.__new__() allocates memory for __slots__'
15821584

1583-
def __new__(cls, *args):
1585+
def __new__(cls, *args, **kwargs):
15841586
'Emulate object_new() in Objects/typeobject.c'
15851587
inst = super().__new__(cls)
15861588
if hasattr(cls, 'slot_names'):
@@ -1593,7 +1595,7 @@ Python:
15931595
cls = type(self)
15941596
if hasattr(cls, 'slot_names') and name not in cls.slot_names:
15951597
raise AttributeError(
1596-
f'{type(self).__name__!r} object has no attribute {name!r}'
1598+
f'{cls.__name__!r} object has no attribute {name!r}'
15971599
)
15981600
super().__setattr__(name, value)
15991601

@@ -1602,7 +1604,7 @@ Python:
16021604
cls = type(self)
16031605
if hasattr(cls, 'slot_names') and name not in cls.slot_names:
16041606
raise AttributeError(
1605-
f'{type(self).__name__!r} object has no attribute {name!r}'
1607+
f'{cls.__name__!r} object has no attribute {name!r}'
16061608
)
16071609
super().__delattr__(name)
16081610

Doc/library/copyreg.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@ Such constructors may be factory functions or class instances.
2525
hence not valid as a constructor), raises :exc:`TypeError`.
2626

2727

28-
.. function:: pickle(type, function, constructor=None)
28+
.. function:: pickle(type, function, constructor_ob=None)
2929

3030
Declares that *function* should be used as a "reduction" function for objects
3131
of type *type*. *function* should return either a string or a tuple
32-
containing two or three elements.
32+
containing two or three elements. See the :attr:`~pickle.Pickler.dispatch_table`
33+
for more details on the interface of *function*.
3334

34-
The optional *constructor* parameter, if provided, is a callable object which
35-
can be used to reconstruct the object when called with the tuple of arguments
36-
returned by *function* at pickling time. A :exc:`TypeError` is raised if the
37-
*constructor* is not callable.
35+
The *constructor_ob* parameter is a legacy feature and is now ignored, but if
36+
passed it must be a callable.
3837

39-
See the :mod:`pickle` module for more details on the interface
40-
expected of *function* and *constructor*. Note that the
41-
:attr:`~pickle.Pickler.dispatch_table` attribute of a pickler
38+
Note that the :attr:`~pickle.Pickler.dispatch_table` attribute of a pickler
4239
object or subclass of :class:`pickle.Pickler` can also be used for
4340
declaring reduction functions.
4441

Doc/library/http.server.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ provides three different variants:
392392
contents of the file are output. If the file's MIME type starts with
393393
``text/`` the file is opened in text mode; otherwise binary mode is used.
394394

395-
For example usage, see the implementation of the :func:`test` function
396-
invocation in the :mod:`http.server` module.
395+
For example usage, see the implementation of the ``test`` function
396+
in :source:`Lib/http/server.py`.
397397

398398
.. versionchanged:: 3.7
399399
Support of the ``'If-Modified-Since'`` header.

Doc/library/os.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ process and user.
304304

305305
.. function:: getenv(key, default=None)
306306

307-
Return the value of the environment variable *key* if it exists, or
308-
*default* if it doesn't. *key*, *default* and the result are str. Note that
307+
Return the value of the environment variable *key* as a string if it exists, or
308+
*default* if it doesn't. *key* is a string. Note that
309309
since :func:`getenv` uses :data:`os.environ`, the mapping of :func:`getenv` is
310310
similarly also captured on import, and the function may not reflect
311311
future environment changes.
@@ -319,8 +319,8 @@ process and user.
319319

320320
.. function:: getenvb(key, default=None)
321321

322-
Return the value of the environment variable *key* if it exists, or
323-
*default* if it doesn't. *key*, *default* and the result are bytes. Note that
322+
Return the value of the environment variable *key* as bytes if it exists, or
323+
*default* if it doesn't. *key* must be bytes. Note that
324324
since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is
325325
similarly also captured on import, and the function may not reflect
326326
future environment changes.

Doc/library/venv.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ Creating virtual environments
8585
without there needing to be any reference to its virtual environment in
8686
``PATH``.
8787

88+
.. warning:: Because scripts installed in environments should not expect the
89+
environment to be activated, their shebang lines contain the absolute paths
90+
to their environment's interpreters. Because of this, environments are
91+
inherently non-portable, in the general case. You should always have a
92+
simple means of recreating an environment (for example, if you have a
93+
requirements file ``requirements.txt``, you can invoke ``pip install -r
94+
requirements.txt`` using the environment's ``pip`` to install all of the
95+
packages needed by the environment). If for any reason you need to move the
96+
environment to a new location, you should recreate it at the desired
97+
location and delete the one at the old location. If you move an environment
98+
because you moved a parent directory of it, you should recreate the
99+
environment in its new location. Otherwise, software installed into the
100+
environment may not work as expected.
88101

89102
.. _venv-api:
90103

Doc/library/xml.sax.utils.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ or as base classes.
2525
replaced with its corresponding value. The characters ``'&'``, ``'<'`` and
2626
``'>'`` are always escaped, even if *entities* is provided.
2727

28+
.. note::
29+
30+
This function should only be used to escape characters that
31+
can't be used directly in XML. Do not use this function as a general
32+
string translation function.
2833

2934
.. function:: unescape(data, entities={})
3035

Doc/license.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ for third-party software incorporated in the Python distribution.
302302
Mersenne Twister
303303
----------------
304304

305-
The :mod:`_random` module includes code based on a download from
305+
The :mod:`!_random` C extension underlying the :mod:`random` module
306+
includes code based on a download from
306307
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html. The following are
307308
the verbatim comments from the original code::
308309

@@ -819,7 +820,8 @@ sources unless the build is configured ``--with-system-expat``::
819820
libffi
820821
------
821822

822-
The :mod:`_ctypes` extension is built using an included copy of the libffi
823+
The :mod:`!_ctypes` C extension underlying the :mod:`ctypes` module
824+
is built using an included copy of the libffi
823825
sources unless the build is configured ``--with-system-libffi``::
824826

825827
Copyright (c) 1996-2008 Red Hat, Inc and others.
@@ -920,7 +922,8 @@ on the cfuhash project::
920922
libmpdec
921923
--------
922924

923-
The :mod:`_decimal` module is built using an included copy of the libmpdec
925+
The :mod:`!_decimal` C extension underlying the :mod:`decimal` module
926+
is built using an included copy of the libmpdec
924927
library unless the build is configured ``--with-system-libmpdec``::
925928

926929
Copyright (c) 2008-2020 Stefan Krah. All rights reserved.

Doc/reference/expressions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,12 @@ returns a boolean value regardless of the type of its argument
17411741
(for example, ``not 'foo'`` produces ``False`` rather than ``''``.)
17421742

17431743

1744+
.. index::
1745+
single: := (colon equals)
1746+
single: assignment expression
1747+
single: walrus operator
1748+
single: named expression
1749+
17441750
Assignment expressions
17451751
======================
17461752

Doc/tutorial/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ the ones with a fractional part (e.g. ``5.0``, ``1.6``) have type
7070
:class:`float`. We will see more about numeric types later in the tutorial.
7171

7272
Division (``/``) always returns a float. To do :term:`floor division` and
73-
get an integer result (discarding any fractional result) you can use the ``//``
74-
operator; to calculate the remainder you can use ``%``::
73+
get an integer result you can use the ``//`` operator; to calculate
74+
the remainder you can use ``%``::
7575

7676
>>> 17 / 3 # classic division returns a float
7777
5.666666666666667

Doc/whatsnew/3.12.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
* Credit the author of a patch or bugfix. Just the name is
3838
sufficient; the e-mail address isn't necessary.
3939
40-
* It's helpful to add the bug/patch number as a comment:
40+
* It's helpful to add the issue number as a comment:
4141
4242
XXX Describe the transmogrify() function added to the socket
4343
module.
44-
(Contributed by P.Y. Developer in :issue:`12345`.)
44+
(Contributed by P.Y. Developer in :gh:`12345`.)
4545
4646
This saves the maintainer the effort of going through the VCS log when
4747
researching a change.
@@ -93,6 +93,13 @@ Other Language Changes
9393
when parsing source code containing null bytes. (Contributed by Pablo Galindo
9494
in :gh:`96670`.)
9595

96+
* The Garbage Collector now runs only on the eval breaker mechanism of the
97+
Python bytecode evaluation loop instead on object allocations. The GC can
98+
also run when :c:func:`PyErr_CheckSignals` is called so C extensions that
99+
need to run for a long time without executing any Python code also have a
100+
chance to execute the GC periodically. (Contributed by Pablo Galindo in
101+
:gh:`97922`.)
102+
96103
New Modules
97104
===========
98105

@@ -102,6 +109,24 @@ New Modules
102109
Improved Modules
103110
================
104111

112+
asyncio
113+
-------
114+
115+
* On Linux, :mod:`asyncio` uses :class:`~asyncio.PidfdChildWatcher` by default
116+
if :func:`os.pidfd_open` is available and functional instead of
117+
:class:`~asyncio.ThreadedChildWatcher`.
118+
(Contributed by Kumar Aditya in :gh:`98024`.)
119+
120+
* The child watcher classes :class:`~asyncio.MultiLoopChildWatcher`,
121+
:class:`~asyncio.FastChildWatcher` and
122+
:class:`~asyncio.SafeChildWatcher` are deprecated and
123+
will be removed in Python 3.14. It is recommended to not manually
124+
configure a child watcher as the event loop now uses the best available
125+
child watcher for each platform (:class:`~asyncio.PidfdChildWatcher`
126+
if supported and :class:`~asyncio.ThreadedChildWatcher` otherwise).
127+
(Contributed by Kumar Aditya in :gh:`94597`.)
128+
129+
105130
pathlib
106131
-------
107132

Include/cpython/code.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ typedef uint16_t _Py_CODEUNIT;
3232
#define _Py_SET_OPCODE(word, opcode) \
3333
do { ((unsigned char *)&(word))[0] = (opcode); } while (0)
3434

35+
typedef struct {
36+
PyObject *_co_code;
37+
PyObject *_co_varnames;
38+
PyObject *_co_cellvars;
39+
PyObject *_co_freevars;
40+
} _PyCoCached;
41+
3542
// To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are
3643
// defined in this macro:
3744
#define _PyCode_DEF(SIZE) { \
@@ -90,7 +97,7 @@ typedef uint16_t _Py_CODEUNIT;
9097
PyObject *co_qualname; /* unicode (qualname, for reference) */ \
9198
PyObject *co_linetable; /* bytes object that holds location info */ \
9299
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
93-
PyObject *_co_code; /* cached co_code object/attribute */ \
100+
_PyCoCached *_co_cached; /* cached co_* attributes */ \
94101
int _co_firsttraceable; /* index of first traceable instruction */ \
95102
char *_co_linearray; /* array of line offsets */ \
96103
/* Scratch space for extra data relating to the code object. \

Include/internal/pycore_gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ extern void _PyList_ClearFreeList(PyInterpreterState *interp);
202202
extern void _PyDict_ClearFreeList(PyInterpreterState *interp);
203203
extern void _PyAsyncGen_ClearFreeLists(PyInterpreterState *interp);
204204
extern void _PyContext_ClearFreeList(PyInterpreterState *interp);
205+
extern void _Py_ScheduleGC(PyInterpreterState *interp);
206+
extern void _Py_RunGC(PyThreadState *tstate);
205207

206208
#ifdef __cplusplus
207209
}

0 commit comments

Comments
 (0)