I have code that creates an exception on exit. I can't imagine why.
Exception exceptions.TypeError: "'NoneType' object is not callable" in
<bound method glLibLight.__del__ of <glLib.glLibLight.glLibLight instance at
This error only happens on exit. Ideas?
From: Mike C. Fletcher <mcfletch@vr...> - 2009-04-05 01:19:18
Ian Mallett wrote:
> I have code that creates an exception on exit. I can't imagine why.
> Exception exceptions.TypeError: "'NoneType' object is not callable" in
> <bound method glLibLight.__del__ of <glLib.glLibLight.glLibLight
> instance at 0x034B3F80>> ignored
> This error only happens on exit. Ideas?
I'm gathering "glLib.glLibLight" is your code. You'll have a __del__
method on one of those objects that tries to call e.g. an OpenGL
function. During interpreter shutdown the global namespaces of modules
are cleared out so that every name is set to None. Your __del__ method
is trying to call a function by name and the result is an attempt to
call the None object. If you need to have access to a function in a
__del__ method you need to arrange to be sure that function is available
(e.g. by binding as an argument) or check that it is non-null before
calling it, or catch the error in the __del__.
Incidentally, it is generally better to use weakrefs rather than __del__
methods, as __del__ methods prevent garbage collection from operating if
there is a loop in your object references. See the vbo module for an
example of usage, though as I read it I realize that it's not properly
handling cases where the namespace is cleared out before it's called
either. (Should catch the errors to make it safe).
Mike C. Fletcher
Designer, VR Plumber, Coder