Skip to content

Commit 1bdb611

Browse files
author
Erlend E. Aasland
committed
Merge branch 'main' into sqlite-serialize
Regen clinic after pythonGH-27155.
2 parents ddf4da1 + 3b56b3b commit 1bdb611

File tree

354 files changed

+15826
-9566
lines changed

Some content is hidden

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

354 files changed

+15826
-9566
lines changed

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Lib/ast.py @isidentical
128128

129129
**/*idlelib* @terryjreedy
130130

131-
**/*typing* @gvanrossum @ilevkivskyi
131+
**/*typing* @gvanrossum @Fidget-Spinner
132132

133133
**/*asyncore @giampaolo
134134
**/*asynchat @giampaolo

.github/workflows/doc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: 'Build documentation'
4141
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html
4242
- name: 'Upload'
43-
uses: actions/upload-artifact@v2.2.3
43+
uses: actions/upload-artifact@v2.2.4
4444
with:
4545
name: doc-html
4646
path: Doc/build/html

Doc/c-api/code.rst

+8
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,11 @@ bound into a function.
5959
6060
For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626
6161
<https://www.python.org/dev/peps/pep-0626/#out-of-process-debuggers-and-profilers>`_.
62+
63+
.. c:function:: int PyCode_Addr2Location(PyObject *co, int byte_offset, int *start_line, int *start_column, int *end_line, int *end_column)
64+
65+
Sets the passed ``int`` pointers to the source code line and column numbers
66+
for the instruction at ``byte_offset``. Sets the value to ``0`` when
67+
information is not available for any particular element.
68+
69+
Returns ``1`` if the function succeeds and 0 otherwise.

Doc/c-api/function.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ There are a few functions specific to Python functions.
3636
3737
The function's docstring and name are retrieved from the code object. *__module__*
3838
is retrieved from *globals*. The argument defaults, annotations and closure are
39-
set to ``NULL``. *__qualname__* is set to the same value as the function's name.
39+
set to ``NULL``. *__qualname__* is set to the same value as the code object's
40+
``co_qualname`` field.
4041
4142
4243
.. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname)
4344
4445
As :c:func:`PyFunction_New`, but also allows setting the function object's
4546
``__qualname__`` attribute. *qualname* should be a unicode object or ``NULL``;
46-
if ``NULL``, the ``__qualname__`` attribute is set to the same value as its
47-
``__name__`` attribute.
47+
if ``NULL``, the ``__qualname__`` attribute is set to the same value as the
48+
code object's ``co_qualname`` field.
4849
4950
.. versionadded:: 3.3
5051

Doc/c-api/init_config.rst

+10
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,16 @@ PyConfig
596596
597597
.. versionadded:: 3.10
598598
599+
.. c:member:: int no_debug_ranges
600+
601+
If equals to ``1``, disables the inclusion of the end line and column
602+
mappings in code objects. Also disables traceback printing carets to
603+
specific error locations.
604+
605+
Default: ``0``.
606+
607+
.. versionadded:: 3.11
608+
599609
.. c:member:: wchar_t* check_hash_pycs_mode
600610
601611
Control the validation behavior of hash-based ``.pyc`` files:

Doc/c-api/memory.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Customize Memory Allocators
490490
Debug hooks on the Python memory allocators
491491
===========================================
492492
493-
When :ref:`Python is built is debug mode <debug-build>`, the
493+
When :ref:`Python is built in debug mode <debug-build>`, the
494494
:c:func:`PyMem_SetupDebugHooks` function is called at the :ref:`Python
495495
preinitialization <c-preinit>` to setup debug hooks on Python memory allocators
496496
to detect memory errors.

Doc/c-api/typeobj.rst

+9-8
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
710710

711711
.. warning::
712712

713-
It is not recommended for :ref:`heap types <heap-types>` to implement
713+
It is not recommended for :ref:`mutable heap types <heap-types>` to implement
714714
the vectorcall protocol.
715715
When a user sets :attr:`__call__` in Python code, only *tp_call* is updated,
716716
likely making it inconsistent with the vectorcall function.
@@ -734,8 +734,9 @@ and :c:type:`PyType_Type` effectively act as defaults.)
734734
always inherited. If it's not, then the subclass won't use
735735
:ref:`vectorcall <vectorcall>`, except when
736736
:c:func:`PyVectorcall_Call` is explicitly called.
737-
This is in particular the case for :ref:`heap types <heap-types>`
738-
(including subclasses defined in Python).
737+
This is in particular the case for types without the
738+
:const:`Py_TPFLAGS_IMMUTABLETYPE` flag set (including subclasses defined in
739+
Python).
739740

740741

741742
.. c:member:: getattrfunc PyTypeObject.tp_getattr
@@ -1125,9 +1126,9 @@ and :c:type:`PyType_Type` effectively act as defaults.)
11251126

11261127
**Inheritance:**
11271128

1128-
This flag is never inherited by :ref:`heap types <heap-types>`.
1129-
For extension types, it is inherited whenever
1130-
:c:member:`~PyTypeObject.tp_descr_get` is inherited.
1129+
This flag is never inherited by types without the
1130+
:const:`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it is
1131+
inherited whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited.
11311132

11321133

11331134
.. XXX Document more flags here?
@@ -1172,9 +1173,9 @@ and :c:type:`PyType_Type` effectively act as defaults.)
11721173

11731174
**Inheritance:**
11741175

1175-
This bit is inherited for :ref:`static subtypes <static-types>` if
1176+
This bit is inherited for types with the
1177+
:const:`Py_TPFLAGS_IMMUTABLETYPE` flag set, if
11761178
:c:member:`~PyTypeObject.tp_call` is also inherited.
1177-
:ref:`Heap types <heap-types>` do not inherit ``Py_TPFLAGS_HAVE_VECTORCALL``.
11781179

11791180
.. versionadded:: 3.9
11801181

Doc/c-api/veryhigh.rst

-36
Original file line numberDiff line numberDiff line change
@@ -185,42 +185,6 @@ the same library that the Python runtime is using.
185185
:c:func:`PyMem_RawRealloc`, instead of being allocated by
186186
:c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.
187187
188-
189-
.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start)
190-
191-
This is a simplified interface to
192-
:c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set
193-
to ``NULL`` and *flags* set to ``0``.
194-
195-
196-
.. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags)
197-
198-
This is a simplified interface to
199-
:c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set
200-
to ``NULL``.
201-
202-
203-
.. c:function:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
204-
205-
Parse Python source code from *str* using the start token *start* according to
206-
the *flags* argument. The result can be used to create a code object which can
207-
be evaluated efficiently. This is useful if a code fragment must be evaluated
208-
many times. *filename* is decoded from the :term:`filesystem encoding and
209-
error handler`.
210-
211-
212-
.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
213-
214-
This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below,
215-
leaving *flags* set to ``0``.
216-
217-
218-
.. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
219-
220-
Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python
221-
source code is read from *fp* instead of an in-memory string.
222-
223-
224188
.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
225189
226190
This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving

Doc/data/refcounts.dat

-26
Original file line numberDiff line numberDiff line change
@@ -1791,32 +1791,6 @@ PyObject_TypeCheck:int:::
17911791
PyObject_TypeCheck:PyObject*:o:0:
17921792
PyObject_TypeCheck:PyTypeObject*:type:0:
17931793

1794-
PyParser_SimpleParseFile:struct _node*:::
1795-
PyParser_SimpleParseFile:FILE*:fp::
1796-
PyParser_SimpleParseFile:const char*:filename::
1797-
PyParser_SimpleParseFile:int:start::
1798-
1799-
PyParser_SimpleParseFileFlags:struct _node*:::
1800-
PyParser_SimpleParseFileFlags:FILE*:fp::
1801-
PyParser_SimpleParseFileFlags:const char*:filename::
1802-
PyParser_SimpleParseFileFlags:int:start::
1803-
PyParser_SimpleParseFileFlags:int:flags::
1804-
1805-
PyParser_SimpleParseString:struct _node*:::
1806-
PyParser_SimpleParseString:const char*:str::
1807-
PyParser_SimpleParseString:int:start::
1808-
1809-
PyParser_SimpleParseStringFlags:struct _node*:::
1810-
PyParser_SimpleParseStringFlags:const char*:str::
1811-
PyParser_SimpleParseStringFlags:int:start::
1812-
PyParser_SimpleParseStringFlags:int:flags::
1813-
1814-
PyParser_SimpleParseStringFlagsFilename:struct _node*:::
1815-
PyParser_SimpleParseStringFlagsFilename:const char*:str::
1816-
PyParser_SimpleParseStringFlagsFilename:const char*:filename::
1817-
PyParser_SimpleParseStringFlagsFilename:int:start::
1818-
PyParser_SimpleParseStringFlagsFilename:int:flags::
1819-
18201794
PyRun_AnyFile:int:::
18211795
PyRun_AnyFile:FILE*:fp::
18221796
PyRun_AnyFile:const char*:filename::

Doc/distributing/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ involved in creating and publishing a project:
131131
* `The .pypirc file`_
132132

133133
.. _Project structure: \
134-
https://packaging.python.org/tutorials/distributing-packages/
134+
https://packaging.python.org/tutorials/packaging-projects/#packaging-python-projects
135135
.. _Building and packaging the project: \
136-
https://packaging.python.org/tutorials/distributing-packages/#packaging-your-project
136+
https://packaging.python.org/tutorials/packaging-projects/#creating-the-package-files
137137
.. _Uploading the project to the Python Packaging Index: \
138-
https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
138+
https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
139139
.. _The .pypirc file: \
140140
https://packaging.python.org/specifications/pypirc/
141141

Doc/faq/extending.rst

+2-33
Original file line numberDiff line numberDiff line change
@@ -275,39 +275,8 @@ for more hints.
275275

276276
However sometimes you have to run the embedded Python interpreter in the same
277277
thread as your rest application and you can't allow the
278-
:c:func:`PyRun_InteractiveLoop` to stop while waiting for user input. The one
279-
solution then is to call :c:func:`PyParser_ParseString` and test for ``e.error``
280-
equal to ``E_EOF``, which means the input is incomplete. Here's a sample code
281-
fragment, untested, inspired by code from Alex Farber::
282-
283-
#define PY_SSIZE_T_CLEAN
284-
#include <Python.h>
285-
#include <node.h>
286-
#include <errcode.h>
287-
#include <grammar.h>
288-
#include <parsetok.h>
289-
#include <compile.h>
290-
291-
int testcomplete(char *code)
292-
/* code should end in \n */
293-
/* return -1 for error, 0 for incomplete, 1 for complete */
294-
{
295-
node *n;
296-
perrdetail e;
297-
298-
n = PyParser_ParseString(code, &_PyParser_Grammar,
299-
Py_file_input, &e);
300-
if (n == NULL) {
301-
if (e.error == E_EOF)
302-
return 0;
303-
return -1;
304-
}
305-
306-
PyNode_Free(n);
307-
return 1;
308-
}
309-
310-
Another solution is trying to compile the received string with
278+
:c:func:`PyRun_InteractiveLoop` to stop while waiting for user input.
279+
A solution is trying to compile the received string with
311280
:c:func:`Py_CompileString`. If it compiles without errors, try to execute the
312281
returned code object by calling :c:func:`PyEval_EvalCode`. Otherwise save the
313282
input for later. If the compilation fails, find out if it's an error or just

Doc/library/argparse.rst

+2
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,8 @@ is available in ``argparse`` and adds support for boolean actions such as
853853
>>> parser.parse_args(['--no-foo'])
854854
Namespace(foo=False)
855855

856+
.. versionadded:: 3.9
857+
856858
The recommended way to create a custom action is to extend :class:`Action`,
857859
overriding the ``__call__`` method and optionally the ``__init__`` and
858860
``format_usage`` methods.

Doc/library/asyncio-eventloop.rst

+4-8
Original file line numberDiff line numberDiff line change
@@ -1132,16 +1132,12 @@ Executing code in thread or process pools
11321132
.. method:: loop.set_default_executor(executor)
11331133

11341134
Set *executor* as the default executor used by :meth:`run_in_executor`.
1135-
*executor* should be an instance of
1135+
*executor* must be an instance of
11361136
:class:`~concurrent.futures.ThreadPoolExecutor`.
11371137

1138-
.. deprecated:: 3.8
1139-
Using an executor that is not an instance of
1140-
:class:`~concurrent.futures.ThreadPoolExecutor` is deprecated and
1141-
will trigger an error in Python 3.9.
1142-
1143-
*executor* must be an instance of
1144-
:class:`concurrent.futures.ThreadPoolExecutor`.
1138+
.. versionchanged:: 3.11
1139+
*executor* must be an instance of
1140+
:class:`~concurrent.futures.ThreadPoolExecutor`.
11451141

11461142

11471143
Error Handling API

Doc/library/asyncio-task.rst

+2-62
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ other coroutines::
148148
* a *coroutine object*: an object returned by calling a
149149
*coroutine function*.
150150

151-
asyncio also supports legacy :ref:`generator-based
152-
<asyncio_generator_based_coro>` coroutines.
153-
154151

155152
.. rubric:: Tasks
156153

@@ -695,7 +692,7 @@ Running in Threads
695692

696693
This coroutine function is primarily intended to be used for executing
697694
IO-bound functions/methods that would otherwise block the event loop if
698-
they were ran in the main thread. For example::
695+
they were run in the main thread. For example::
699696

700697
def blocking_io():
701698
print(f"start blocking_io at {time.strftime('%X')}")
@@ -766,7 +763,7 @@ Scheduling From Other Threads
766763

767764
try:
768765
result = future.result(timeout)
769-
except asyncio.TimeoutError:
766+
except concurrent.futures.TimeoutError:
770767
print('The coroutine took too long, cancelling the task...')
771768
future.cancel()
772769
except Exception as exc:
@@ -1042,60 +1039,3 @@ Task Object
10421039
in the :func:`repr` output of a task object.
10431040

10441041
.. versionadded:: 3.8
1045-
1046-
1047-
.. _asyncio_generator_based_coro:
1048-
1049-
Generator-based Coroutines
1050-
==========================
1051-
1052-
.. note::
1053-
1054-
Support for generator-based coroutines is **deprecated** and
1055-
is scheduled for removal in Python 3.10.
1056-
1057-
Generator-based coroutines predate async/await syntax. They are
1058-
Python generators that use ``yield from`` expressions to await
1059-
on Futures and other coroutines.
1060-
1061-
Generator-based coroutines should be decorated with
1062-
:func:`@asyncio.coroutine <asyncio.coroutine>`, although this is not
1063-
enforced.
1064-
1065-
1066-
.. decorator:: coroutine
1067-
1068-
Decorator to mark generator-based coroutines.
1069-
1070-
This decorator enables legacy generator-based coroutines to be
1071-
compatible with async/await code::
1072-
1073-
@asyncio.coroutine
1074-
def old_style_coroutine():
1075-
yield from asyncio.sleep(1)
1076-
1077-
async def main():
1078-
await old_style_coroutine()
1079-
1080-
This decorator should not be used for :keyword:`async def`
1081-
coroutines.
1082-
1083-
.. deprecated-removed:: 3.8 3.10
1084-
1085-
Use :keyword:`async def` instead.
1086-
1087-
.. function:: iscoroutine(obj)
1088-
1089-
Return ``True`` if *obj* is a :ref:`coroutine object <coroutine>`.
1090-
1091-
This method is different from :func:`inspect.iscoroutine` because
1092-
it returns ``True`` for generator-based coroutines.
1093-
1094-
.. function:: iscoroutinefunction(func)
1095-
1096-
Return ``True`` if *func* is a :ref:`coroutine function
1097-
<coroutine>`.
1098-
1099-
This method is different from :func:`inspect.iscoroutinefunction`
1100-
because it returns ``True`` for generator-based coroutine functions
1101-
decorated with :func:`@coroutine <coroutine>`.

Doc/library/atexit.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ internal error is detected, or when :func:`os._exit` is called.
4848

4949
.. function:: unregister(func)
5050

51-
Remove *func* from the list of functions to be run at interpreter
52-
shutdown. After calling :func:`unregister`, *func* is guaranteed not to be
53-
called when the interpreter shuts down, even if it was registered more than
54-
once. :func:`unregister` silently does nothing if *func* was not previously
55-
registered.
51+
Remove *func* from the list of functions to be run at interpreter shutdown.
52+
:func:`unregister` silently does nothing if *func* was not previously
53+
registered. If *func* has been registered more than once, every occurrence
54+
of that function in the :mod:`atexit` call stack will be removed. Equality
55+
comparisons (``==``) are used internally during unregistration, so function
56+
references do not need to have matching identities.
5657

5758

5859
.. seealso::

0 commit comments

Comments
 (0)