diff --git a/mypyc/lib-rt/misc_ops.c b/mypyc/lib-rt/misc_ops.c index ca09c347b4ff..dfbdad106f9d 100644 --- a/mypyc/lib-rt/misc_ops.c +++ b/mypyc/lib-rt/misc_ops.c @@ -619,11 +619,17 @@ int CPyStatics_Initialize(PyObject **statics, PyObject **result = statics; // Start with some hard-coded values *result++ = Py_None; +#if !CPY_3_14_FEATURES Py_INCREF(Py_None); +#endif *result++ = Py_False; +#if !CPY_3_14_FEATURES Py_INCREF(Py_False); +#endif *result++ = Py_True; +#if !CPY_3_14_FEATURES Py_INCREF(Py_True); +#endif if (strings) { for (; **strings != '\0'; strings++) { size_t num; @@ -638,6 +644,9 @@ int CPyStatics_Initialize(PyObject **statics, } PyUnicode_InternInPlace(&obj); *result++ = obj; +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif data += len; } } @@ -655,6 +664,9 @@ int CPyStatics_Initialize(PyObject **statics, return -1; } *result++ = obj; +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif data += len; } } @@ -670,6 +682,9 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif data = end; data++; *result++ = obj; @@ -683,6 +698,9 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif *result++ = obj; } } @@ -695,6 +713,9 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif *result++ = obj; } } @@ -706,10 +727,17 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif int i; for (i = 0; i < num_items; i++) { PyObject *item = statics[*tuples++]; +#if CPY_3_14_FEATURES + CPy_SetImmortal(item); +#else Py_INCREF(item); +#endif PyTuple_SET_ITEM(obj, i, item); } *result++ = obj; @@ -723,9 +751,16 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +//#if CPY_3_14_FEATURES +// CPy_SetImmortal(obj); +//#endif for (int i = 0; i < num_items; i++) { PyObject *item = statics[*frozensets++]; +#if CPY_3_14_FEATURES + CPy_SetImmortal(item); +#else Py_INCREF(item); +#endif if (PySet_Add(obj, item) == -1) { return -1; }