Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refcounting bug in module initialization #317

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2517,6 +2517,7 @@ _zic_module_exec(PyObject* module)
_zic_module_state* rec = _zic_state_init(module);

rec->adapter_hooks = PyList_New(0);
Py_INCREF(rec->adapter_hooks);
davisagli marked this conversation as resolved.
Show resolved Hide resolved
if (rec->adapter_hooks == NULL)
return -1;

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
Loading