Skip to content

Commit 6b0e5ba

Browse files
committed
Catch up with main
2 parents a59d97c + 38f331d commit 6b0e5ba

File tree

122 files changed

+1209
-1154
lines changed

Some content is hidden

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

122 files changed

+1209
-1154
lines changed

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: 'Build HTML documentation'
4949
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" html
5050
- name: 'Upload'
51-
uses: actions/upload-artifact@v2.2.4
51+
uses: actions/upload-artifact@v2.3.1
5252
with:
5353
name: doc-html
5454
path: Doc/build/html

Doc/c-api/exceptions.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ For convenience, some of these functions will always return a
253253
.. versionadded:: 3.3
254254
255255
256+
.. c:function:: PyObject* PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, PyObject *name, PyObject *path)
257+
258+
Much like :c:func:`PyErr_SetImportError` but this function allows for
259+
specifying a subclass of :exc:`ImportError` to raise.
260+
261+
.. versionadded:: 3.6
262+
263+
256264
.. c:function:: void PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)
257265
258266
Set file, line, and offset information for the current exception. If the
@@ -320,13 +328,6 @@ an error value).
320328
:mod:`warnings` module and the :option:`-W` option in the command line
321329
documentation. There is no C API for warning control.
322330
323-
.. c:function:: PyObject* PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, PyObject *name, PyObject *path)
324-
325-
Much like :c:func:`PyErr_SetImportError` but this function allows for
326-
specifying a subclass of :exc:`ImportError` to raise.
327-
328-
.. versionadded:: 3.6
329-
330331
331332
.. c:function:: int PyErr_WarnExplicitObject(PyObject *category, PyObject *message, PyObject *filename, int lineno, PyObject *module, PyObject *registry)
332333

Doc/c-api/reflection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Reflection
3131
See also :c:func:`PyThreadState_GetFrame`.
3232
3333
34-
.. c:function:: int PyFrame_GetBack(PyFrameObject *frame)
34+
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
3535
3636
Get the *frame* next outer frame.
3737
@@ -42,7 +42,7 @@ Reflection
4242
.. versionadded:: 3.9
4343
4444
45-
.. c:function:: int PyFrame_GetCode(PyFrameObject *frame)
45+
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
4646
4747
Get the *frame* code.
4848

Doc/c-api/typeobj.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ PyObject Slots
476476
--------------
477477

478478
The type object structure extends the :c:type:`PyVarObject` structure. The
479-
:attr:`ob_size` field is used for dynamic types (created by :func:`type_new`,
479+
:attr:`ob_size` field is used for dynamic types (created by :func:`type_new`,
480480
usually called from a class statement). Note that :c:data:`PyType_Type` (the
481481
metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
482482
type objects) *must* have the :attr:`ob_size` field.
@@ -2000,6 +2000,17 @@ and :c:type:`PyType_Type` effectively act as defaults.)
20002000
For this field to be taken into account (even through inheritance),
20012001
you must also set the :const:`Py_TPFLAGS_HAVE_FINALIZE` flags bit.
20022002

2003+
Also, note that, in a garbage collected Python,
2004+
:c:member:`~PyTypeObject.tp_dealloc` may be called from
2005+
any Python thread, not just the thread which created the object (if the object
2006+
becomes part of a refcount cycle, that cycle might be collected by a garbage
2007+
collection on any thread). This is not a problem for Python API calls, since
2008+
the thread on which tp_dealloc is called will own the Global Interpreter Lock
2009+
(GIL). However, if the object being destroyed in turn destroys objects from some
2010+
other C or C++ library, care should be taken to ensure that destroying those
2011+
objects on the thread which called tp_dealloc will not violate any assumptions
2012+
of the library.
2013+
20032014
**Inheritance:**
20042015

20052016
This field is inherited by subtypes.
@@ -2024,17 +2035,6 @@ and :c:type:`PyType_Type` effectively act as defaults.)
20242035
.. versionadded:: 3.9 (the field exists since 3.8 but it's only used since 3.9)
20252036

20262037

2027-
Also, note that, in a garbage collected Python, :c:member:`~PyTypeObject.tp_dealloc` may be called from
2028-
any Python thread, not just the thread which created the object (if the object
2029-
becomes part of a refcount cycle, that cycle might be collected by a garbage
2030-
collection on any thread). This is not a problem for Python API calls, since
2031-
the thread on which tp_dealloc is called will own the Global Interpreter Lock
2032-
(GIL). However, if the object being destroyed in turn destroys objects from some
2033-
other C or C++ library, care should be taken to ensure that destroying those
2034-
objects on the thread which called tp_dealloc will not violate any assumptions
2035-
of the library.
2036-
2037-
20382038
.. _static-types:
20392039

20402040
Static Types
@@ -2440,7 +2440,8 @@ Async Object Structures
24402440

24412441
PyObject *am_aiter(PyObject *self);
24422442

2443-
Must return an :term:`awaitable` object. See :meth:`__anext__` for details.
2443+
Must return an :term:`asynchronous iterator` object.
2444+
See :meth:`__anext__` for details.
24442445

24452446
This slot may be set to ``NULL`` if an object does not implement
24462447
asynchronous iteration protocol.

Doc/c-api/unicode.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ Error handling is set by errors which may also be set to ``NULL`` meaning to use
10031003
the default handling defined for the codec. Default error handling for all
10041004
built-in codecs is "strict" (:exc:`ValueError` is raised).
10051005
1006-
The codecs all use a similar interface. Only deviation from the following
1006+
The codecs all use a similar interface. Only deviations from the following
10071007
generic ones are documented for simplicity.
10081008
10091009
@@ -1171,7 +1171,7 @@ These are the UTF-16 codec APIs:
11711171
``1``, any byte order mark is copied to the output (where it will result in
11721172
either a ``\ufeff`` or a ``\ufffe`` character).
11731173
1174-
After completion, *\*byteorder* is set to the current byte order at the end
1174+
After completion, ``*byteorder`` is set to the current byte order at the end
11751175
of input data.
11761176
11771177
If *byteorder* is ``NULL``, the codec starts in native order mode.
@@ -1302,7 +1302,7 @@ Character Map Codecs
13021302
13031303
This codec is special in that it can be used to implement many different codecs
13041304
(and this is in fact what was done to obtain most of the standard codecs
1305-
included in the :mod:`encodings` package). The codec uses mapping to encode and
1305+
included in the :mod:`encodings` package). The codec uses mappings to encode and
13061306
decode characters. The mapping objects provided must support the
13071307
:meth:`__getitem__` mapping interface; dictionaries and sequences work well.
13081308
@@ -1426,7 +1426,7 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
14261426
.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
14271427
14281428
Split a Unicode string at line breaks, returning a list of Unicode strings.
1429-
CRLF is considered to be one line break. If *keepend* is ``0``, the Line break
1429+
CRLF is considered to be one line break. If *keepend* is ``0``, the line break
14301430
characters are not included in the resulting strings.
14311431
14321432

Doc/c-api/veryhigh.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ the same library that the Python runtime is using.
7575
:c:func:`PyRun_SimpleFile`. *filename* is decoded from the filesystem
7676
encoding (:func:`sys.getfilesystemencoding`). If *filename* is ``NULL``, this
7777
function uses ``"???"`` as the filename.
78+
If *closeit* is true, the file is closed before
79+
``PyRun_SimpleFileExFlags()`` returns.
7880
7981
8082
.. c:function:: int PyRun_SimpleString(const char *command)

Doc/library/calendar.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
289289

290290
.. note::
291291

292-
The :meth:`formatweekday` and :meth:`formatmonthname` methods of these two
293-
classes temporarily change the ``LC_TIME`` locale to the given *locale*. Because
294-
the current locale is a process-wide setting, they are not thread-safe.
292+
The constructor, :meth:`formatweekday` and :meth:`formatmonthname` methods
293+
of these two classes temporarily change the ``LC_TIME`` locale to the given
294+
*locale*. Because the current locale is a process-wide setting, they are
295+
not thread-safe.
295296

296297

297298
For simple text calendars this module provides the following functions.

Doc/library/locale.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ The :mod:`locale` module defines the following exception and functions:
301301
*language code* and *encoding* may be ``None`` if their values cannot be
302302
determined.
303303

304+
.. deprecated:: 3.11 3.13
305+
304306

305307
.. function:: getlocale(category=LC_CTYPE)
306308

Doc/whatsnew/3.11.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ Deprecated
486486

487487
(Contributed by Hugo van Kemenade in :issue:`45173`.)
488488

489+
* The :func:`locale.getdefaultlocale` function is deprecated and will be
490+
removed in Python 3.13. Use :func:`locale.setlocale`,
491+
:func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
492+
:func:`locale.getlocale` functions instead.
493+
(Contributed by Victor Stinner in :issue:`46659`.)
494+
489495

490496
Removed
491497
=======
@@ -847,6 +853,8 @@ Porting to Python 3.11
847853
use ``PyObject_GetAttrString((PyObject*)frame, "f_locals")``.
848854
* ``f_lasti``: removed,
849855
use ``PyObject_GetAttrString((PyObject*)frame, "f_lasti")``.
856+
Code using ``f_lasti`` with ``PyCode_Addr2Line()`` should use
857+
:c:func:`PyFrame_GetLineNumber` instead.
850858

851859
The following fields were removed entirely, as they were details
852860
of the old implementation:
@@ -1013,3 +1021,7 @@ Removed
10131021
public C API by mistake, it must only be used by Python internally.
10141022
Use the ``PyTypeObject.tp_members`` member instead.
10151023
(Contributed by Victor Stinner in :issue:`40170`.)
1024+
1025+
* Remove the ``HAVE_PY_SET_53BIT_PRECISION`` macro (moved to the internal C
1026+
API).
1027+
(Contributed by Victor Stinner in :issue:`45412`.)

Include/Python.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "pymacro.h"
4040
#include "pymath.h"
4141
#include "pymem.h"
42+
#include "pytypedefs.h"
43+
#include "pybuffer.h"
4244
#include "object.h"
4345
#include "objimpl.h"
4446
#include "typeslots.h"
@@ -50,7 +52,6 @@
5052
#include "longobject.h"
5153
#include "cpython/longintrepr.h"
5254
#include "boolobject.h"
53-
#include "buffer.h"
5455
#include "floatobject.h"
5556
#include "complexobject.h"
5657
#include "rangeobject.h"

Include/boolobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
1515
Don't forget to apply Py_INCREF() when returning either!!! */
1616

1717
/* Don't use these directly */
18-
PyAPI_DATA(struct _longobject) _Py_FalseStruct;
19-
PyAPI_DATA(struct _longobject) _Py_TrueStruct;
18+
PyAPI_DATA(PyLongObject) _Py_FalseStruct;
19+
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
2020

2121
/* Use these macros */
2222
#define Py_False ((PyObject *) &_Py_FalseStruct)

Include/code.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
extern "C" {
77
#endif
88

9-
typedef struct PyCodeObject PyCodeObject;
10-
119
#ifndef Py_LIMITED_API
1210
# define Py_CPYTHON_CODE_H
1311
# include "cpython/code.h"

Include/cpython/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
133133

134134
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
135135
PyObject *obj,
136-
struct _Py_Identifier *name,
136+
_Py_Identifier *name,
137137
...);
138138

139139
static inline PyObject *

Include/cpython/descrobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct {
4343

4444
typedef struct {
4545
PyDescr_COMMON;
46-
struct PyMemberDef *d_member;
46+
PyMemberDef *d_member;
4747
} PyMemberDescrObject;
4848

4949
typedef struct {

Include/cpython/dictobject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
3232
Py_hash_t hash);
3333
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
3434
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
35-
struct _Py_Identifier *key);
35+
_Py_Identifier *key);
3636
PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
3737
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
3838
PyObject *mp, PyObject *key, PyObject *defaultobj);
@@ -49,7 +49,7 @@ PyAPI_FUNC(int) _PyDict_Next(
4949
/* Get the number of items of a dictionary. */
5050
#define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
5151
PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
52-
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, struct _Py_Identifier *);
52+
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
5353
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
5454
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
5555
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
@@ -66,9 +66,9 @@ PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
6666
argument is raised.
6767
*/
6868
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
69-
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
69+
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
7070

71-
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
71+
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
7272
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
7373

7474
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);

Include/cpython/frameobject.h

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

77
struct _frame {
88
PyObject_HEAD
9-
struct _frame *f_back; /* previous frame, or NULL */
9+
PyFrameObject *f_back; /* previous frame, or NULL */
1010
struct _interpreter_frame *f_frame; /* points to the frame data */
1111
PyObject *f_trace; /* Trace function */
1212
int f_lineno; /* Current line number. Only valid if non-zero */

Include/cpython/import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PyMODINIT_FUNC PyInit__imp(void);
66

77
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
88

9-
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
9+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
1010
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
1111
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
1212

Include/cpython/object.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
#include "buffer.h" // for Py_buffer, included after PyObject has been defined
6-
75
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
86

97
#ifdef Py_TRACE_REFS
@@ -203,11 +201,11 @@ struct _typeobject {
203201
iternextfunc tp_iternext;
204202

205203
/* Attribute descriptor and subclassing stuff */
206-
struct PyMethodDef *tp_methods;
207-
struct PyMemberDef *tp_members;
208-
struct PyGetSetDef *tp_getset;
204+
PyMethodDef *tp_methods;
205+
PyMemberDef *tp_members;
206+
PyGetSetDef *tp_getset;
209207
// Strong reference on a heap type, borrowed reference on a static type
210-
struct _typeobject *tp_base;
208+
PyTypeObject *tp_base;
211209
PyObject *tp_dict;
212210
descrgetfunc tp_descr_get;
213211
descrsetfunc tp_descr_set;
@@ -264,18 +262,16 @@ PyAPI_FUNC(PyObject *) _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *);
264262
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
265263
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
266264
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
267-
struct PyModuleDef;
268-
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *);
265+
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
269266

270-
struct _Py_Identifier;
271267
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
272268
PyAPI_FUNC(void) _Py_BreakPoint(void);
273269
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
274270
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
275271

276272
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
277-
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
278-
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
273+
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);
274+
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *);
279275
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
280276
don't raise AttributeError.
281277
@@ -286,7 +282,7 @@ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObjec
286282
is raised.
287283
*/
288284
PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
289-
PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, struct _Py_Identifier *, PyObject **);
285+
PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, _Py_Identifier *, PyObject **);
290286

291287
PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
292288

@@ -464,12 +460,9 @@ partially-deallocated object. To check this, the tp_dealloc function must be
464460
passed as second argument to Py_TRASHCAN_BEGIN().
465461
*/
466462

467-
/* Forward declarations for PyThreadState */
468-
struct _ts;
469-
470463
/* Python 3.9 private API, invoked by the macros below. */
471-
PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
472-
PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
464+
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
465+
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
473466
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
474467
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
475468

0 commit comments

Comments
 (0)