WeakValueDictionary
Tim Peters
tim.one at home.com
Wed Sep 26 00:39:41 EDT 2001
[Ken Seehof]
| >>> sys.version
| '2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]'
| >>> import weakref
| >>> d = weakref.WeakValueDictionary()
| >>> d['z']
| Traceback (most recent call last):
| File "<input>", line 1, in ?
| File "C:\PYTHON21\lib\weakref.py", line 35, in __getitem__
| o = self.data.get(key)()
| TypeError: object of type 'None' is not callable
|
| Shouldn't this be raising KeyError instead of TypeError?
It does in current CVS Python:
C:\Code\python\PCbuild>python
Python 2.2a3+ (#23, Sep 20 2001, 19:43:51) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import weakref
>>> d = weakref.WeakValueDictionary()
>>> d['z']
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\CODE\PYTHON\lib\weakref.py", line 44, in __getitem__
o = self.data[key]()
KeyError: z
>>>
I guess that's what the extra 9 lines of code do <wink>.
More information about the Python-list
mailing list