New submission from Philip Jenvey:

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/test_weakref.py", 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

----------
components: Library (Lib)
messages: 215716
nosy: pitrou, pjenvey
priority: normal
severity: normal
status: open
title: WeakKeyDictionary.__len__ fragile w/ _IterationGuards
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21173>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to