Skip to content

Commit 17292a3

Browse files
committed
Catch up with main
2 parents 6e3869c + c085974 commit 17292a3

File tree

838 files changed

+14497
-4177
lines changed

Some content is hidden

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

838 files changed

+14497
-4177
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Lib/ast.py @isidentical
135135

136136
**/*idlelib* @terryjreedy
137137

138-
**/*typing* @gvanrossum @Fidget-Spinner @JelleZijlstra
138+
**/*typing* @gvanrossum @Fidget-Spinner @JelleZijlstra @AlexWaygood
139139

140140
**/*asyncore @giampaolo
141141
**/*asynchat @giampaolo

.github/CONTRIBUTING.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@ Contributing to Python
44
Build Status
55
------------
66

7-
- main
7+
- `Buildbot status overview <https://buildbot.python.org/all/#/release_status>`_
88

9-
+ `Stable buildbots <https://buildbot.python.org/3.x.stable/>`_
10-
11-
- 3.9
12-
13-
+ `Stable buildbots <https://buildbot.python.org/3.9.stable/>`_
14-
15-
- 3.8
16-
17-
+ `Stable buildbots <https://buildbot.python.org/3.8.stable/>`_
18-
19-
- 3.7
20-
21-
+ `Stable buildbots <https://buildbot.python.org/3.7.stable/>`_
9+
- `GitHub Actions status <https://github.com/python/cpython/actions/workflows/build.yml>`_
2210

2311

2412
Thank You

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The Python team applies security fixes according to the table
66
in [the devguide](
7-
https://devguide.python.org/#status-of-python-branches
7+
https://devguide.python.org/versions/#supported-versions
88
).
99

1010
## Reporting a Vulnerability

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
id: check
4242
run: |
4343
if [ -z "$GITHUB_BASE_REF" ]; then
44-
echo '::set-output name=run_tests::true'
44+
echo "run_tests=true" >> $GITHUB_OUTPUT
4545
else
4646
git fetch origin $GITHUB_BASE_REF --depth=1
4747
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
@@ -57,7 +57,7 @@ jobs:
5757
# into the PR branch anyway.
5858
#
5959
# https://github.com/python/core-workflow/issues/373
60-
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
60+
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
6161
fi
6262
6363
check_generated_files:

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ is not possible due to its implementation being opaque at build time.
19331933
19341934
.. note::
19351935
A freed key becomes a dangling pointer. You should reset the key to
1936-
`NULL`.
1936+
``NULL``.
19371937
19381938
19391939
Methods

Doc/c-api/init_config.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,6 @@ Private provisional API:
15711571
15721572
* :c:member:`PyConfig._init_main`: if set to ``0``,
15731573
:c:func:`Py_InitializeFromConfig` stops at the "Core" initialization phase.
1574-
* :c:member:`PyConfig._isolated_interpreter`: if non-zero,
1575-
disallow threads, subprocesses and fork.
15761574
15771575
.. c:function:: PyStatus _Py_InitializeMain(void)
15781576

Doc/c-api/structures.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -387,27 +387,27 @@ Accessing attributes of extension types
387387
Structure which describes an attribute of a type which corresponds to a C
388388
struct member. Its fields are:
389389
390-
+------------------+---------------+-------------------------------+
391-
| Field | C Type | Meaning |
392-
+==================+===============+===============================+
393-
| :attr:`name` | const char \* | name of the member |
394-
+------------------+---------------+-------------------------------+
395-
| :attr:`!type` | int | the type of the member in the |
396-
| | | C struct |
397-
+------------------+---------------+-------------------------------+
398-
| :attr:`offset` | Py_ssize_t | the offset in bytes that the |
399-
| | | member is located on the |
400-
| | | type's object struct |
401-
+------------------+---------------+-------------------------------+
402-
| :attr:`flags` | int | flag bits indicating if the |
403-
| | | field should be read-only or |
404-
| | | writable |
405-
+------------------+---------------+-------------------------------+
406-
| :attr:`doc` | const char \* | points to the contents of the |
407-
| | | docstring |
408-
+------------------+---------------+-------------------------------+
390+
.. c:member:: const char* PyMemberDef.name
391+
392+
Name of the member
393+
394+
.. c:member:: int PyMemberDef.type
395+
396+
The type of the member in the C struct.
397+
398+
.. c:member:: Py_ssize_t PyMemberDef.offset
399+
400+
The offset in bytes that the member is located on the types object struct.
401+
402+
.. c:member:: int PyMemberDef.flags
403+
404+
Flag bits indicating if the field should be read-only or writable.
405+
406+
.. c:member:: const char* PyMemberDef.doc
407+
408+
Points to the contents of the docstring.
409409
410-
:attr:`!type` can be one of many ``T_`` macros corresponding to various C
410+
:c:member:`PyMemberDef.type` can be one of many ``T_`` macros corresponding to various C
411411
types. When the member is accessed in Python, it will be converted to the
412412
equivalent Python type.
413413
@@ -441,7 +441,7 @@ Accessing attributes of extension types
441441
handles use of the :keyword:`del` statement on that attribute more correctly
442442
than :c:macro:`T_OBJECT`.
443443
444-
:attr:`flags` can be ``0`` for write and read access or :c:macro:`READONLY` for
444+
:c:member:`PyMemberDef.flags` can be ``0`` for write and read access or :c:macro:`READONLY` for
445445
read-only access. Using :c:macro:`T_STRING` for :attr:`type` implies
446446
:c:macro:`READONLY`. :c:macro:`T_STRING` data is interpreted as UTF-8.
447447
Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX`

Doc/c-api/tuple.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Tuple Objects
6969
7070
Return the slice of the tuple pointed to by *p* between *low* and *high*,
7171
or ``NULL`` on failure. This is the equivalent of the Python expression
72-
``p[low:high]``. Indexing from the end of the list is not supported.
72+
``p[low:high]``. Indexing from the end of the tuple is not supported.
7373
7474
7575
.. c:function:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)

Doc/c-api/type.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,55 @@ Type Objects
5757
modification of the attributes or base classes of the type.
5858
5959
60+
.. c:function:: int PyType_AddWatcher(PyType_WatchCallback callback)
61+
62+
Register *callback* as a type watcher. Return a non-negative integer ID
63+
which must be passed to future calls to :c:func:`PyType_Watch`. In case of
64+
error (e.g. no more watcher IDs available), return ``-1`` and set an
65+
exception.
66+
67+
.. versionadded:: 3.12
68+
69+
70+
.. c:function:: int PyType_ClearWatcher(int watcher_id)
71+
72+
Clear watcher identified by *watcher_id* (previously returned from
73+
:c:func:`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error (e.g.
74+
if *watcher_id* was never registered.)
75+
76+
An extension should never call ``PyType_ClearWatcher`` with a *watcher_id*
77+
that was not returned to it by a previous call to
78+
:c:func:`PyType_AddWatcher`.
79+
80+
.. versionadded:: 3.12
81+
82+
83+
.. c:function:: int PyType_Watch(int watcher_id, PyObject *type)
84+
85+
Mark *type* as watched. The callback granted *watcher_id* by
86+
:c:func:`PyType_AddWatcher` will be called whenever
87+
:c:func:`PyType_Modified` reports a change to *type*. (The callback may be
88+
called only once for a series of consecutive modifications to *type*, if
89+
:c:func:`PyType_Lookup` is not called on *type* between the modifications;
90+
this is an implementation detail and subject to change.)
91+
92+
An extension should never call ``PyType_Watch`` with a *watcher_id* that was
93+
not returned to it by a previous call to :c:func:`PyType_AddWatcher`.
94+
95+
.. versionadded:: 3.12
96+
97+
98+
.. c:type:: int (*PyType_WatchCallback)(PyObject *type)
99+
100+
Type of a type-watcher callback function.
101+
102+
The callback must not modify *type* or cause :c:func:`PyType_Modified` to be
103+
called on *type* or any type in its MRO; violating this rule could cause
104+
infinite recursion.
105+
106+
.. versionadded:: 3.12
107+
108+
60109
.. c:function:: int PyType_HasFeature(PyTypeObject *o, int feature)
61110
62111
Return non-zero if the type object *o* sets the feature *feature*.

Doc/data/stable_abi.dat

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/extending/embedding.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ be directly useful to you:
298298

299299
.. code-block:: shell-session
300300
301-
$ /opt/bin/python3.4-config --cflags
302-
-I/opt/include/python3.4m -I/opt/include/python3.4m -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
301+
$ /opt/bin/python3.11-config --cflags
302+
-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall
303303
304-
* ``pythonX.Y-config --ldflags`` will give you the recommended flags when
305-
linking:
304+
* ``pythonX.Y-config --ldflags --embed`` will give you the recommended flags
305+
when linking:
306306

307307
.. code-block:: shell-session
308308
309-
$ /opt/bin/python3.4-config --ldflags
310-
-L/opt/lib/python3.4/config-3.4m -lpthread -ldl -lutil -lm -lpython3.4m -Xlinker -export-dynamic
309+
$ /opt/bin/python3.11-config --ldflags --embed
310+
-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -lpthread -ldl -lutil -lm
311311
312312
.. note::
313313
To avoid confusion between several Python installations (and especially

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ Glossary
882882

883883
package
884884
A Python :term:`module` which can contain submodules or recursively,
885-
subpackages. Technically, a package is a Python module with an
885+
subpackages. Technically, a package is a Python module with a
886886
``__path__`` attribute.
887887

888888
See also :term:`regular package` and :term:`namespace package`.

Doc/howto/clinic.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. highlight:: c
22

3+
.. _howto-clinic:
4+
35
**********************
46
Argument Clinic How-To
57
**********************

Doc/howto/functional.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ requesting iterator-2 and its corresponding key.
994994
The functools module
995995
====================
996996

997-
The :mod:`functools` module in Python 2.5 contains some higher-order functions.
997+
The :mod:`functools` module contains some higher-order functions.
998998
A **higher-order function** takes one or more functions as input and returns a
999999
new function. The most useful tool in this module is the
10001000
:func:`functools.partial` function.

Doc/howto/isolating-extensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ Module State Access from Slot Methods, Getters and Setters
461461

462462
.. After adding to limited API:
463463
464-
If you use the `limited API <https://docs.python.org/3/c-api/stable.html>__,
464+
If you use the :ref:`limited API <stable>,
465465
you must update ``Py_LIMITED_API`` to ``0x030b0000``, losing ABI
466466
compatibility with earlier versions.
467467

Doc/howto/logging-cookbook.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3712,6 +3712,71 @@ Of course, the examples above show output according to the format used by
37123712
:func:`~logging.basicConfig`, but you can use a different formatter when you
37133713
configure logging.
37143714

3715+
Note that with the above scheme, you are somewhat at the mercy of buffering and
3716+
the sequence of write calls which you are intercepting. For example, with the
3717+
definition of ``LoggerWriter`` above, if you have the snippet
3718+
3719+
.. code-block:: python
3720+
3721+
sys.stderr = LoggerWriter(logger, logging.WARNING)
3722+
1 / 0
3723+
3724+
then running the script results in
3725+
3726+
.. code-block:: text
3727+
3728+
WARNING:demo:Traceback (most recent call last):
3729+
3730+
WARNING:demo: File "/home/runner/cookbook-loggerwriter/test.py", line 53, in <module>
3731+
3732+
WARNING:demo:
3733+
WARNING:demo:main()
3734+
WARNING:demo: File "/home/runner/cookbook-loggerwriter/test.py", line 49, in main
3735+
3736+
WARNING:demo:
3737+
WARNING:demo:1 / 0
3738+
WARNING:demo:ZeroDivisionError
3739+
WARNING:demo::
3740+
WARNING:demo:division by zero
3741+
3742+
As you can see, this output isn't ideal. That's because the underlying code
3743+
which writes to ``sys.stderr`` makes mutiple writes, each of which results in a
3744+
separate logged line (for example, the last three lines above). To get around
3745+
this problem, you need to buffer things and only output log lines when newlines
3746+
are seen. Let's use a slghtly better implementation of ``LoggerWriter``:
3747+
3748+
.. code-block:: python
3749+
3750+
class BufferingLoggerWriter(LoggerWriter):
3751+
def __init__(self, logger, level):
3752+
super().__init__(logger, level)
3753+
self.buffer = ''
3754+
3755+
def write(self, message):
3756+
if '\n' not in message:
3757+
self.buffer += message
3758+
else:
3759+
parts = message.split('\n')
3760+
if self.buffer:
3761+
s = self.buffer + parts.pop(0)
3762+
self.logger.log(self.level, s)
3763+
self.buffer = parts.pop()
3764+
for part in parts:
3765+
self.logger.log(self.level, part)
3766+
3767+
This just buffers up stuff until a newline is seen, and then logs complete
3768+
lines. With this approach, you get better output:
3769+
3770+
.. code-block:: text
3771+
3772+
WARNING:demo:Traceback (most recent call last):
3773+
WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module>
3774+
WARNING:demo: main()
3775+
WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main
3776+
WARNING:demo: 1/0
3777+
WARNING:demo:ZeroDivisionError: division by zero
3778+
3779+
37153780
.. patterns-to-avoid:
37163781
37173782
Patterns to avoid

0 commit comments

Comments
 (0)