[Python-bugs-list] [ python-Bugs-478536 ] TypeError from WeakKeyDictionary.has_key
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 06 Nov 2001 08:08:47 -0800
Bugs item #478536, was opened at 2001-11-05 19:27
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478536&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Sverker Nilsson (svenil)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: TypeError from WeakKeyDictionary.has_key
Initial Comment:
TypeError from WeakKeyDictionary.has_key
The has_key method on WeakKeyDictionary
gives a TypeError if the key is not weakly
referencable. The result I expected was 0.
I can put an exception catcher around the
call, but I think the right place for that
catcher is in the has_key method.
Sverker Nilsson
Example:
Python 2.2b1 (#5, Oct 20 2001, 03:03:53)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import weakref
>>> ref = weakref.WeakKeyDictionary()
>>> ref.has_key('asdf')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.2/weakref.py", line 182,
in has_key
return self.data.has_key(ref(key))
TypeError: 'str' objects are not weakly referencable
>>>
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478536&group_id=5470