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:
323
323
"};" ,
324
324
)
325
325
if emitter .capi_version < (3 , 12 ):
326
+ # versions >= 3.12 do not define tp_weaklistoffset, but set Py_TPFLAGS_MANAGED_WEAKREF flag instead
326
327
fields ["tp_weaklistoffset" ] = base_size
327
328
else :
328
329
fields ["tp_basicsize" ] = base_size
@@ -384,6 +385,9 @@ def emit_line() -> None:
384
385
fields ["tp_call" ] = "PyVectorcall_Call"
385
386
if has_managed_dict (cl , emitter ):
386
387
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
+
387
391
fields ["tp_flags" ] = " | " .join (flags )
388
392
389
393
fields ["tp_doc" ] = native_class_doc_initializer (cl )
You can’t perform that action at this time.
0 commit comments