homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients amaury.forgeotdarc, loewis, pitrou, skrah
Date 2012年03月26日.15:02:11
SpamBayes Score 1.74692e-06
Marked as misclassified No
Message-id <1332774132.25.0.923838369322.issue11826@psf.upfronthosting.co.za>
In-reply-to
Content
Actually _iomodule.c already has a freefunc with the same signature.
atexit_free() is properly called in:
static void
module_dealloc(PyModuleObject *m)
{
 PyObject_GC_UnTrack(m);
 if (m->md_def && m->md_def->m_free)
 m->md_def->m_free(m);
 if (m->md_dict != NULL) {
 _PyModule_Clear((PyObject *)m);
 Py_DECREF(m->md_dict);
 }
 if (m->md_state != NULL)
 PyMem_FREE(m->md_state);
 Py_TYPE(m)->tp_free((PyObject *)m);
}
So my only worry is if there's a way to exploit the fact that _PyModule_Clear()
is called after atexit_free(). I tried things like: 
>>> import atexit
>>> def g(): pass
...
>>> class silly:
... def __del__(self): atexit.register(g)
...
>>> atexit.x = silly()
>>> atexit.register(g)
<function g at 0x7fe7ebb83a68>
>>>
Exception AttributeError: "'NoneType' object has no attribute 'register'" in <bound method silly.__del__ of <__main__.silly object at 0x153fc50>> ignored
But I haven't been able to break anything, so I think I'll go ahead and
commit if there aren't any protests.
History
Date User Action Args
2012年03月26日 15:02:12skrahsetrecipients: + skrah, loewis, amaury.forgeotdarc, pitrou
2012年03月26日 15:02:12skrahsetmessageid: <1332774132.25.0.923838369322.issue11826@psf.upfronthosting.co.za>
2012年03月26日 15:02:11skrahlinkissue11826 messages
2012年03月26日 15:02:11skrahcreate

AltStyle によって変換されたページ (->オリジナル) /