[IronPython] Dict iteration inconsistency?

Dino Viehland dinov at exchange.microsoft.com
Fri May 19 18:32:59 CEST 2006


But we probably shouldn't be throwing an exception here if CPython isn't... I've opened a bug on this.

Do you want to help develop Dynamic languages on CLR?<http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
________________________________
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Simon Dahlbacka
Sent: Friday, May 19, 2006 9:20 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Dict iteration inconsistency?

They don't do the same thing..
fragment 1 iterates over a *copy* of the dictionarys keys, while fragment 2 iterates over the dictionary

On 5/19/06, J. de Hooge <info at geatec.com<mailto:info at geatec.com>> wrote:
LS

Following code fragments seem to behave inconsistently

[START OF CODE]

# --- Fragment 1
#
#       Accepted by CPython
#
#       Accepted by IronPython1.0 B6

dictionary = dict (zip (range (10), range (0, 100, 10)))

print dictionary

for key in dictionary.keys ():
        dictionary [key] = 100 * key

print dictionary

# --- Fragment 2: IronPython objects to the following, CPython thinks its OK
#
#       Accepted by CPython
#
#       Rejected by IronPython1.0 B6:
#               Traceback (most recent call last):
#               File C:\activ_dell\prog\qQuick\try\try.py, line 29, in
Initialize
#               RuntimeError: dictionary changed size during iteration

dictionary = dict (zip (range (10), range (0, 100, 10)))

print dictionary

for key in dictionary:
        dictionary [key] = 100 * key

print dictionary

# --- Shouldn't fragments 1 and 2 be both rejected or both accepted by
IronPython?

[END OF CODE]


Kind regards,
Jacques de Hooge
info at geatec.com<mailto:info at geatec.com>


_______________________________________________
users mailing list
users at lists.ironpython.com<mailto:users at lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060519/abcc1c4a/attachment.html>


More information about the Ironpython-users mailing list