Skip to content

Commit 940932f

Browse files
committed
fix error
1 parent fe39cfb commit 940932f

6 files changed

Lines changed: 55 additions & 39 deletions

File tree

Include/internal/pycore_opcode_utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ extern "C" {
8282
#define CONSTANT_MINUS_ONE 11
8383
#define NUM_COMMON_CONSTANTS 12
8484

85-
extern PyCFunctionObject _PyBuiltin_All;
86-
extern PyCFunctionObject _PyBuiltin_Any;
85+
PyAPI_DATA(PyCFunctionObject) _PyBuiltin_All;
86+
PyAPI_DATA(PyCFunctionObject) _PyBuiltin_Any;
8787

8888
/* Filled once by pycore_init_builtins; every entry is immortal. */
89-
extern PyObject *_PyCommonConsts[NUM_COMMON_CONSTANTS];
89+
PyAPI_DATA(PyObject *) _PyCommonConsts[NUM_COMMON_CONSTANTS];
9090

9191
/* Non-static: used by static _PyBuiltin_All/_Any in bltinmodule.c. */
9292
extern PyObject *_PyCFunction_vectorcall_O(

Objects/methodobject.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ meth_hash(PyObject *self)
353353
return x;
354354
}
355355

356+
static int
357+
cfunction_is_gc(PyObject *op)
358+
{
359+
return !_Py_IsStaticImmortal(op);
360+
}
361+
356362

357363
PyTypeObject PyCFunction_Type = {
358364
PyVarObject_HEAD_INIT(&PyType_Type, 0)
@@ -388,6 +394,15 @@ PyTypeObject PyCFunction_Type = {
388394
meth_getsets, /* tp_getset */
389395
0, /* tp_base */
390396
0, /* tp_dict */
397+
0, /* tp_descr_get */
398+
0, /* tp_descr_set */
399+
0, /* tp_dictoffset */
400+
0, /* tp_init */
401+
0, /* tp_alloc */
402+
0, /* tp_new */
403+
0, /* tp_free */
404+
/* Static immortal instances have no PyGC_Head prefix. */
405+
cfunction_is_gc, /* tp_is_gc */
391406
};
392407

393408
PyTypeObject PyCMethod_Type = {

Programs/test_frozenmain.h

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bltinmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static PyMethodDef _PyBuiltin_All_methoddef = {
468468
"all", (PyCFunction)builtin_all, METH_O, builtin_all__doc__,
469469
};
470470

471-
Py_EXPORTED_SYMBOL PyCFunctionObject _PyBuiltin_All = {
471+
PyCFunctionObject _PyBuiltin_All = {
472472
.ob_base = _PyObject_HEAD_INIT(&PyCFunction_Type),
473473
.m_ml = &_PyBuiltin_All_methoddef,
474474
.m_self = NULL,
@@ -481,7 +481,7 @@ static PyMethodDef _PyBuiltin_Any_methoddef = {
481481
"any", (PyCFunction)builtin_any, METH_O, builtin_any__doc__,
482482
};
483483

484-
Py_EXPORTED_SYMBOL PyCFunctionObject _PyBuiltin_Any = {
484+
PyCFunctionObject _PyBuiltin_Any = {
485485
.ob_base = _PyObject_HEAD_INIT(&PyCFunction_Type),
486486
.m_ml = &_PyBuiltin_Any_methoddef,
487487
.m_self = NULL,
@@ -490,7 +490,7 @@ Py_EXPORTED_SYMBOL PyCFunctionObject _PyBuiltin_Any = {
490490
.vectorcall = _PyCFunction_vectorcall_O,
491491
};
492492

493-
Py_EXPORTED_SYMBOL PyObject *_PyCommonConsts[NUM_COMMON_CONSTANTS];
493+
PyObject *_PyCommonConsts[NUM_COMMON_CONSTANTS];
494494

495495
/*[clinic input]
496496
ascii as builtin_ascii

Python/pylifecycle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,12 @@ pycore_init_builtins(PyThreadState *tstate)
869869
interp->callable_cache.len = len;
870870

871871
/* Install the static all/any singletons. */
872-
if (PyDict_SetItemString(builtins_dict, "all",
873-
(PyObject *)&_PyBuiltin_All) < 0) {
872+
if (PyDict_SetItem(builtins_dict, &_Py_ID(all),
873+
(PyObject *)&_PyBuiltin_All) < 0) {
874874
goto error;
875875
}
876-
if (PyDict_SetItemString(builtins_dict, "any",
877-
(PyObject *)&_PyBuiltin_Any) < 0) {
876+
if (PyDict_SetItem(builtins_dict, &_Py_ID(any),
877+
(PyObject *)&_PyBuiltin_Any) < 0) {
878878
goto error;
879879
}
880880

Tools/gdb/libpython.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,7 @@ def is_other_python_frame(self):
18101810
return False
18111811

18121812
if (caller.startswith('cfunction_vectorcall_') or
1813+
caller.startswith('_PyCFunction_vectorcall_') or
18131814
caller == 'cfunction_call'):
18141815
arg_name = 'func'
18151816
# Within that frame:

0 commit comments

Comments
 (0)