Skip to content

Commit 4df2215

Browse files
authored
[mypyc] Fix 3.12 issue with pickling of instances with __dict__ (#15574)
This fixes the testPickling test case in mypyc/test-data/run-classes.test on Python 3.12. Handle another case that was missed in #15471. On 3.12 we rely on Py_TPFLAGS_MANAGED_DICT and shouldn't define an explicit `__dict__` member. Work on mypyc/mypyc#995.
1 parent a759c49 commit 4df2215

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypyc/codegen/emitclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def emit_line() -> None:
270270
# that isn't what we want.
271271

272272
# XXX: there is no reason for the __weakref__ stuff to be mixed up with __dict__
273-
if cl.has_dict:
273+
if cl.has_dict and not has_managed_dict(cl, emitter):
274274
# __dict__ lives right after the struct and __weakref__ lives right after that
275275
# TODO: They should get members in the struct instead of doing this nonsense.
276276
weak_offset = f"{base_size} + sizeof(PyObject *)"

0 commit comments

Comments
 (0)