[New-bugs-announce] [issue14159] __len__ method of weakset

Yury Selivanov report at bugs.python.org
Wed Feb 29 15:55:23 CET 2012


New submission from Yury Selivanov <yselivanov at gmail.com>:

WeakSet has a bug in its '__len__' method, where it performs iteration though 'self.data' without ensuring _IterationGuard.

This leads to some hard to catch errors with the following traceback:


  builtins.RuntimeError: Set changed size during iteration

    File /usr/lib64/python3.2/_weakrefset.py, line 66, in __len__
        return sum(x() is not None for x in self.data)
    File /usr/lib64/python3.2/_weakrefset.py, line 66, in <genexpr>
        return sum(x() is not None for x in self.data)

----------
components: Library (Lib)
files: weakset_len.patch
keywords: patch
messages: 154636
nosy: Yury.Selivanov, pitrou, rhettinger
priority: normal
severity: normal
status: open
title: __len__ method of weakset
type: crash
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24681/weakset_len.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14159>
_______________________________________


More information about the New-bugs-announce mailing list