[Python-Dev] Preserving the blamelist (original) (raw)

Tim Peters tim.peters at gmail.com
Wed Apr 12 09:00:11 CEST 2006


[Neal]

... I'm concerned about the negative ref leak in testcontextlib. I wonder if this was a result of PJE's fix for generators?

[Tim]

I don't know, but if you do

while 1: testcontextlib.testmain() gc.collect() under a debug build it eventually (> 500 iterations) crashes with Fatal Python error: deallocating None ...

OK, I fixed that (incorrect decref in gen_throw()).

Neal, that should also repair test_contextlib's ref leak oddities. The reason you didn't see this before is that test_contextlib didn't actually run any tests until recently.

Phillip, when eyeballing gen_dealloc(), I didn't understand two things:

  1. Why doesn't

    if (gen->gi_frame->f_stacktop!=NULL) {

    check first to be sure that gen->gi_frame != Py_None? Is that impossible here for some reason?

  2. It looks like "gi_frame != NULL" is an (undocumented) invariant. Right? If so,

    Py_XDECREF(gen->gi_frame);

    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 gi_frame can hold. For example, what does it mean when gi_frame is Py_None? Can it ever be NULL? It's very hard to reverse- engineer invariants and "special value" intents from staring at code. Not to say that isn't fun ;-)



More information about the Python-Dev mailing list