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 @@ -293,6 +293,7 @@ def emit_line() -> None:
293
293
"};" ,
294
294
)
295
295
if emitter .capi_version < (3 , 12 ):
296
+ # versions >= 3.12 do not define tp_weaklistoffset, but set Py_TPFLAGS_MANAGED_WEAKREF flag instead
296
297
fields ["tp_weaklistoffset" ] = base_size
297
298
else :
298
299
fields ["tp_basicsize" ] = base_size
@@ -354,6 +355,9 @@ def emit_line() -> None:
354
355
fields ["tp_call" ] = "PyVectorcall_Call"
355
356
if has_managed_dict (cl , emitter ):
356
357
flags .append ("Py_TPFLAGS_MANAGED_DICT" )
358
+ if cl .supports_weakref and emitter .capi_version >= (3 , 12 ):
359
+ flags .append ("Py_TPFLAGS_MANAGED_WEAKREF" )
360
+
357
361
fields ["tp_flags" ] = " | " .join (flags )
358
362
359
363
emitter .emit_line (f"static PyTypeObject { emitter .type_struct_name (cl )} _template_ = {{" )
You can’t perform that action at this time.
0 commit comments