File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ def emit_line() -> None:
323323 "};" ,
324324 )
325325 if emitter .capi_version < (3 , 12 ):
326+ # versions >= 3.12 do not define tp_weaklistoffset, but set Py_TPFLAGS_MANAGED_WEAKREF flag instead
326327 fields ["tp_weaklistoffset" ] = base_size
327328 else :
328329 fields ["tp_basicsize" ] = base_size
@@ -384,6 +385,9 @@ def emit_line() -> None:
384385 fields ["tp_call" ] = "PyVectorcall_Call"
385386 if has_managed_dict (cl , emitter ):
386387 flags .append ("Py_TPFLAGS_MANAGED_DICT" )
388+ if cl .supports_weakref and emitter .capi_version >= (3 , 12 ):
389+ flags .append ("Py_TPFLAGS_MANAGED_WEAKREF" )
390+
387391 fields ["tp_flags" ] = " | " .join (flags )
388392
389393 fields ["tp_doc" ] = native_class_doc_initializer (cl )
You can’t perform that action at this time.
0 commit comments