Skip to content

Commit ab4a9fa

Browse files
committed
Bump to Python 3.12
1 parent 26ba104 commit ab4a9fa

File tree

174 files changed

+11954
-3381
lines changed

Some content is hidden

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

174 files changed

+11954
-3381
lines changed

.github/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This distribution of GDB is based on (reasonably) newest development (`master` branch) version.
44

55
## Features:
6-
* Support for Python 3.11 (and required!)
6+
* Support for Python 3.12 (and required!)
77
* Support for virtualenv for GDB only (Create venv in `<gdb-dir>/venv` directory)
88
* Relocatable installation - unzip anywhere (note: Python's venv is NOT relocatable)
99
* Reduced verbosity of startup

.github/python-config-stub

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ VENV_DIR=$(realpath.exe --canonicalize-missing $SCRIPT_DIR/../../install/venv/)
1414

1515
case "$2" in
1616
--includes) echo "-I$SCRIPT_DIR/python-dev/include" ;;
17-
--ldflags) echo "-L$SCRIPT_DIR/python-dev/libs -lpython311" ;;
17+
--ldflags) echo "-L$SCRIPT_DIR/python-dev/libs -lpython312" ;;
1818
--exec-prefix) echo "$VENV_DIR" ;;
1919
--prefix) echo "$VENV_DIR" ;;
2020
*) echo "Bad arg $2. Blech!" >&2 ; exit 1 ;;

.github/python-dev/include/Python.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#include "bytearrayobject.h"
5050
#include "bytesobject.h"
5151
#include "unicodeobject.h"
52+
#include "cpython/initconfig.h"
53+
#include "pystate.h"
54+
#include "pyerrors.h"
5255
#include "longobject.h"
5356
#include "cpython/longintrepr.h"
5457
#include "boolobject.h"
@@ -74,8 +77,6 @@
7477
#include "sliceobject.h"
7578
#include "cpython/cellobject.h"
7679
#include "iterobject.h"
77-
#include "cpython/initconfig.h"
78-
#include "pystate.h"
7980
#include "cpython/genobject.h"
8081
#include "descrobject.h"
8182
#include "genericaliasobject.h"
@@ -85,7 +86,6 @@
8586
#include "cpython/picklebufobject.h"
8687
#include "cpython/pytime.h"
8788
#include "codecs.h"
88-
#include "pyerrors.h"
8989
#include "pythread.h"
9090
#include "cpython/context.h"
9191
#include "modsupport.h"

.github/python-dev/include/abstract.h

+34-8
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ extern "C" {
1414
1515
Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument
1616
is used to enable certain printing options. The only option currently
17-
supported is Py_Print_RAW.
18-
19-
(What should be said about Py_Print_RAW?). */
17+
supported is Py_PRINT_RAW. By default (flags=0), PyObject_Print() formats
18+
the object by calling PyObject_Repr(). If flags equals to Py_PRINT_RAW, it
19+
formats the object by calling PyObject_Str(). */
2020

2121

2222
/* Implemented elsewhere:
@@ -88,7 +88,7 @@ extern "C" {
8888
-1 on failure.
8989
9090
This is the equivalent of the Python statement: del o.attr_name. */
91-
#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A), NULL)
91+
#define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL)
9292

9393

9494
/* Implemented as a macro:
@@ -98,7 +98,7 @@ extern "C" {
9898
Delete attribute named attr_name, for object o. Returns -1
9999
on failure. This is the equivalent of the Python
100100
statement: del o.attr_name. */
101-
#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A), NULL)
101+
#define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL)
102102

103103

104104
/* Implemented elsewhere:
@@ -228,6 +228,32 @@ PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
228228
PyObject *name,
229229
...);
230230

231+
/* Given a vectorcall nargsf argument, return the actual number of arguments.
232+
* (For use outside the limited API, this is re-defined as a static inline
233+
* function in cpython/abstract.h)
234+
*/
235+
PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf);
236+
237+
/* Call "callable" (which must support vectorcall) with positional arguments
238+
"tuple" and keyword arguments "dict". "dict" may also be NULL */
239+
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
240+
241+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
242+
#define PY_VECTORCALL_ARGUMENTS_OFFSET \
243+
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
244+
245+
/* Perform a PEP 590-style vector call on 'callable' */
246+
PyAPI_FUNC(PyObject *) PyObject_Vectorcall(
247+
PyObject *callable,
248+
PyObject *const *args,
249+
size_t nargsf,
250+
PyObject *kwnames);
251+
252+
/* Call the method 'name' on args[0] with arguments in args[1..nargsf-1]. */
253+
PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod(
254+
PyObject *name, PyObject *const *args,
255+
size_t nargsf, PyObject *kwnames);
256+
#endif
231257

232258
/* Implemented elsewhere:
233259
@@ -722,7 +748,7 @@ PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
722748
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
723749
by PySequence_Fast, and that i is within bounds. */
724750
#define PySequence_Fast_GET_ITEM(o, i)\
725-
(PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
751+
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
726752

727753
/* Return a pointer to the underlying item array for
728754
an object returned by PySequence_Fast */
@@ -802,7 +828,7 @@ PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
802828
failure.
803829
804830
This is equivalent to the Python statement: del o[key]. */
805-
#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
831+
#define PyMapping_DelItemString(O, K) PyObject_DelItemString((O), (K))
806832

807833
/* Implemented as a macro:
808834
@@ -812,7 +838,7 @@ PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
812838
Returns -1 on failure.
813839
814840
This is equivalent to the Python statement: del o[key]. */
815-
#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
841+
#define PyMapping_DelItem(O, K) PyObject_DelItem((O), (K))
816842

817843
/* On success, return 1 if the mapping object 'o' has the key 'key',
818844
and 0 otherwise.

.github/python-dev/include/boolobject.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ extern "C" {
77
#endif
88

99

10-
PyAPI_DATA(PyTypeObject) PyBool_Type;
10+
// PyBool_Type is declared by object.h
1111

12-
#define PyBool_Check(x) Py_IS_TYPE(x, &PyBool_Type)
12+
#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
1313

14-
/* Py_False and Py_True are the only two bools in existence.
15-
Don't forget to apply Py_INCREF() when returning either!!! */
14+
/* Py_False and Py_True are the only two bools in existence. */
1615

1716
/* Don't use these directly */
1817
PyAPI_DATA(PyLongObject) _Py_FalseStruct;
1918
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
2019

2120
/* Use these macros */
22-
#define Py_False ((PyObject *) &_Py_FalseStruct)
23-
#define Py_True ((PyObject *) &_Py_TrueStruct)
21+
#define Py_False _PyObject_CAST(&_Py_FalseStruct)
22+
#define Py_True _PyObject_CAST(&_Py_TrueStruct)
2423

2524
// Test if an object is the True singleton, the same as "x is True" in Python.
2625
PyAPI_FUNC(int) Py_IsTrue(PyObject *x);
@@ -31,8 +30,8 @@ PyAPI_FUNC(int) Py_IsFalse(PyObject *x);
3130
#define Py_IsFalse(x) Py_Is((x), Py_False)
3231

3332
/* Macros for returning Py_True or Py_False, respectively */
34-
#define Py_RETURN_TRUE return Py_NewRef(Py_True)
35-
#define Py_RETURN_FALSE return Py_NewRef(Py_False)
33+
#define Py_RETURN_TRUE return Py_True
34+
#define Py_RETURN_FALSE return Py_False
3635

3736
/* Function to return a bool from a C long */
3837
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);

.github/python-dev/include/bytearrayobject.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ PyAPI_DATA(PyTypeObject) PyByteArray_Type;
2121
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
2222

2323
/* Type check macros */
24-
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
25-
#define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type)
24+
#define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type)
25+
#define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type)
2626

2727
/* Direct API functions */
2828
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);

.github/python-dev/include/bytesobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
2929

3030
#define PyBytes_Check(op) \
3131
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
32-
#define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type)
32+
#define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type)
3333

3434
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
3535
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);

.github/python-dev/include/ceval.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
3131

3232
/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
3333
#define PyEval_CallObject(callable, arg) \
34-
PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
34+
PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))
3535

3636
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
3737
PyObject *callable, const char *format, ...);

.github/python-dev/include/compile.h

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ extern "C" {
1010
#define Py_eval_input 258
1111
#define Py_func_type_input 345
1212

13-
/* This doesn't need to match anything */
14-
#define Py_fstring_input 800
15-
1613
#ifndef Py_LIMITED_API
1714
# define Py_CPYTHON_COMPILE_H
1815
# include "cpython/compile.h"

.github/python-dev/include/complexobject.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ extern "C" {
1010

1111
PyAPI_DATA(PyTypeObject) PyComplex_Type;
1212

13-
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
14-
#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
13+
#define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type)
14+
#define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type)
1515

1616
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
1717

.github/python-dev/include/cpython/abstract.h

+6-19
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,18 @@ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall(
5050
PyObject *const *args, Py_ssize_t nargs,
5151
PyObject *keywords);
5252

53-
#define PY_VECTORCALL_ARGUMENTS_OFFSET \
54-
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
55-
53+
// PyVectorcall_NARGS() is exported as a function for the stable ABI.
54+
// Here (when we are not using the stable ABI), the name is overridden to
55+
// call a static inline function for best performance.
56+
#define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n)
5657
static inline Py_ssize_t
57-
PyVectorcall_NARGS(size_t n)
58+
_PyVectorcall_NARGS(size_t n)
5859
{
5960
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
6061
}
6162

6263
PyAPI_FUNC(vectorcallfunc) PyVectorcall_Function(PyObject *callable);
6364

64-
PyAPI_FUNC(PyObject *) PyObject_Vectorcall(
65-
PyObject *callable,
66-
PyObject *const *args,
67-
size_t nargsf,
68-
PyObject *kwnames);
69-
7065
// Backwards compatibility aliases for API that was provisional in Python 3.8
7166
#define _PyObject_Vectorcall PyObject_Vectorcall
7267
#define _PyObject_VectorcallMethod PyObject_VectorcallMethod
@@ -84,10 +79,6 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
8479
size_t nargsf,
8580
PyObject *kwargs);
8681

87-
/* Call "callable" (which must support vectorcall) with positional arguments
88-
"tuple" and keyword arguments "dict". "dict" may also be NULL */
89-
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
90-
9182
// Same as PyObject_Vectorcall(), except without keyword arguments
9283
PyAPI_FUNC(PyObject *) _PyObject_FastCall(
9384
PyObject *func,
@@ -96,10 +87,6 @@ PyAPI_FUNC(PyObject *) _PyObject_FastCall(
9687

9788
PyAPI_FUNC(PyObject *) PyObject_CallOneArg(PyObject *func, PyObject *arg);
9889

99-
PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod(
100-
PyObject *name, PyObject *const *args,
101-
size_t nargsf, PyObject *kwnames);
102-
10390
static inline PyObject *
10491
PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
10592
{
@@ -176,7 +163,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
176163
/* Assume tp_as_sequence and sq_item exist and that 'i' does not
177164
need to be corrected for a negative index. */
178165
#define PySequence_ITEM(o, i)\
179-
( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
166+
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
180167

181168
#define PY_ITERSEARCH_COUNT 1
182169
#define PY_ITERSEARCH_INDEX 2

.github/python-dev/include/cpython/bytearrayobject.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ static inline char* PyByteArray_AS_STRING(PyObject *op)
2525
}
2626
return _PyByteArray_empty_string;
2727
}
28-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
29-
# define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
30-
#endif
28+
#define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
3129

3230
static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
3331
PyByteArrayObject *self = _PyByteArray_CAST(op);
3432
return Py_SIZE(self);
3533
}
36-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
37-
# define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))
38-
#endif
34+
#define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))

.github/python-dev/include/cpython/bytesobject.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@ static inline char* PyBytes_AS_STRING(PyObject *op)
3636
{
3737
return _PyBytes_CAST(op)->ob_sval;
3838
}
39-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
40-
# define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op))
41-
#endif
39+
#define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op))
4240

4341
static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
4442
PyBytesObject *self = _PyBytes_CAST(op);
4543
return Py_SIZE(self);
4644
}
47-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
48-
# define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
49-
#endif
45+
#define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
5046

5147
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
5248
x must be an iterable object. */

.github/python-dev/include/cpython/cellobject.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,27 @@ typedef struct {
1515

1616
PyAPI_DATA(PyTypeObject) PyCell_Type;
1717

18-
#define PyCell_Check(op) Py_IS_TYPE(op, &PyCell_Type)
18+
#define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type)
1919

2020
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
2121
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
2222
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
2323

24-
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
25-
#define PyCell_SET(op, v) _Py_RVALUE(((PyCellObject *)(op))->ob_ref = (v))
24+
static inline PyObject* PyCell_GET(PyObject *op) {
25+
PyCellObject *cell;
26+
assert(PyCell_Check(op));
27+
cell = _Py_CAST(PyCellObject*, op);
28+
return cell->ob_ref;
29+
}
30+
#define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op))
31+
32+
static inline void PyCell_SET(PyObject *op, PyObject *value) {
33+
PyCellObject *cell;
34+
assert(PyCell_Check(op));
35+
cell = _Py_CAST(PyCellObject*, op);
36+
cell->ob_ref = value;
37+
}
38+
#define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value))
2639

2740
#ifdef __cplusplus
2841
}

.github/python-dev/include/cpython/ceval.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#endif
44

55
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
6+
PyAPI_FUNC(void) PyEval_SetProfileAllThreads(Py_tracefunc, PyObject *);
67
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
78
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
9+
PyAPI_FUNC(void) PyEval_SetTraceAllThreads(Py_tracefunc, PyObject *);
810
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
911

1012
/* Helper to look up a builtin object */
@@ -20,7 +22,14 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _P
2022
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
2123
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
2224

23-
PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
25+
PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
26+
27+
PyAPI_FUNC(Py_ssize_t) PyUnstable_Eval_RequestCodeExtraIndex(freefunc);
28+
// Old name -- remove when this API changes:
29+
_Py_DEPRECATED_EXTERNALLY(3.12) static inline Py_ssize_t
30+
_PyEval_RequestCodeExtraIndex(freefunc f) {
31+
return PyUnstable_Eval_RequestCodeExtraIndex(f);
32+
}
2433

2534
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
2635
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);

0 commit comments

Comments
 (0)