8000 Merge branch 'main' into docs/argparse-devguide · python/cpython@b0da078 · GitHub
[go: up one dir, main page]

Skip to content

Commit b0da078

Browse files
Merge branch 'main' into docs/argparse-devguide
2 parents a46cde5 + 1465386 commit b0da078

File tree

308 files changed

+7882
-4397
lines changed

Some content is hidden

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

308 files changed

+7882
-4397
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ jobs:
140140
run: make regen-configure
141141
- name: Build CPython
142142
run: |
143-
# Deepfreeze will usually cause global objects to be added or removed,
144-
# so we run it before regen-global-objects gets rum (in regen-all).
145-
make regen-deepfreeze
146143
make -j4 regen-all
147144
make regen-stdlib-module-names
148145
- name: Check for changes
@@ -182,7 +179,7 @@ jobs:
182179
- name: Display build info
183180
run: .\python.bat -m test.pythoninfo
184181
- name: Tests
185-
run: .\PCbuild\rt.bat -p Win32 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
182+
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci
186183

187184
build_win_amd64:
188185
name: 'Windows (x64)'
@@ -201,7 +198,7 @@ jobs:
201198
- name: Display build info
202199
run: .\python.bat -m test.pythoninfo
203200
- name: Tests
204-
run: .\PCbuild\rt.bat -p x64 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
201+
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci
205202

206203
build_win_arm64:
207204
name: 'Windows (arm64)'
@@ -252,7 +249,7 @@ jobs:
252249
- name: Display build info
253250
run: make pythoninfo
254251
- name: Tests
255-
run: make buildbottest TESTOPTS="-j4 -uall,-cpu"
252+
run: make test
256253

257254
build_ubuntu:
258255
name: 'Ubuntu'
@@ -261,7 +258,7 @@ jobs:
261258
needs: check_source
262259
if: needs.check_source.outputs.run_tests == 'true'
263260
env:
264-
OPENSSL_VER: 1.1.1v
261+
OPENSSL_VER: 3.0.11
265262
PYTHONSTRICTEXTENSIONBUILD: 1
266263
steps:
267264
- uses: actions/checkout@v4
@@ -319,7 +316,7 @@ jobs:
319316
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
320317
- name: Tests
321318
working-directory: ${{ env.CPYTHON_BUILDDIR }}
322-
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
319+
run: xvfb-run make test
323320

324321
build_ubuntu_ssltests:
325322
name: 'Ubuntu SSL tests with OpenSSL'
@@ -330,7 +327,7 @@ jobs:
330327
strategy:
331328
fail-fast: false
332329
matrix:
333-
openssl_ver: [1.1.1v, 3.0.10, 3.1.2]
330+
openssl_ver: [1.1.1w, 3.0.11, 3.1.3]
334331
env:
335332
OPENSSL_VER: ${{ matrix.openssl_ver }}
336333
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -382,7 +379,7 @@ jobs:
382379
needs: check_source
383380
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
384381
env:
385-
OPENSSL_VER: 1.1.1v
382+
OPENSSL_VER: 3.0.11
386383
PYTHONSTRICTEXTENSIONBUILD: 1
387384
steps:
388385
- uses: actions/checkout@v4
@@ -491,7 +488,7 @@ jobs:
491488
needs: check_source
492489
if: needs.check_source.outputs.run_tests == 'true'
493490
env:
494-
OPENSSL_VER: 1.1.1v
491+
OPENSSL_VER: 3.0.11
495492
PYTHONSTRICTEXTENSIONBUILD: 1
496493
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
497494
steps:
@@ -535,7 +532,7 @@ jobs:
535532
- name: Display build info
536533
run: make pythoninfo
537534
- name: Tests
538-
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
535+
run: xvfb-run make test
539536

540537
all-required-green: # This job does nothing and is only used for the branch protection
541538
name: All required checks pass

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.0.288
3+
rev: v0.0.292
44
hooks:
55
- id: ruff
66
name: Run Ruff on Lib/test/

Doc/c-api/init.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,19 @@ code, or when embedding the Python interpreter:
870870
When the current thread state is ``NULL``, this issues a fatal error (so that
871871
the caller needn't check for ``NULL``).
872872
873+
See also :c:func:`PyThreadState_GetUnchecked`.
874+
875+
876+
.. c:function:: PyThreadState* PyThreadState_GetUnchecked()
877+
878+
Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a
< 10000 /code>
879+
fatal error if it is NULL. The caller is responsible to check if the result
880+
is NULL.
881+
882+
.. versionadded:: 3.13
883+
In Python 3.5 to 3.12, the function was private and known as
884+
``_PyThreadState_UncheckedGet()``.
885+
873886
874887
.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
875888

Doc/c-api/object.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,21 @@ Object Protocol
489489
:c:macro:`Py_TPFLAGS_ITEMS_AT_END` set.
490490
491491
.. versionadded:: 3.12
492+
493+
.. c:function:: int PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
494+
495+
Visit the managed dictionary of *obj*.
496+
497+
This function must only be called in a traverse function of the type which
498+
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
499+
500+
.. versionadded:: 3.13
501+
502+
.. c:function:: void PyObject_ClearManagedDict(PyObject *obj)
503+
504+
Clear the managed dictionary of *obj*.
505+
506+
This function must only be called in a traverse function of the type which
507+
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
508+
509+
.. versionadded:: 3.13

Doc/c-api/typeobj.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,9 @@ and :c:data:`PyType_Type` effectively act as defaults.)
11311131

11321132
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
11331133

1134+
The type traverse function must call :c:func:`PyObject_VisitManagedDict`
1135+
and its clear function must call :c:func:`PyObject_ClearManagedDict`.
1136+
11341137
.. versionadded:: 3.12
11351138

11361139
**Inheritance:**
@@ -1368,6 +1371,23 @@ and :c:data:`PyType_Type` effectively act as defaults.)
13681371
debugging aid you may want to visit it anyway just so the :mod:`gc` module's
13691372
:func:`~gc.get_referents` function will include it.
13701373

1374+
Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::
1375+
1376+
Py_VISIT(Py_TYPE(self));
1377+
1378+
It is only needed since Python 3.9. To support Python 3.8 and older, this
1379+
line must be conditionnal::
1380+
1381+
#if PY_VERSION_HEX >= 0x03090000
1382+
Py_VISIT(Py_TYPE(self));
1383+
#endif
1384+
1385+
If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
1386+
:c:member:`~PyTypeObject.tp_flags` field, the traverse function must call
1387+
:c:func:`PyObject_VisitManagedDict` like this::
1388+
1389+
PyObject_VisitManagedDict((PyObject*)self, visit, arg);
1390+
13711391
.. warning::
13721392
When implementing :c:member:`~PyTypeObject.tp_traverse`, only the
13731393
members that the instance *owns* (by having :term:`strong references
@@ -1451,6 +1471,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
14511471
so that *self* knows the contained object can no longer be used. The
14521472
:c:func:`Py_CLEAR` macro performs the operations in a safe order.
14531473

1474+
If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
1475+
:c:member:`~PyTypeObject.tp_flags` field, the traverse function must call
1476+
:c:func:`PyObject_ClearManagedDict` like this::
1477+
1478+
PyObject_ClearManagedDict((PyObject*)self);
1479+
14541480
Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called
14551481
before an instance is deallocated. For example, when reference counting
14561482
is enough to determine that an object is no longer used, the cyclic garbage
@@ -1801,7 +1827,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
18011827
field is ``NULL`` then no :attr:`~object.__dict__` gets created for instances.
18021828

18031829
If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
1804-
:c:member:`~PyTypeObject.tp_dict` field, then
1830+
:c:member:`~PyTypeObject.tp_flags` field, then
18051831
:c:member:`~PyTypeObject.tp_dictoffset` will be set to ``-1``, to indicate
18061832
that it is unsafe to use this field.
18071833

Doc/constraints.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ colorama<0.5
1010
imagesize<1.5
1111
Jinja2<3.2
1212
packaging<24
13-
# Pygments==2.15.0 breaks CI
14-
Pygments<2.16,!=2.15.0
13+
Pygments>=2.16.1,<3
1514
requests<3
1615
snowballstemmer<3
1716
sphinxcontrib-applehelp<1.1

Doc/howto/urllib2.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ which comes after we have a look at what happens when things go wrong.
194194
Handling Exceptions
195195
===================
196196

197-
*urlopen* raises :exc:`URLError` when it cannot handle a response (though as
197+
*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a response (though as
198198
usual with Python APIs, built-in exceptions such as :exc:`ValueError`,
199199
:exc:`TypeError` etc. may also be raised).
200200

201-
:exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific case of
201+
:exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error.URLError` raised in the specific case of
202202
HTTP URLs.
203203

204204
The exception classes are exported from the :mod:`urllib.error` module.
@@ -229,12 +229,12 @@ the status code indicates that the server is unable to fulfil the request. The
229229
default handlers will handle some of these responses for you (for example, if
230230
the response is a "redirection" that requests the client fetch the document from
231231
a different URL, urllib will handle that for you). For those it can't handle,
232-
urlopen will raise an :exc:`HTTPError`. Typical errors include '404' (page not
232+
urlopen will raise an :exc:`~urllib.error.HTTPError`. Typical errors include '404' (page not
233233
found), '403' (request forbidden), and '401' (authentication required).
234234

235235
See section 10 of :rfc:`2616` for a reference on all the HTTP error codes.
236236

237-
The :exc:`HTTPError` instance raised will have an integer 'code' attribute, which
237+
The :exc:`~urllib.error.HTTPError` instance raised will have an integer 'code' attribute, which
238238
corresponds to the error sent by the server.
239239

240240
Error Codes
@@ -317,7 +317,7 @@ dictionary is reproduced here for convenience ::
317317
}
318318

319319
When an error is raised the server responds by returning an HTTP error code
320-
*and* an error page. You can use the :exc:`HTTPError` instance as a response on the
320+
*and* an error page. You can use the :exc:`~urllib.error.HTTPError` instance as a response on the
321321
page returned. This means that as well as the code attribute, it also has read,
322322
geturl, and info, methods as returned by the ``urllib.response`` module::
323323

@@ -338,7 +338,7 @@ geturl, and info, methods as returned by the ``urllib.response`` module::
338338
Wrapping it Up
339339
--------------
340340

341-
So if you want to be prepared for :exc:`HTTPError` *or* :exc:`URLError` there are two
341+
So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:`~urllib.error.URLError` there are two
342342
basic approaches. I prefer the second approach.
343343

344344
Number 1
@@ -365,7 +365,7 @@ Number 1
365365
.. note::
366366

367367
The ``except HTTPError`` *must* come first, otherwise ``except URLError``
368-
will *also* catch an :exc:`HTTPError`.
368+
will *also* catch an :exc:`~urllib.error.HTTPError`.
369369

370370
Number 2
371371
~~~~~~~~
@@ -391,7 +391,7 @@ Number 2
391391
info and geturl
392392
===============
393393

394-
The response returned by urlopen (or the :exc:`HTTPError` instance) has two
394+
The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` instance) has two
395395
useful methods :meth:`info` and :meth:`geturl` and is defined in the module
396396
:mod:`urllib.response`..
397397

Doc/library/__main__.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ package. For more details, see :ref:`intra-package-references` in the
238238
Idiomatic Usage
239239
^^^^^^^^^^^^^^^
240240

241-
The contents of ``__main__.py`` typically isn't fenced with
242-
``if __name__ == '__main__'`` blocks. Instead, those files are kept short,
243-
functions to execute from other modules. Those other modules can then be
241+
The content of ``__main__.py`` typically isn't fenced with an
242+
``if __name__ == '__main__'`` block. Instead, those files are kept
243+
short and import functions to execute from other modules. Those other modules can then be
244244
easily unit-tested and are properly reusable.
245245

246246
If used, an ``if __name__ == '__main__'`` block will still work as expected

Doc/library/ast.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,26 +2483,26 @@ The following options are accepted:
24832483

24842484
.. program:: ast
24852485

2486-
.. cmdoption:: -h, --help
2486+
.. option:: -h, --help
24872487

24882488
Show the help message and exit.
24892489

2490-
.. cmdoption:: -m <mode>
2491-
--mode <mode>
2490+
.. option:: -m <mode>
2491+
--mode <mode>
24922492

24932493
Specify what kind of code must be compiled, like the *mode* argument
24942494
in :func:`parse`.
24952495

2496-
.. cmdoption:: --no-type-comments
2496+
.. option:: --no-type-comments
24972497

24982498
Don't parse type comments.
24992499

2500-
.. cmdoption:: -a, --include-attributes
2500+
.. option:: -a, --include-attributes
25012501

25022502
Include attributes such as line numbers and column offsets.
25032503

2504-
.. cmdoption:: -i <indent>
2505-
--indent <indent>
2504+
.. option:: -i <indent>
2505+
--indent <indent>
25062506

25072507
Indentation of nodes in AST (number of spaces).
25082508

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ and work with streams:
157157
.. versionchanged:: 3.10
158158
Removed the *loop* parameter.
159159

160-
.. versionchanged:: 3.11
161-
Added the *ssl_shutdown_timeout* parameter.
160+
.. versionchanged:: 3.11
161+
Added the *ssl_shutdown_timeout* parameter.
162162

163163

164164
.. coroutinefunction:: start_unix_server(client_connected_cb, path=None, \

Doc/library/codecs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ encodings.
13501350
+--------------------+---------+---------------------------+
13511351
| raw_unicode_escape | | Latin-1 encoding with |
13521352
| | | :samp:`\\u{XXXX}` and |
1353-
| | | :samp:`\\U{XXXXXXXX}`` |
1353+
| | | :samp:`\\U{XXXXXXXX}` |
13541354
| | | for other code points. |
13551355
| | | Existing |
13561356
| | | backslashes are not |

Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Common patterns for working with :class:`Counter` objects::
358358
list(c) # list unique elements
359359
set(c) # convert to a set
360360
dict(c) # convert to a regular dictionary
361-
c.items() # convert to a list of (elem, cnt) pairs
361+
c.items() # access the (elem, cnt) pairs
362362
Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs
363363
c.most_common()[:-n-1:-1] # n least common elements
364364
+c # remove zero and negative counts

0 commit comments

Comments
 (0)
0