Commit 93c7400a authored by Stefan Behnel's avatar Stefan Behnel

Fix: reallowing tp_clear() in a subtype of an @no_gc_clear extension type...

Fix: reallowing tp_clear() in a subtype of an @no_gc_clear extension type generated an invalid C function call to the (non-existent) base type implementation.
Closes #2309.
parent df202292
......@@ -2,6 +2,17 @@
Cython Changelog
================
0.28.4 (2018-??-??)
===================
Bugs fixed
----------
* Reallowing ``tp_clear()`` in a subtype of an ``@no_gc_clear`` extension type
generated an invalid C function call to the (non-existent) base type implementation.
(Github issue #2309)
0.28.3 (2018-05-27)
===================
......
......@@ -1603,7 +1603,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("}")
def generate_clear_function(self, scope, code, cclass_entry):
tp_slot = TypeSlots.GCDependentSlot("tp_clear")
tp_slot = TypeSlots.get_slot_by_name("tp_clear")
slot_func = scope.mangle_internal("tp_clear")
base_type = scope.parent_type.base_type
if tp_slot.slot_code(scope) != slot_func:
......
......@@ -56,6 +56,21 @@ cdef class DisableTpClear:
pto.tp_clear(self)
cdef class ReallowTpClear(DisableTpClear):
"""
>>> import gc
>>> obj = ReallowTpClear()
>>> is_tp_clear_null(obj)
False
>>> obj.attr = obj # create hard reference cycle
>>> del obj; _ignore = gc.collect()
# Problem: cannot really validate that the cycle was cleaned up without using weakrefs etc...
"""
cdef public object attr
def test_closure_without_clear(str x):
"""
>>> c = test_closure_without_clear('abc')
......
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