[Python-bugs-list] [ python-Bugs-442791 ] 2.2a1: New style classes and __delitem__
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 01 Aug 2001 15:39:44 -0700
Bugs item #442791, was opened at 2001-07-19 08:44
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442791&group_id=5470
Category: type/class unification
Group: Python 2.2
>Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Guido van Rossum (gvanrossum)
Summary: 2.2a1: New style classes and __delitem__
Initial Comment:
And another one: New style class don't seem to support
__delitem__:
----
class Foo(object):
def __delitem__(self, key):
print "__delitem__"
del Foo()[42]
----
This results in:
Traceback (most recent call last):
File "test.py", line 5, in ?
del Foo()[42]
TypeError: object doesn't support item deletion
----
Changing the base class to dictionary results in:
----
Traceback (most recent call last):
File "test.py", line 5, in ?
del Foo()[42]
KeyError: 42
----
but Foo.__delitem__ doesn't seem to be called.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-01 15:39
Message:
Logged In: YES
user_id=6380
Reopened. I'll investigate.
----------------------------------------------------------------------
Comment By: Walter Dörwald (doerwalter)
Date: 2001-08-01 11:34
Message:
Logged In: YES
user_id=89016
I checked out the descr-branch and it seems that dictionary
still doesn't support __delitem__:
>>> x = {}
>>> dictionary.__setitem__(x, 1, 1)
>>> x
{1: 1}
>>> dictionary.__delitem__(x, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: type object 'dictionary' has no
attribute '__delitem__'
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 09:36
Message:
Logged In: YES
user_id=6380
Whoops, you found a whole slew of bugs in this area!
I've fixed this now in the descr-branch of the CVS tree, in
Object/typeobject.c:2.16.8.69.
I've also added a bit to the test suite that checks these
(and slices).
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442791&group_id=5470