Issue 9733: Can't iterate over multiprocessing.managers.DictProxy (original) (raw)

I expected I could iterate over a DictProxy as I do over a regular dict.

from multiprocessing import Manager m = Manager() d = m.dict() d <DictProxy object, typeid 'dict' at 0x98a240c> for x in d: ... print x ... Traceback (most recent call last): File "", line 1, in File "", line 2, in getitem File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in _callmethod raise convert_to_error(kind, result) KeyError: 0 d['a'] = 1 for x in d: ... print x ... Traceback (most recent call last): File "", line 1, in File "", line 2, in getitem File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in _callmethod raise convert_to_error(kind, result) KeyError: 0

I expected I could iterate over a DictProxy as I do over a regular dict.

DictProxy doesn't support iterkeys(), itervalues(), or iteritems() either. So while

iter(d)

could do iter(d.keys())

behind the scenes, it would mask the fact that this would not return an iterator over the keys, but send a potentially long list of keys back to the client.