[New-bugs-announce] [issue31218] del expects __delitem__ if __setitem__ is defined

Calvin report at bugs.python.org
Wed Aug 16 06:48:18 EDT 2017


New submission from Calvin:

I noticed some odd behaviour on classes defining __setitem__.
Using del on a class defining __setitem__ but not __delitem__ results in "AttributeError: __delitem__".
On classes definig neiter __setitem__ nor __delitem__ on the other hand this results in "TypeError: 'WithoutSetItem' object doesn't support item deletion".

See the appended example script.

----------
files: delitem_example.py
messages: 300346
nosy: raumzeitkeks
priority: normal
severity: normal
status: open
title: del expects __delitem__ if __setitem__ is defined
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file47085/delitem_example.py

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


More information about the New-bugs-announce mailing list