[IronPython] Dict iteration inconsistency?

J. de Hooge info at geatec.com
Fri May 19 17:39:17 CEST 2006


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





More information about the Ironpython-users mailing list