imported method from module evaluates to None in some cases

Hrvoje Niksic hniksic at xemacs.org
Sun Nov 23 05:21:24 EST 2008


Andrew <andrewpadilla1 at gmail.com> writes:

> On Nov 20, 6:53 am, Hrvoje Niksic <hnik... at xemacs.org> wrote:
>> Andrew <andrewpadil... at gmail.com> writes:
>> > I'm having a problem in some zope (2.10) code (HTTPResponse.py) where
>> > a method that gets imported somehow evaluates to None in certain cases
>> > which causes a TypeError exception to be raised (eg: TypeError:
>> > 'NoneType' object is not callable). The code excerpt is below where
>> > the exception is raised on the line with the comment 'TypeError IS
>> > RAISED HERE'.
>>
>> Could the "certain cases" involve automatic invocation of the close
>> method at interpreter shutdown?  While the interpreter shuts down,
>> module-level variables are set to None.  This is documented in some
>> detail inhttp://www.python.org/doc/essays/cleanup/, steps C1-C3.
>
> That's possible. I didn't know that. Now I guess the question for me
> is why and where did the interpreter shutdown? I don't see log entries
> relating to it. Is it possible for me to intercept an interpreter
> shutdown so I can find out the location and possibly the reason why
> the interpreter abruptly shuts down?

Normally the interpreter exits due to a call to sys.exit or simply
because the main module finishes, and this is what I had in mind.
When that happens, module contents get cleared, and __del__ finalizer
methods can get invoked with the module in a half-cleaned-up state.

I don't know why the interpreter would shut down abruptly, but I
suppose you could inspect the traceback to see what exactly caused the
exception?



More information about the Python-list mailing list