Skip to content

Commit e272804

Browse files
Merge branch 'main' into global-objects-empty-tuple
2 parents 9dfee07 + ad6c700 commit e272804

File tree

85 files changed

+803
-564
lines changed

Some content is hidden

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

85 files changed

+803
-564
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/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/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/whatsnew/3.11.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ Changes in the Python API
618618
Build Changes
619619
=============
620620

621+
* Building Python now requires a C11 compiler without optional C11 features.
622+
(Contributed by Victor Stinner in :issue:`46656`.)
623+
621624
* CPython can now be built with the ThinLTO option via ``--with-lto=thin``.
622625
(Contributed by Dong-hee Na and Brett Holman in :issue:`44340`.)
623626

@@ -630,11 +633,13 @@ Build Changes
630633
(Contributed by Victor Stinner in :issue:`45440`.)
631634

632635
* Building Python now requires a C99 ``<math.h>`` header file providing
633-
a ``NAN`` constant, or the ``__builtin_nan()`` built-in function. If a
634-
platform does not support Not-a-Number (NaN), the ``Py_NO_NAN`` macro can be
635-
defined in the ``pyconfig.h`` file.
636+
a ``NAN`` constant, or the ``__builtin_nan()`` built-in function.
636637
(Contributed by Victor Stinner in :issue:`46640`.)
637638

639+
* Building Python now requires support for floating point Not-a-Number (NaN):
640+
remove the ``Py_NO_NAN`` macro.
641+
(Contributed by Victor Stinner in :issue:`46656`.)
642+
638643
* Freelists for object structs can now be disabled. A new :program:`configure`
639644
option :option:`!--without-freelists` can be used to disable all freelists
640645
except empty tuple singleton.
@@ -853,6 +858,8 @@ Porting to Python 3.11
853858
use ``PyObject_GetAttrString((PyObject*)frame, "f_locals")``.
854859
* ``f_lasti``: removed,
855860
use ``PyObject_GetAttrString((PyObject*)frame, "f_lasti")``.
861+
Code using ``f_lasti`` with ``PyCode_Addr2Line()`` should use
862+
:c:func:`PyFrame_GetLineNumber` instead.
856863

857864
The following fields were removed entirely, as they were details
858865
of the old implementation:
@@ -1019,3 +1026,7 @@ Removed
10191026
public C API by mistake, it must only be used by Python internally.
10201027
Use the ``PyTypeObject.tp_members`` member instead.
10211028
(Contributed by Victor Stinner in :issue:`40170`.)
1029+
1030+
* Remove the ``HAVE_PY_SET_53BIT_PRECISION`` macro (moved to the internal C
1031+
API).
1032+
(Contributed by Victor Stinner in :issue:`45412`.)

Include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "pymacro.h"
4040
#include "pymath.h"
4141
#include "pymem.h"
42+
#include "pytypedefs.h"
4243
#include "pybuffer.h"
4344
#include "object.h"
4445
#include "objimpl.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 & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ struct _typeobject {
201201
iternextfunc tp_iternext;
202202

203203
/* Attribute descriptor and subclassing stuff */
204-
struct PyMethodDef *tp_methods;
205-
struct PyMemberDef *tp_members;
206-
struct PyGetSetDef *tp_getset;
204+
PyMethodDef *tp_methods;
205+
PyMemberDef *tp_members;
206+
PyGetSetDef *tp_getset;
207207
// Strong reference on a heap type, borrowed reference on a static type
208-
struct _typeobject *tp_base;
208+
PyTypeObject *tp_base;
209209
PyObject *tp_dict;
210210
descrgetfunc tp_descr_get;
211211
descrsetfunc tp_descr_set;
@@ -262,18 +262,16 @@ PyAPI_FUNC(PyObject *) _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *);
262262
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
263263
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
264264
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
265-
struct PyModuleDef;
266-
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *);
265+
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
267266

268-
struct _Py_Identifier;
269267
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
270268
PyAPI_FUNC(void) _Py_BreakPoint(void);
271269
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
272270
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
273271

274272
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
275-
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
276-
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 *);
277275
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
278276
don't raise AttributeError.
279277
@@ -284,7 +282,7 @@ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObjec
284282
is raised.
285283
*/
286284
PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
287-
PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, struct _Py_Identifier *, PyObject **);
285+
PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, _Py_Identifier *, PyObject **);
288286

289287
PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
290288

@@ -462,12 +460,9 @@ partially-deallocated object. To check this, the tp_dealloc function must be
462460
passed as second argument to Py_TRASHCAN_BEGIN().
463461
*/
464462

465-
/* Forward declarations for PyThreadState */
466-
struct _ts;
467-
468463
/* Python 3.9 private API, invoked by the macros below. */
469-
PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
470-
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);
471466
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
472467
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
473468

Include/cpython/pystate.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ typedef struct _stack_chunk {
7979
PyObject * data[1]; /* Variable sized */
8080
} _PyStackChunk;
8181

82-
// The PyThreadState typedef is in Include/pystate.h.
8382
struct _ts {
8483
/* See Python/ceval.c for comments explaining most fields */
8584

86-
struct _ts *prev;
87-
struct _ts *next;
85+
PyThreadState *prev;
86+
PyThreadState *next;
8887
PyInterpreterState *interp;
8988

9089
/* Has been initialized to a safe state.
@@ -308,12 +307,12 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
308307

309308
/* cross-interpreter data */
310309

311-
struct _xid;
312-
313310
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
314311
// opaque struct that holds data outside the object machinery. This
315312
// is necessary to pass safely between interpreters in the same process.
316-
typedef struct _xid {
313+
typedef struct _xid _PyCrossInterpreterData;
314+
315+
struct _xid {
317316
// data is the cross-interpreter-safe derivation of a Python object
318317
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
319318
// new_object func (below) encodes the data.
@@ -339,7 +338,7 @@ typedef struct _xid {
339338
// interpreter given the data. The resulting object (a new
340339
// reference) will be equivalent to the original object. This field
341340
// is required.
342-
PyObject *(*new_object)(struct _xid *);
341+
PyObject *(*new_object)(_PyCrossInterpreterData *);
343342
// free is called when the data is released. If it is NULL then
344343
// nothing will be done to free the data. For some types this is
345344
// okay (e.g. bytes) and for those types this field should be set
@@ -350,7 +349,7 @@ typedef struct _xid {
350349
// to PyMem_RawFree (the default if not explicitly set to NULL).
351350
// The call will happen with the original interpreter activated.
352351
void (*free)(void *);
353-
} _PyCrossInterpreterData;
352+
};
354353

355354
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
356355
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
@@ -360,7 +359,7 @@ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
360359

361360
/* cross-interpreter data registry */
362361

363-
typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
362+
typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *);
364363

365364
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
366365
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);

Include/cpython/traceback.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
typedef struct _traceback {
5+
typedef struct _traceback PyTracebackObject;
6+
7+
struct _traceback {
68
PyObject_HEAD
7-
struct _traceback *tb_next;
9+
PyTracebackObject *tb_next;
810
PyFrameObject *tb_frame;
911
int tb_lasti;
1012
int tb_lineno;
11-
} PyTracebackObject;
13+
};
1214

1315
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
1416
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);

Include/descrobject.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ extern "C" {
88
typedef PyObject *(*getter)(PyObject *, void *);
99
typedef int (*setter)(PyObject *, PyObject *, void *);
1010

11-
typedef struct PyGetSetDef {
11+
struct PyGetSetDef {
1212
const char *name;
1313
getter get;
1414
setter set;
1515
const char *doc;
1616
void *closure;
17-
} PyGetSetDef;
17+
};
1818

1919
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
2020
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
@@ -23,15 +23,11 @@ PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
2323
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
2424
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
2525
PyAPI_DATA(PyTypeObject) PyProperty_Type;
26-
// Forward declaration for following prototype
27-
struct PyMemberDef;
2826

2927
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
3028
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
31-
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
32-
struct PyMemberDef *);
33-
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
34-
struct PyGetSetDef *);
29+
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *);
30+
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *);
3531

3632
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
3733
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);

Include/floatobject.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
1616
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
1717
#define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
1818

19-
#ifdef Py_NAN
20-
# define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
21-
#endif
19+
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
2220

2321
#define Py_RETURN_INF(sign) \
2422
do { \

Include/internal/pycore_code.h

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

2424
typedef struct {
2525
uint32_t tp_version;
26-
uint32_t dk_version_or_hint;
26+
uint32_t dk_version;
2727
} _PyAttrCache;
2828

2929
typedef struct {

Include/internal/pycore_dtoa.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifndef PY_NO_SHORT_FLOAT_REPR
21
#ifdef __cplusplus
32
extern "C" {
43
#endif
@@ -7,6 +6,11 @@ extern "C" {
76
# error "this header requires Py_BUILD_CORE define"
87
#endif
98

9+
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
10+
11+
12+
#if _PY_SHORT_FLOAT_REPR == 1
13+
1014
/* These functions are used by modules compiled as C extension like math:
1115
they must be exported. */
1216

@@ -17,7 +21,8 @@ PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
1721
PyAPI_FUNC(double) _Py_dg_stdnan(int sign);
1822
PyAPI_FUNC(double) _Py_dg_infinity(int sign);
1923

24+
#endif // _PY_SHORT_FLOAT_REPR == 1
25+
2026
#ifdef __cplusplus
2127
}
2228
#endif
23-
#endif /* !PY_NO_SHORT_FLOAT_REPR */

0 commit comments

Comments
 (0)