diff --git a/mypyc/lib-rt/misc_ops.c b/mypyc/lib-rt/misc_ops.c index 64b4ff67b942..79c899063558 100644 --- a/mypyc/lib-rt/misc_ops.c +++ b/mypyc/lib-rt/misc_ops.c @@ -616,11 +616,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; @@ -635,6 +641,9 @@ int CPyStatics_Initialize(PyObject **statics, } PyUnicode_InternInPlace(&obj); *result++ = obj; +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif data += len; } } @@ -652,6 +661,9 @@ int CPyStatics_Initialize(PyObject **statics, return -1; } *result++ = obj; +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif data += len; } } @@ -667,6 +679,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; @@ -680,6 +695,9 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif *result++ = obj; } } @@ -692,6 +710,9 @@ int CPyStatics_Initialize(PyObject **statics, if (obj == NULL) { return -1; } +#if CPY_3_14_FEATURES + CPy_SetImmortal(obj); +#endif *result++ = obj; } } @@ -703,10 +724,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; @@ -720,9 +748,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; }