Aahz wrote: > In article <h49ah5$hv3$0...@news.t-online.com>, > Peter Otten <__pete...@web.de> wrote: >> >>I have a hunch that you are triggering a reload() somewhere. Example: >> >>Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18) >>[GCC 4.3.3] on linux2 >>Type "help", "copyright", "credits" or "license" for more information. >>>>> import weakref >>>>> weakref.WeakValueDictionary() >><WeakValueDictionary at 140598938447312> >>>>> import UserDict >>>>> reload(UserDict) >><module 'UserDict' from '/usr/lib/python2.6/UserDict.pyc'> >>>>> weakref.WeakValueDictionary() >>Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "/usr/lib/python2.6/weakref.py", line 51, in __init__ >> UserDict.UserDict.__init__(self, *args, **kw) >>TypeError: unbound method __init__() must be called with UserDict instance >>as first argument (got WeakValueDictionary instance instead) > > Nice sleuthing! How did you figure that out?
Roughly: - The poster's description/remedy makes no sense (to me); have a look at the traceback. - Nothing suspicious except the actual error message. Isn't WeakValueDictionary a UserDict? Verify. - There must be two different UserDict classes. This can happen to an unsuspecting user by importing the main script or by doing a reload(). UserDict is unlikely to be the main script, and web frameworks (django was mentioned) often use a reload mechanism to avoid frequent server restarts. - Reproduce the error. Peter -- http://mail.python.org/mailman/listinfo/python-list