Message363591
One of the intended use cases for Py_mod_create is to return instances of ModuleType subclasses rather than straight ModuleType instances. And those are definitely legal to define:
>>> import __main__
>>> class MyModule(type(__main__)): pass
...
>>> m = MyModule('example')
>>> m
<module 'example'>
So it isn't valid to skip calling the cleanup functions just because md_state is NULL - we have no idea what Py_mod_create might have done that needs to be cleaned up.
It would *probably* be legitimate to skip calling the cleanup functions when there's no Py_mod_create slot defined, but then the rules for "Do I need to account for md_state potentially being NULL or not?" are getting complicated enough that the safest option for a module author is to always assume that md_state might be NULL and handle that case appropriately. |
|
Date |
User |
Action |
Args |
2020-03-07 12:22:22 | ncoghlan | set | recipients:
+ ncoghlan, vstinner, petr.viktorin, Dormouse759, pablogsal, shihai1991 |
2020-03-07 12:22:22 | ncoghlan | set | messageid: <1583583742.59.0.11361543648.issue39824@roundup.psfhosted.org> |
2020-03-07 12:22:22 | ncoghlan | link | issue39824 messages |
2020-03-07 12:22:22 | ncoghlan | create | |
|