Skip to content

Commit

Permalink
Merge pull request #317 from zopefoundation/davisagli-fix-gc-assertion
Browse files Browse the repository at this point in the history
Fix refcounting bug in module initialization
  • Loading branch information
davisagli committed Aug 26, 2024
2 parents a44f50e + c8ada7e commit 9a2d03e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
7.0.2 (unreleased)
==================

- TBD
- Fix reference-counting bug in C module initialization (broken in 7.0).
(`#316 <https://github.com/zopefoundation/zope.interface/issues/316>`_)


7.0.1 (2024-08-06)
Expand Down
7 changes: 7 additions & 0 deletions src/zope/interface/_zope_interface_coptimizations.c
Original file line number Diff line number Diff line change
Expand Up @@ -2519,6 +2519,7 @@ _zic_module_exec(PyObject* module)
rec->adapter_hooks = PyList_New(0);
if (rec->adapter_hooks == NULL)
return -1;
Py_INCREF(rec->adapter_hooks);

#if USE_STATIC_TYPES

Expand Down Expand Up @@ -2569,26 +2570,32 @@ _zic_module_exec(PyObject* module)
*/
sb_class = PyType_FromModuleAndSpec(module, &SB_type_spec, NULL);
if (sb_class == NULL) { return -1; }
Py_INCREF(sb_class);
rec->specification_base_class = TYPE(sb_class);

osd_class = PyType_FromModuleAndSpec(module, &OSD_type_spec, NULL);
if (osd_class == NULL) { return -1; }
Py_INCREF(osd_class);
rec->object_specification_descriptor_class = TYPE(osd_class);

cpb_class = PyType_FromModuleAndSpec(module, &CPB_type_spec, sb_class);
if (cpb_class == NULL) { return -1; }
Py_INCREF(cpb_class);
rec->class_provides_base_class = TYPE(cpb_class);

ib_class = PyType_FromModuleAndSpec(module, &IB_type_spec, sb_class);
if (ib_class == NULL) { return -1; }
Py_INCREF(ib_class);
rec->interface_base_class = TYPE(ib_class);

lb_class = PyType_FromModuleAndSpec(module, &LB_type_spec, NULL);
if (lb_class == NULL) { return -1; }
Py_INCREF(lb_class);
rec->lookup_base_class = TYPE(lb_class);

vb_class = PyType_FromModuleAndSpec(module, &VB_type_spec, lb_class);
if (vb_class == NULL) { return -1; }
Py_INCREF(vb_class);
rec->verifying_base_class = TYPE(vb_class);

#endif
Expand Down

0 comments on commit 9a2d03e

Please sign in to comment.