This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pjenvey
Recipients pitrou, pjenvey
Date 2014-04-07.20:17:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
len() on WeakKeyDictionarys can fail with ValueErrors when _IterationGuards are kept alive

Attached is a test showing this:

ERROR: test_weak_keys_len_destroy_while_iterating (__main__.MappingTestCase)
Traceback (most recent call last):
  File "Lib/test/", line 1336, in test_weak_keys_len_destroy_while_iterating
    self.assertEqual(len(dict), 0)
ValueError: __len__() should return >= 0

One probably shouldn't keep them alive like this, but __len__ shouldn't be blowing up either. On non ref counting GC platforms this situation is easier to trigger unintentionally
Date User Action Args
2014-04-07 20:17:27pjenveysetrecipients: + pjenvey, pitrou
2014-04-07 20:17:27pjenveysetmessageid: <>
2014-04-07 20:17:27pjenveylinkissue21173 messages
2014-04-07 20:17:27pjenveycreate