[IronPython] very strange dictionnary bug
Dino Viehland
dinov at exchange.microsoft.com
Fri Aug 18 17:13:08 CEST 2006
I haven't seen anything like this before... But I have a couple of questions: Are the keys always strings when it repros? And is the dictionary always created using the {} syntax?
I ask because we have a lot of different dictionary implementations, or there could be a bug where we have different instances of some basic object that are hashing differently for some reason (although given the code below, that seems strange).
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Stanislas Pinte
Sent: Friday, August 18, 2006 7:38 AM
To: Discussion of IronPython
Subject: Re: [IronPython] very strange dictionnary bug
By the way, the environment in which the bug shows up is single-threaded, so I do not suspect any concurrent access problem.
Stan.
Stanislas Pinte a écrit :
> Hello,
>
> We are just seeing a very strange bug in the following code:
>
> myDictionnary = {}
> .
> for key in myDictionnary.keys():
> assert myDictionnary.has_key(key) --> throw AssertionError
>
> this is fixed by the following change:
>
> for key, value in myDictionnary.iteritems():
> ...
>
> Ever seen this?
>
> Too bad I cannot reproduce this...a very simple test case like the one
> below doesn't do the trick...
>
> thanks,
>
> Stan.
>
> [sim-ironpython]> ironpython/ipy.exe
> IronPython 1.0.60816 on .NET 2.0.50727.42 Copyright (c) Microsoft
> Corporation. All rights reserved.
>>>> a = {"one": 1, "two": 2, "three": 3} a["one"]
> 1
>>>> a.pop("one")
> 1
>>>> a
> {'two': 2, 'three': 3}
>>>> a.keys()
> ['two', 'three']
>>>> for k in a.keys():
> . print k
> .
> two
> three
>
--
-----------------------------------------------------------------
Stanislas Pinte e-mail: stan at ertmssolutions.com
ERTMS Solutions http://www.ertmssolutions.com
Rue de l'Autonomie, 1 Tel: + 322 - 522.06.63
1070 Bruxelles Fax: + 322 - 522.09.30
-----------------------------------------------------------------
Skype (http://www.skype.com) id: stanpinte
-----------------------------------------------------------------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list