[issue18674] Store weak references in modules_by_index

Antoine Pitrou report at bugs.python.org
Tue Aug 6 23:37:44 CEST 2013


Antoine Pitrou added the comment:

Theoretically, people *should* already incref the result from PyState_FindModule. On the other hand, the object currently wouldn't be lost unless something else calls PyState_RemoveModule(), which is hardly every used AFAICT.

The only saving grace is that PyState_FindModule() is py3-specific, and only used for extension modules which have a positive m_size (probably not many of them yet).

(I think this issue teaches us that borrowed ref-returning APIs are a bad idea)

Unfortunately, without this change, we also make it difficult or impossible to reclaim extension modules using the GC. At least I cannot think of another way.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18674>
_______________________________________


More information about the Python-bugs-list mailing list