You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[mypyc] Pickle test failure with Python 3.14.0a1 #17973
// This is a hack. Python 3.11 doesn't include good public APIs to work with managed
// dicts, which are the default for heap types. So we try to opt-out until Python 3.12.
t->ht_type.tp_flags &= ~Py_TPFLAGS_MANAGED_DICT;
#endif
return (PyObject*)t;
#if PY_MINOR_VERSION == 11
// This is a hack. Python 3.11 doesn't include good public APIs to work with managed
// dicts, which are the default for heap types. So we try to opt-out until Python 3.12.
t->ht_type.tp_flags &= ~Py_TPFLAGS_MANAGED_DICT;
+#elif PY_MINOR_VERSION == 14+ t->ht_type.tp_flags &= ~Py_TPFLAGS_INLINE_VALUES;
With that the test case passes again (and no other test is failing because of it). However, I'm unsure that's the correct solution. With python/cpython#123192Py_TPFLAGS_INLINE_VALUES is automatically set for type->tp_itemsize == 0 which is the case here.
Activity
[-]Pickle test failure with Python 3.14a1[/-][+]Pickle test failure with Python 3.14.0a1[/+][-]Pickle test failure with Python 3.14.0a1[/-][+][mypyc] Pickle test failure with Python 3.14.0a1[/+]hauntsaninja commentedon Oct 17, 2024
I suspect it's something funky when calling
PyObject_SetAttr(obj, "__dict__", {"x": 10}), which is what mypyc will do here when unpicklingWith a debug Python build you also get a segfault following the AttributeError:
In lldb:
cdce8p commentedon Nov 20, 2024
Still an issue with
3.14.0a2cdce8p commentedon Dec 18, 2024
Still an issue with
3.14.0a3as well.Edit: And with
3.14.0a4too.cdce8p commentedon Feb 1, 2025
A possible workaround could be to disable the
Py_TPFLAGS_INLINE_VALUEShere:mypy/mypyc/lib-rt/misc_ops.c
Lines 299 to 304 in f44a60d
#if PY_MINOR_VERSION == 11 // This is a hack. Python 3.11 doesn't include good public APIs to work with managed // dicts, which are the default for heap types. So we try to opt-out until Python 3.12. t->ht_type.tp_flags &= ~Py_TPFLAGS_MANAGED_DICT; +#elif PY_MINOR_VERSION == 14 + t->ht_type.tp_flags &= ~Py_TPFLAGS_INLINE_VALUES;With that the test case passes again (and no other test is failing because of it). However, I'm unsure that's the correct solution. With python/cpython#123192
Py_TPFLAGS_INLINE_VALUESis automatically set fortype->tp_itemsize == 0which is the case here.cdce8p commentedon Feb 1, 2025
From what I can tell the
testPicklingcase also had issues when adding support for 3.12./CC @JukkaL
cdce8p commentedon May 30, 2025
This was fixed in python/cpython#134859 which will be included in Python 3.14.0b3.