Commit 1f35c14d authored by Stefan Behnel's avatar Stefan Behnel

divert tp_clear()/tp_traverse() to parent type if type has no object attributes

parent aa0ec1fc
...@@ -220,10 +220,16 @@ class GCDependentSlot(InternalMethodSlot): ...@@ -220,10 +220,16 @@ class GCDependentSlot(InternalMethodSlot):
InternalMethodSlot.__init__(self, slot_name) InternalMethodSlot.__init__(self, slot_name)
def slot_code(self, scope): def slot_code(self, scope):
if scope.needs_gc(): if not scope.needs_gc():
return InternalMethodSlot.slot_code(self, scope)
else:
return "0" return "0"
if not scope.has_pyobject_attrs:
# if the type does not have object attributes, it can
# delegate GC methods to its parent - iff the parent
# functions are defined in the same module
parent_type_scope = scope.parent_type.base_type.scope
if scope.parent_scope is parent_type_scope.parent_scope:
return self.slot_code(parent_type_scope)
return InternalMethodSlot.slot_code(self, scope)
class SyntheticSlot(InternalMethodSlot): class SyntheticSlot(InternalMethodSlot):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment