[Python-Dev] [Python-checkins] python/dist/src/Modules _csv.c, 1.37, 1.38

Armin Rigo arigo at tunes.org
Wed Jun 15 18:48:21 CEST 2005


Hi Michael,

On Wed, Jun 15, 2005 at 03:26:00PM +0100, Michael Hudson wrote:
> > Hum, you probably don't want to know, but it works just fine to forget
> > a Py_INCREF before PyModule_AddObject() for the following reason:
> 
> No, it's more complicated than that, at least in an embedded
> scenario (see bug #1220756).

Uh, yes, indeed.  I guess that my explanations don't survive an
interpreter shutdown, after which the reference counter of the object
effectively drops to zero.  I don't see how this doesn't crash Python
when you exit.  It could be that the gc is not called after the
reference from the import mechanism was effectively removed -- type
objects after a PyType_Ready() are full of ref cycles.  But it's all
quite obscure.


Armin


More information about the Python-Dev mailing list