Bug with super() and reload()?
Thomas Heller
theller at python.net
Thu Jan 16 07:48:22 EST 2003
I stumbled over the following problem with super() and reload().
Consider this module:
---- file mod.py ----
class X(object):
def test(self):
print "X.test"
class Y(X):
def test(self):
print "Y.test"
super(Y, self).test()
---- EOF ----
then, running this code:
---- the script ----
import mod
Y = mod.Y
reload(mod)
y = Y()
y.test()
---- EOF ----
prints this traceback:
Y.test
Traceback (most recent call last):
File "<stdin>", line 8, in ?
File "mod.py", line 8, in test
super(Y, self).test()
TypeError: super(type, obj): obj must be an instance or subtype of type
Thinking hard, I can understand why this traceback occurs: The object
'y' is not an instance of the 'Y' refered to in the source code.
Should this be considered a bug, or is it simply a wart, and reload
should be avoided?
Thomas
More information about the Python-list
mailing list