wangjun / sdict

Automatically exported from code.google.com/p/sdict
0 stars 0 forks source link

Iterating over the dictionary broken #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

>> d = sdict.Dict()
>>> for x in range(5): d[x] = x
... 
>>> for k in d: print k, d[k]
... 
0 0
1 1
2 2
3 3
4 4
None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/david/.virtualenvs/reddit/lib/python2.7/site-packages/sdict/__init__.py", line 75, in __getitem__
    return self.get(key)
  File "/Users/david/.virtualenvs/reddit/lib/python2.7/site-packages/sdict/__init__.py", line 26, in get
    raise Exception('invalid key: '+str(key))   
Exception: invalid key: None

What is the expected output? What do you see instead?

Iteration should stop after 5th key, instead seems to be stuck in infinite loop 
returning None.

What version of the product are you using? On what operating system?

Python 2.7.2, Mac OS X 10.7.3.

Original issue reported on code.google.com by davidwtb...@gmail.com on 15 Mar 2012 at 12:04

GoogleCodeExporter commented 9 years ago
I need to overwrite __iter__ method to fix this bug. thanks

Original comment by ccnu...@gmail.com on 15 Mar 2012 at 1:30

GoogleCodeExporter commented 9 years ago

Original comment by ccnu...@gmail.com on 15 Mar 2012 at 1:46

GoogleCodeExporter commented 9 years ago

Original comment by ccnu...@gmail.com on 15 Mar 2012 at 1:55

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by ccnu...@gmail.com on 15 Mar 2012 at 1:56