Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f38dc2

Browse files
authored
Merge branch 'main' into pop_block_cleanup
2 parents 63e5c9c + 127a497 commit 1f38dc2

37 files changed

Lines changed: 865 additions & 337 deletions

Doc/c-api/structures.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
551551
from ``PyObject``.
552552
553553
Can only be used as part of :c:member:`Py_tp_members <PyTypeObject.tp_members>`
554-
:c:type:`slot <PyTypeSlot>` when creating a class using negative
554+
:c:type:`slot <PyType_Slot>` when creating a class using negative
555555
:c:member:`~PyType_Spec.basicsize`.
556556
It is mandatory in that case.
557557
558-
This flag is only used in :c:type:`PyTypeSlot`.
558+
This flag is only used in :c:type:`PyType_Slot`.
559559
When setting :c:member:`~PyTypeObject.tp_members` during
560560
class creation, Python clears it and sets
561561
:c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct.
@@ -693,7 +693,8 @@ Defining Getters and Setters
693693
694694
.. c:member:: setter set
695695
696-
Optional C function to set or delete the attribute, if omitted the attribute is readonly.
696+
Optional C function to set or delete the attribute.
697+
If ``NULL``, the attribute is read-only.
697698
698699
.. c:member:: const char* doc
699700
@@ -703,18 +704,18 @@ Defining Getters and Setters
703704
704705
Optional function pointer, providing additional data for getter and setter.
705706
706-
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
707-
instance) and a function pointer (the associated ``closure``)::
707+
.. c:type:: PyObject *(*getter)(PyObject *, void *)
708708
709-
typedef PyObject *(*getter)(PyObject *, void *);
709+
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
710+
instance) and a function pointer (the associated ``closure``):
710711
711712
It should return a new reference on success or ``NULL`` with a set exception
712713
on failure.
713714
714-
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
715-
the value to be set) and a function pointer (the associated ``closure``)::
715+
.. c:type:: int (*setter)(PyObject *, PyObject *, void *)
716716
717-
typedef int (*setter)(PyObject *, PyObject *, void *);
717+
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
718+
the value to be set) and a function pointer (the associated ``closure``):
718719
719720
In case the attribute should be deleted the second parameter is ``NULL``.
720721
Should return ``0`` on success or ``-1`` with a set exception on failure.

Doc/library/asyncio-task.rst

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -828,23 +828,22 @@ Waiting Primitives
828828
*return_when* indicates when this function should return. It must
829829
be one of the following constants:
830830

831-
.. tabularcolumns:: |l|L|
832-
833-
+-----------------------------+----------------------------------------+
834-
| Constant | Description |
835-
+=============================+========================================+
836-
| :const:`FIRST_COMPLETED` | The function will return when any |
837-
| | future finishes or is cancelled. |
838-
+-----------------------------+----------------------------------------+
839-
| :const:`FIRST_EXCEPTION` | The function will return when any |
840-
| | future finishes by raising an |
841-
| | exception. If no future raises an |
842-
| | exception then it is equivalent to |
843-
| | :const:`ALL_COMPLETED`. |
844-
+-----------------------------+----------------------------------------+
845-
| :const:`ALL_COMPLETED` | The function will return when all |
846-
| | futures finish or are cancelled. |
847-
+-----------------------------+----------------------------------------+
831+
.. list-table::
832+
:header-rows: 1
833+
834+
* - Constant
835+
- Description
836+
837+
* - .. data:: FIRST_COMPLETED
838+
- The function will return when any future finishes or is cancelled.
839+
840+
* - .. data:: FIRST_EXCEPTION
841+
- The function will return when any future finishes by raising an
842+
exception. If no future raises an exception
843+
then it is equivalent to :const:`ALL_COMPLETED`.
844+
845+
* - .. data:: ALL_COMPLETED
846+
- The function will return when all futures finish or are cancelled.
848847

849848
Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the
850849
futures when a timeout occurs.

Doc/library/concurrent.futures.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
275275

276276
.. versionchanged:: 3.3
277277
When one of the worker processes terminates abruptly, a
278-
:exc:`BrokenProcessPool` error is now raised. Previously, behaviour
278+
:exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised.
279+
Previously, behaviour
279280
was undefined but operations on the executor or its futures would often
280281
freeze or deadlock.
281282

@@ -493,23 +494,22 @@ Module Functions
493494
*return_when* indicates when this function should return. It must be one of
494495
the following constants:
495496

496-
.. tabularcolumns:: |l|L|
497-
498-
+-----------------------------+----------------------------------------+
499-
| Constant | Description |
500-
+=============================+========================================+
501-
| :const:`FIRST_COMPLETED` | The function will return when any |
502-
| | future finishes or is cancelled. |
503-
+-----------------------------+----------------------------------------+
504-
| :const:`FIRST_EXCEPTION` | The function will return when any |
505-
| | future finishes by raising an |
506-
| | exception. If no future raises an |
507-
| | exception then it is equivalent to |
508-
| | :const:`ALL_COMPLETED`. |
509-
+-----------------------------+----------------------------------------+
510-
| :const:`ALL_COMPLETED` | The function will return when all |
511-
| | futures finish or are cancelled. |
512-
+-----------------------------+----------------------------------------+
497+
.. list-table::
498+
:header-rows: 1
499+
500+
* - Constant
501+
- Description
502+
503+
* - .. data:: FIRST_COMPLETED
504+
- The function will return when any future finishes or is cancelled.
505+
506+
* - .. data:: FIRST_EXCEPTION
507+
- The function will return when any future finishes by raising an
508+
exception. If no future raises an exception
509+
then it is equivalent to :const:`ALL_COMPLETED`.
510+
511+
* - .. data:: ALL_COMPLETED
512+
- The function will return when all futures finish or are cancelled.
513513

514514
.. function:: as_completed(fs, timeout=None)
515515

@@ -570,7 +570,8 @@ Exception classes
570570
.. exception:: BrokenThreadPool
571571

572572
Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception
573-
class is raised when one of the workers of a :class:`ThreadPoolExecutor`
573+
class is raised when one of the workers
574+
of a :class:`~concurrent.futures.ThreadPoolExecutor`
574575
has failed initializing.
575576

576577
.. versionadded:: 3.7
@@ -581,7 +582,8 @@ Exception classes
581582

582583
Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly
583584
:exc:`RuntimeError`), this exception class is raised when one of the
584-
workers of a :class:`ProcessPoolExecutor` has terminated in a non-clean
585+
workers of a :class:`~concurrent.futures.ProcessPoolExecutor`
586+
has terminated in a non-clean
585587
fashion (for example, if it was killed from the outside).
586588

587589
.. versionadded:: 3.3

Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Functions and classes provided:
185185
.. note::
186186

187187
Most types managing resources support the :term:`context manager` protocol,
188-
which closes *thing* on leaving the :keyword:`with` statment.
188+
which closes *thing* on leaving the :keyword:`with` statement.
189189
As such, :func:`!closing` is most useful for third party types that don't
190190
support context managers.
191191
This example is purely for illustration purposes,

Doc/library/dbm.rst

Lines changed: 43 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ the Oracle Berkeley DB.
3636
.. versionchanged:: 3.11
3737
Accepts :term:`path-like object` for filename.
3838

39+
.. Substitutions for the open() flag param docs;
40+
all submodules use the same text.
41+
42+
.. |flag_r| replace::
43+
Open existing database for reading only.
44+
45+
.. |flag_w| replace::
46+
Open existing database for reading and writing.
47+
48+
.. |flag_c| replace::
49+
Open database for reading and writing, creating it if it doesn't exist.
50+
51+
.. |flag_n| replace::
52+
Always create a new, empty database, open for reading and writing.
53+
3954
.. function:: open(file, flag='r', mode=0o666)
4055

4156
Open the database file *file* and return a corresponding object.
@@ -46,21 +61,13 @@ the Oracle Berkeley DB.
4661

4762
The optional *flag* argument can be:
4863

49-
+---------+-------------------------------------------+
50-
| Value | Meaning |
51-
+=========+===========================================+
52-
| ``'r'`` | Open existing database for reading only |
53-
| | (default) |
54-
+---------+-------------------------------------------+
55-
| ``'w'`` | Open existing database for reading and |
56-
| | writing |
57-
+---------+-------------------------------------------+
58-
| ``'c'`` | Open database for reading and writing, |
59-
| | creating it if it doesn't exist |
60-
+---------+-------------------------------------------+
61-
| ``'n'`` | Always create a new, empty database, open |
62-
| | for reading and writing |
63-
+---------+-------------------------------------------+
64+
.. csv-table::
65+
:header: "Value", "Meaning"
66+
67+
``'r'`` (default), |flag_r|
68+
``'w'``, |flag_w|
69+
``'c'``, |flag_c|
70+
``'n'``, |flag_n|
6471

6572
The optional *mode* argument is the Unix mode of the file, used only when the
6673
database has to be created. It defaults to octal ``0o666`` (and will be
@@ -165,21 +172,13 @@ supported.
165172

166173
The optional *flag* argument can be:
167174

168-
+---------+-------------------------------------------+
169-
| Value | Meaning |
170-
+=========+===========================================+
171-
| ``'r'`` | Open existing database for reading only |
172-
| | (default) |
173-
+---------+-------------------------------------------+
174-
| ``'w'`` | Open existing database for reading and |
175-
| | writing |
176-
+---------+-------------------------------------------+
177-
| ``'c'`` | Open database for reading and writing, |
178-
| | creating it if it doesn't exist |
179-
+---------+-------------------------------------------+
180-
| ``'n'`` | Always create a new, empty database, open |
181-
| | for reading and writing |
182-
+---------+-------------------------------------------+
175+
.. csv-table::
176+
:header: "Value", "Meaning"
177+
178+
``'r'`` (default), |flag_r|
179+
``'w'``, |flag_w|
180+
``'c'``, |flag_c|
181+
``'n'``, |flag_n|
183182

184183
The following additional characters may be appended to the flag to control
185184
how the database is opened:
@@ -297,21 +296,13 @@ to locate the appropriate header file to simplify building this module.
297296

298297
The optional *flag* argument must be one of these values:
299298

300-
+---------+-------------------------------------------+
301-
| Value | Meaning |
302-
+=========+===========================================+
303-
| ``'r'`` | Open existing database for reading only |
304-
| | (default) |
305-
+---------+-------------------------------------------+
306-
| ``'w'`` | Open existing database for reading and |
307-
| | writing |
308-
+---------+-------------------------------------------+
309-
| ``'c'`` | Open database for reading and writing, |
310-
| | creating it if it doesn't exist |
311-
+---------+-------------------------------------------+
312-
| ``'n'`` | Always create a new, empty database, open |
313-
| | for reading and writing |
314-
+---------+-------------------------------------------+
299+
.. csv-table::
300+
:header: "Value", "Meaning"
301+
302+
``'r'`` (default), |flag_r|
303+
``'w'``, |flag_w|
304+
``'c'``, |flag_c|
305+
``'n'``, |flag_n|
315306

316307
The optional *mode* argument is the Unix mode of the file, used only when the
317308
database has to be created. It defaults to octal ``0o666`` (and will be
@@ -376,21 +367,13 @@ The module defines the following:
376367

377368
The optional *flag* argument can be:
378369

379-
+---------+-------------------------------------------+
380-
| Value | Meaning |
381-
+=========+===========================================+
382-
| ``'r'`` | Open existing database for reading only |
383-
| | (default) |
384-
+---------+-------------------------------------------+
385-
| ``'w'`` | Open existing database for reading and |
386-
| | writing |
387-
+---------+-------------------------------------------+
388-
| ``'c'`` | Open database for reading and writing, |
389-
| | creating it if it doesn't exist |
390-
+---------+-------------------------------------------+
391-
| ``'n'`` | Always create a new, empty database, open |
392-
| | for reading and writing |
393-
+---------+-------------------------------------------+
370+
.. csv-table::
371+
:header: "Value", "Meaning"
372+
373+
``'r'``, |flag_r|
374+
``'w'``, |flag_w|
375+
``'c'`` (default), |flag_c|
376+
``'n'``, |flag_n|
394377

395378
The optional *mode* argument is the Unix mode of the file, used only when the
396379
database has to be created. It defaults to octal ``0o666`` (and will be modified

Doc/library/ssl.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,12 +2574,8 @@ provided.
25742574
:exc:`SSLWantReadError` if it needs more data than the incoming BIO has
25752575
available.
25762576

2577-
- There is no module-level ``wrap_bio()`` call like there is for
2578-
:meth:`~SSLContext.wrap_socket`. An :class:`SSLObject` is always created
2579-
via an :class:`SSLContext`.
2580-
25812577
.. versionchanged:: 3.7
2582-
:class:`SSLObject` instances must to created with
2578+
:class:`SSLObject` instances must be created with
25832579
:meth:`~SSLContext.wrap_bio`. In earlier versions, it was possible to
25842580
create instances directly. This was never documented or officially
25852581
supported.

Doc/tools/.nitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Doc/c-api/memoryview.rst
1414
Doc/c-api/module.rst
1515
Doc/c-api/object.rst
1616
Doc/c-api/stable.rst
17-
Doc/c-api/structures.rst
1817
Doc/c-api/sys.rst
1918
Doc/c-api/type.rst
2019
Doc/c-api/typeobj.rst
@@ -27,10 +26,8 @@ Doc/library/ast.rst
2726
Doc/library/asyncio-extending.rst
2827
Doc/library/asyncio-policy.rst
2928
Doc/library/asyncio-subprocess.rst
30-
Doc/library/asyncio-task.rst
3129
Doc/library/bdb.rst
3230
Doc/library/collections.rst
33-
Doc/library/concurrent.futures.rst
3431
Doc/library/csv.rst
3532
Doc/library/datetime.rst
3633
Doc/library/dbm.rst

Include/cpython/pystate.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct _ts {
102102
#endif
103103
int _whence;
104104

105-
/* Thread state (_Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, _Py_THREAD_GC).
105+
/* Thread state (_Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, _Py_THREAD_SUSPENDED).
106106
See Include/internal/pycore_pystate.h for more details. */
107107
int state;
108108

@@ -217,11 +217,14 @@ struct _ts {
217217
#ifdef Py_DEBUG
218218
// A debug build is likely built with low optimization level which implies
219219
// higher stack memory usage than a release build: use a lower limit.
220-
# define Py_C_RECURSION_LIMIT 500
220+
# if defined(__wasi__)
221+
// Based on wasmtime 16.
222+
# define Py_C_RECURSION_LIMIT 150
223+
# else
224+
# define Py_C_RECURSION_LIMIT 500
225+
# endif
221226
#elif defined(__wasi__)
222-
// WASI has limited call stack. Python's recursion limit depends on code
223-
// layout, optimization, and WASI runtime. Wasmtime can handle about 700
224-
// recursions, sometimes less. 500 is a more conservative limit.
227+
// Based on wasmtime 16.
225228
# define Py_C_RECURSION_LIMIT 500
226229
#elif defined(__s390x__)
227230
# define Py_C_RECURSION_LIMIT 800

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame)
205205
#define _PY_CALLS_TO_DO_BIT 2
206206
#define _PY_ASYNC_EXCEPTION_BIT 3
207207
#define _PY_GC_SCHEDULED_BIT 4
208+
#define _PY_EVAL_PLEASE_STOP_BIT 5
208209

209210
/* Reserve a few bits for future use */
210211
#define _PY_EVAL_EVENTS_BITS 8

0 commit comments

Comments
 (0)