Advice for wxPython error: "'NoneType' object is not callable" in ignored
Follower
follower at iname.com
Sat Mar 1 19:46:50 EST 2003
This post is about an issue relating to wxPython, module importing and
global variables referring to (native?) wxWindows objects. (It is
mostly intended as Google-bait for anyone else having the problem in
the future, but any further information is welcome.)
The following Python error message may indicate you have this problem:
Exception exceptions.TypeError: "'NoneType' object is not callable" in
ignored
Simplest Problem Form
=====================
You have these files:
myapp.py
mypackage/__init__.py
mypackage/mymodule.py
With the following content:
# ---- myapp.py ----
import mypackage.mymodule
# ---- mypackage/__init__.py ----
# <empty>
# ---- mypackage/mymodule.py ----
import wxPython.wx
import mypackage # <1>
myglobal = wxPython.wx.wxSize(780, 580)
# -- <end> --
When you execute the command:
python myapp.py
The following is the output:
Exception exceptions.TypeError: "'NoneType' object is not callable" in
ignored
Solutions
=========
* Don't have global variables ('myglobal' in this example) referring
to wxWindows objects. (Best solution.)
* Don't explictly import the parent package from a module within it.
(i.e. delete the line marked with "<1>"--it's not necessary in real
life anyway.) While this solves the problem in certain circumstances
you may run into the problem again if you have sub-packages which
import the parent package.
Explanation (as far as I understand things)
===========
Error messages of the form "<foo> in <bar> ignored" are generated when
an exception occurs in an object's __del__() method. (In this case it
would seem Python can't identify where the exception occurred which is
why "<bar>" is blank, leaving the message "<foo> in ignored".)
The actual message indicates there are issues with the order of object
deletion with wxPython and global variables referring to
wxPython/wxWindows objects.
Other Resources
===============
See also particularly these messages on the 'wxPython-users' mailing
list:
* "[wxPython-users] Errors when app is closed by logging out",
<http://aspn.activestate.com/ASPN/Mail/Message/1545060>
<http://aspn.activestate.com/ASPN/Mail/Message/1545216>
* "[wxPython-users] weird bug with imports",
<http://aspn.activestate.com/ASPN/Mail/Message/1463373>
<http://aspn.activestate.com/ASPN/Mail/Message/1463822>
Hope this saves someone some time. :-)
More information about the Python-list
mailing list