Skip to content

Commit 188b357

Browse files
committed
merge with main
2 parents ed29777 + 6066f45 commit 188b357

File tree

203 files changed

+2675
-1936
lines changed

Some content is hidden

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

203 files changed

+2675
-1936
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Python/pythonrun.c @iritkatriel
6060
# bytecode.
6161
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
6262
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
63+
**/importlib/resources/* @jaraco @warsaw @brettcannon
64+
**/importlib/metadata/* @jaraco @warsaw
6365

6466
# Dates and times
6567
**/*datetime* @pganssle @abalkin

.github/workflows/doc.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
paths:
2424
- 'Doc/**'
2525
- 'Misc/**'
26+
- '.github/workflows/doc.yml'
2627

2728
permissions:
2829
contents: read
@@ -35,6 +36,38 @@ jobs:
3536
- uses: actions/checkout@v3
3637
- name: Register Sphinx problem matcher
3738
run: echo "::add-matcher::.github/problem-matchers/sphinx.json"
39+
- name: 'Set up Python'
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: '3'
43+
cache: 'pip'
44+
cache-dependency-path: 'Doc/requirements.txt'
45+
- name: 'Install build dependencies'
46+
run: make -C Doc/ venv
47+
- name: 'Check documentation'
48+
run: make -C Doc/ check
49+
- name: 'Build HTML documentation'
50+
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
51+
- name: 'Upload'
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: doc-html
55+
path: Doc/build/html
56+
57+
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
58+
doctest:
59+
name: 'Doctest'
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v3
63+
- name: Register Sphinx problem matcher
64+
run: echo "::add-matcher::.github/problem-matchers/sphinx.json"
65+
- uses: actions/cache@v3
66+
with:
67+
path: ~/.cache/pip
68+
key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }}
69+
restore-keys: |
70+
ubuntu-doc-
3871
- name: 'Install Dependencies'
3972
run: sudo ./.github/workflows/posix-deps-apt.sh && sudo apt-get install wamerican
4073
- name: 'Configure CPython'
@@ -43,17 +76,6 @@ jobs:
4376
run: make -j4
4477
- name: 'Install build dependencies'
4578
run: make -C Doc/ PYTHON=../python venv
46-
# Run "check doctest html" as 3 steps to get a more readable output
47-
# in the web UI
48-
- name: 'Check documentation'
49-
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" check
5079
# Use "xvfb-run" since some doctest tests open GUI windows
5180
- name: 'Run documentation doctest'
52-
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" doctest
53-
- name: 'Build HTML documentation'
54-
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" html
55-
- name: 'Upload'
56-
uses: actions/upload-artifact@v3
57-
with:
58-
name: doc-html
59-
path: Doc/build/html
81+
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" doctest

Doc/c-api/sys.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ Operating System Utilities
2121
2222
Return true (nonzero) if the standard I/O file *fp* with name *filename* is
2323
deemed interactive. This is the case for files for which ``isatty(fileno(fp))``
24-
is true. If the global flag :c:data:`Py_InteractiveFlag` is true, this function
24+
is true. If the :c:member:`PyConfig.interactive` is non-zero, this function
2525
also returns true if the *filename* pointer is ``NULL`` or if the name is equal to
2626
one of the strings ``'<stdin>'`` or ``'???'``.
2727
28+
This function must not be called before Python is initialized.
29+
2830
2931
.. c:function:: void PyOS_BeforeFork()
3032

Doc/library/asyncio-llapi-index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ pipes, etc). Returned from methods like
358358

359359
* - :meth:`transport.get_write_buffer_size()
360360
<WriteTransport.get_write_buffer_size>`
361+
- Return the current size of the output buffer.
362+
363+
* - :meth:`transport.get_write_buffer_limits()
364+
<WriteTransport.get_write_buffer_limits>`
361365
- Return high and low water marks for write flow control.
362366

363367
* - :meth:`transport.set_write_buffer_limits()

Doc/library/cgi.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
The :mod:`cgi` module is deprecated
2020
(see :pep:`PEP 594 <594#cgi>` for details and alternatives).
2121

22+
The :class:`FieldStorage` class can typically be replaced with
23+
:func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests,
24+
and the :mod:`email.message` module or
25+
`multipart <https://pypi.org/project/multipart/>`_ for ``POST`` and ``PUT``.
26+
Most :ref:`utility functions <functions-in-cgi-module>` have replacements.
27+
2228
--------------
2329

2430
Support module for Common Gateway Interface (CGI) scripts.
@@ -293,6 +299,12 @@ algorithms implemented in this module in other circumstances.
293299
``sys.stdin``). The *keep_blank_values*, *strict_parsing* and *separator* parameters are
294300
passed to :func:`urllib.parse.parse_qs` unchanged.
295301

302+
.. deprecated-removed:: 3.11 3.13
303+
This function, like the rest of the :mod:`cgi` module, is deprecated.
304+
It can be replaced by calling :func:`urllib.parse.parse_qs` directly
305+
on the desired query string (except for ``multipart/form-data`` input,
306+
which can be handled as described for :func:`parse_multipart`).
307+
296308

297309
.. function:: parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator="&")
298310

@@ -316,12 +328,31 @@ algorithms implemented in this module in other circumstances.
316328
.. versionchanged:: 3.10
317329
Added the *separator* parameter.
318330

331+
.. deprecated-removed:: 3.11 3.13
332+
This function, like the rest of the :mod:`cgi` module, is deprecated.
333+
It can be replaced with the functionality in the :mod:`email` package
334+
(e.g. :class:`email.message.EmailMessage`/:class:`email.message.Message`)
335+
which implements the same MIME RFCs, or with the
336+
`multipart <https://pypi.org/project/multipart/>`__ PyPI project.
337+
319338

320339
.. function:: parse_header(string)
321340

322341
Parse a MIME header (such as :mailheader:`Content-Type`) into a main value and a
323342
dictionary of parameters.
324343

344+
.. deprecated-removed:: 3.11 3.13
345+
This function, like the rest of the :mod:`cgi` module, is deprecated.
346+
It can be replaced with the functionality in the :mod:`email` package,
347+
which implements the same MIME RFCs.
348+
349+
For example, with :class:`email.message.EmailMessage`::
350+
351+
from email.message import EmailMessage
352+
msg = EmailMessage()
353+
msg['content-type'] = 'application/json; charset="utf8"'
354+
main, params = msg.get_content_type(), msg['content-type'].params
355+
325356

326357
.. function:: test()
327358

Doc/library/dis.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,20 @@ iterations of the loop.
887887

888888
.. opcode:: LOAD_ATTR (namei)
889889

890-
Replaces TOS with ``getattr(TOS, co_names[namei])``.
890+
If the low bit of ``namei`` is not set, this replaces TOS with
891+
``getattr(TOS, co_names[namei>>1])``.
892+
893+
If the low bit of ``namei`` is set, this will attempt to load a method named
894+
``co_names[namei>>1]`` from the TOS object. TOS is popped.
895+
This bytecode distinguishes two cases: if TOS has a method with the correct
896+
name, the bytecode pushes the unbound method and TOS. TOS will be used as
897+
the first argument (``self``) by :opcode:`CALL` when calling the
898+
unbound method. Otherwise, ``NULL`` and the object return by the attribute
899+
lookup are pushed.
900+
901+
.. versionchanged:: 3.12
902+
If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is
903+
pushed to the stack before the attribute or unbound method respectively.
891904

892905

893906
.. opcode:: COMPARE_OP (opname)
@@ -1189,18 +1202,6 @@ iterations of the loop.
11891202
.. versionadded:: 3.6
11901203

11911204

1192-
.. opcode:: LOAD_METHOD (namei)
1193-
1194-
Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped.
1195-
This bytecode distinguishes two cases: if TOS has a method with the correct
1196-
name, the bytecode pushes the unbound method and TOS. TOS will be used as
1197-
the first argument (``self``) by :opcode:`CALL` when calling the
1198-
unbound method. Otherwise, ``NULL`` and the object return by the attribute
1199-
lookup are pushed.
1200-
1201-
.. versionadded:: 3.7
1202-
1203-
12041205
.. opcode:: PUSH_NULL
12051206

12061207
Pushes a ``NULL`` to the stack.

Doc/library/socket.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,10 +2076,10 @@ the interface::
20762076
# Include IP headers
20772077
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
20782078

2079-
# receive all packages
2079+
# receive all packets
20802080
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
20812081

2082-
# receive a package
2082+
# receive a packet
20832083
print(s.recvfrom(65565))
20842084

20852085
# disabled promiscuous mode

Doc/library/sqlite3.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ Module functions and constants
336336
float, str or bytes.
337337

338338

339-
.. function:: complete_statement(sql)
339+
.. function:: complete_statement(statement)
340340

341-
Returns :const:`True` if the string *sql* contains one or more complete SQL
341+
Returns :const:`True` if the string *statement* contains one or more complete SQL
342342
statements terminated by semicolons. It does not verify that the SQL is
343343
syntactically correct, only that there are no unclosed string literals and the
344344
statement is terminated by a semicolon.
@@ -457,11 +457,11 @@ Connection Objects
457457
:meth:`~Cursor.executescript` on it with the given *sql_script*.
458458
Return the new cursor object.
459459

460-
.. method:: create_function(name, num_params, func, *, deterministic=False)
460+
.. method:: create_function(name, narg, func, *, deterministic=False)
461461

462462
Creates a user-defined function that you can later use from within SQL
463-
statements under the function name *name*. *num_params* is the number of
464-
parameters the function accepts (if *num_params* is -1, the function may
463+
statements under the function name *name*. *narg* is the number of
464+
parameters the function accepts (if *narg* is -1, the function may
465465
take any number of arguments), and *func* is a Python callable that is
466466
called as the SQL function. If *deterministic* is true, the created function
467467
is marked as `deterministic <https://sqlite.org/deterministic.html>`_, which
@@ -480,12 +480,12 @@ Connection Objects
480480
.. literalinclude:: ../includes/sqlite3/md5func.py
481481

482482

483-
.. method:: create_aggregate(name, num_params, aggregate_class)
483+
.. method:: create_aggregate(name, n_arg, aggregate_class)
484484

485485
Creates a user-defined aggregate function.
486486

487487
The aggregate class must implement a ``step`` method, which accepts the number
488-
of parameters *num_params* (if *num_params* is -1, the function may take
488+
of parameters *n_arg* (if *n_arg* is -1, the function may take
489489
any number of arguments), and a ``finalize`` method which will return the
490490
final result of the aggregate.
491491

@@ -580,15 +580,15 @@ Connection Objects
580580
Added support for disabling the authorizer using :const:`None`.
581581

582582

583-
.. method:: set_progress_handler(handler, n)
583+
.. method:: set_progress_handler(progress_handler, n)
584584

585585
This routine registers a callback. The callback is invoked for every *n*
586586
instructions of the SQLite virtual machine. This is useful if you want to
587587
get called from SQLite during long-running operations, for example to update
588588
a GUI.
589589

590590
If you want to clear any previously installed progress handler, call the
591-
method with :const:`None` for *handler*.
591+
method with :const:`None` for *progress_handler*.
592592

593593
Returning a non-zero value from the handler function will terminate the
594594
currently executing query and cause it to raise a :exc:`DatabaseError`
@@ -628,7 +628,7 @@ Connection Objects
628628

629629
Loadable extensions are disabled by default. See [#f1]_.
630630

631-
.. audit-event:: sqlite3.enable_load_extension connection,enabled sqlite3.enable_load_extension
631+
.. audit-event:: sqlite3.enable_load_extension connection,enabled sqlite3.Connection.enable_load_extension
632632

633633
.. versionadded:: 3.2
634634

@@ -645,7 +645,7 @@ Connection Objects
645645

646646
Loadable extensions are disabled by default. See [#f1]_.
647647

648-
.. audit-event:: sqlite3.load_extension connection,path sqlite3.load_extension
648+
.. audit-event:: sqlite3.load_extension connection,path sqlite3.Connection.load_extension
649649

650650
.. versionadded:: 3.2
651651

Doc/library/test.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,51 @@ The :mod:`test.support` module defines the following constants:
413413

414414
The :mod:`test.support` module defines the following functions:
415415

416+
.. function:: busy_retry(timeout, err_msg=None, /, *, error=True)
417+
418+
Run the loop body until ``break`` stops the loop.
419+
420+
After *timeout* seconds, raise an :exc:`AssertionError` if *error* is true,
421+
or just stop the loop if *error* is false.
422+
423+
Example::
424+
425+
for _ in support.busy_retry(support.SHORT_TIMEOUT):
426+
if check():
427+
break
428+
429+
Example of error=False usage::
430+
431+
for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
432+
if check():
433+
break
434+
else:
435+
raise RuntimeError('my custom error')
436+
437+
.. function:: sleeping_retry(timeout, err_msg=None, /, *, init_delay=0.010, max_delay=1.0, error=True)
438+
439+
Wait strategy that applies exponential backoff.
440+
441+
Run the loop body until ``break`` stops the loop. Sleep at each loop
442+
iteration, but not at the first iteration. The sleep delay is doubled at
443+
each iteration (up to *max_delay* seconds).
444+
445+
See :func:`busy_retry` documentation for the parameters usage.
446+
447+
Example raising an exception after SHORT_TIMEOUT seconds::
448+
449+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
450+
if check():
451+
break
452+
453+
Example of error=False usage::
454+
455+
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
456+
if check():
457+
break
458+
else:
459+
raise RuntimeError('my custom error')
460+
416461
.. function:: is_resource_enabled(resource)
417462

418463
Return ``True`` if *resource* is enabled and available. The list of

0 commit comments

Comments
 (0)