Skip to content

Commit

Permalink
Fix ManagedDict functions for Python 3.13 (#17507)
Browse files Browse the repository at this point in the history
`PyObject_VisitManagedDict` and `PyObject_ClearManagedDict` were made
public in python/cpython#108763. Both are
available from `pythoncapi_compat.h`.
  • Loading branch information
cdce8p authored Jul 8, 2024
1 parent acc65b5 commit 78d1dfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypyc/codegen/emitclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def generate_traverse_for_class(cl: ClassIR, func_name: str, emitter: Emitter) -
for attr, rtype in base.attributes.items():
emitter.emit_gc_visit(f"self->{emitter.attr(attr)}", rtype)
if has_managed_dict(cl, emitter):
emitter.emit_line("_PyObject_VisitManagedDict((PyObject *)self, visit, arg);")
emitter.emit_line("PyObject_VisitManagedDict((PyObject *)self, visit, arg);")
elif cl.has_dict:
struct_name = cl.struct_name(emitter.names)
# __dict__ lives right after the struct and __weakref__ lives right after that
Expand All @@ -757,7 +757,7 @@ def generate_clear_for_class(cl: ClassIR, func_name: str, emitter: Emitter) -> N
for attr, rtype in base.attributes.items():
emitter.emit_gc_clear(f"self->{emitter.attr(attr)}", rtype)
if has_managed_dict(cl, emitter):
emitter.emit_line("_PyObject_ClearManagedDict((PyObject *)self);")
emitter.emit_line("PyObject_ClearManagedDict((PyObject *)self);")
elif cl.has_dict:
struct_name = cl.struct_name(emitter.names)
# __dict__ lives right after the struct and __weakref__ lives right after that
Expand Down

0 comments on commit 78d1dfe

Please sign in to comment.