[Python-bugs-list] [ python-Bugs-478534 ] SystemError with WeakKeyDictionary
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 06 Nov 2001 08:33:38 -0800
Bugs item #478534, was opened at 2001-11-05 19:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478534&group_id=5470
Category: Python Interpreter Core
Group: Python 2.2
>Status: Pending
>Resolution: Works For Me
Priority: 5
Submitted By: Sverker Nilsson (svenil)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: SystemError with WeakKeyDictionary
Initial Comment:
SystemError with WeakKeyDictionary
A SystemError is generated when trying
to iterate over a function returned from a
function that stored it in a WeakKeyDictionary.
The expected error was TypeError.
Sverker Nilsson
Examples:
This program gives a SystemError:
import weakref
ref = weakref.WeakKeyDictionary()
def encapsulate():
f = lambda : ()
ref[f] = None
return f
for x in encapsulate():
print x
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.
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/tmp/pythona04442", line 9, in ?
for x in encapsulate():
SystemError: error return without exception set
>>>
A variation of it, with a temporary variable,
gives the expected TypeError:
import weakref
ref = weakref.WeakKeyDictionary()
def encapsulate():
f = lambda : ()
ref[f] = None
return f
g = encapsulate()
for x in g:
print x
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/tmp/pythona04442", line 10, in ?
for x in g:
TypeError: iteration over non-sequence
>>>
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-11-06 08:33
Message:
Logged In: YES
user_id=3066
I cannot reproduce this using either code snippet. Note
that the second example should (and does for me) raise
TypeError when calling add() -- you left in a "self" that
appears to be unintended.
Are you using 2.2b1 or CVS python?
----------------------------------------------------------------------
Comment By: Sverker Nilsson (svenil)
Date: 2001-11-05 23:17
Message:
Logged In: YES
user_id=356603
The same problem now occured in another situation. I am
enclosing the condensed program. /Sverker
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478534&group_id=5470