[Python-Dev] Preserving the blamelist (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Apr 12 18:49:35 CEST 2006
- Previous message: [Python-Dev] Preserving the blamelist
- Next message: [Python-Dev] Preserving the blamelist
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 03:00 AM 4/12/2006 -0400, Tim Peters wrote:
Phillip, when eyeballing gendealloc(), I didn't understand two things:
1. Why doesn't if (gen->giframe->fstacktop!=NULL) { check first to be sure that gen->giframe != PyNone?
Apparently, it's because I'm an idiot, and because nobody else realized this during the initial review of the patch. :)
Is that impossible here for some reason?
No, I goofed. It's amazing that this doesn't dump core whenever a generator exits. :(
2. It looks like "giframe != NULL" is an (undocumented) invariant. Right? If so,
PyXDECREF(gen->giframe); sends a confusing message (because of the "X", implying that NULL is OK). Regardless, it would be good to add comments to genobject.h explaining the possible values giframe can hold. For example, what does it mean when giframe is PyNone? Can it ever be NULL?
I think what happened is that at one point I thought I was going to set gi_frame=NULL when there's no active frame, in order to speed up reclamation of the frame. However, I think I then thought that it would break the operation of the generator's 'gi_frame' attribute, which is defined as T_OBJECT. Or else I thought that the tp_visit was screwed up in that case.
So, it looks to me like what this should do is simply allow gi_frame to be NULL instead of Py_None, which would get rid of all the silly casting, and retroactively make the XDECREF correct. :)
Does gen_traverse() need to do anything special to visit a null pointer? Should it only conditionally visit it?
- Previous message: [Python-Dev] Preserving the blamelist
- Next message: [Python-Dev] Preserving the blamelist
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]