[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.16.8.68,2.16.8.69
Guido van Rossum
gvanrossum@users.sourceforge.net
Thu, 19 Jul 2001 09:22:15 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv6462
Modified Files:
Tag: descr-branch
typeobject.c
Log Message:
__delitem__ and __delslice__ were not treated properly at all. Now
they are. This affects slot_sq_ass_item(), slot_sq_ass_slice(),
slot_mp_ass_subscript(), and override_slots().
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.68
retrieving revision 2.16.8.69
diff -C2 -r2.16.8.68 -r2.16.8.69
*** typeobject.c 2001/07/19 12:43:19 2.16.8.68
--- typeobject.c 2001/07/19 16:22:13 2.16.8.69
***************
*** 1962,1967 ****
slot_sq_ass_item(PyObject *self, int index, PyObject *value)
{
! PyObject *res = PyObject_CallMethod(self, "__setitem__",
! "iO", index, value);
if (res == NULL)
return -1;
--- 1962,1972 ----
slot_sq_ass_item(PyObject *self, int index, PyObject *value)
{
! PyObject *res;
!
! if (value == NULL)
! res = PyObject_CallMethod(self, "__delitem__", "i", index);
! else
! res = PyObject_CallMethod(self, "__setitem__",
! "iO", index, value);
if (res == NULL)
return -1;
***************
*** 1973,1978 ****
slot_sq_ass_slice(PyObject *self, int i, int j, PyObject *value)
{
! PyObject *res = PyObject_CallMethod(self, "__setslice__",
! "iiO", i, j, value);
if (res == NULL)
return -1;
--- 1978,1988 ----
slot_sq_ass_slice(PyObject *self, int i, int j, PyObject *value)
{
! PyObject *res;
!
! if (value == NULL)
! res = PyObject_CallMethod(self, "__delslice__", "ii", i, j);
! else
! res = PyObject_CallMethod(self, "__setslice__",
! "iiO", i, j, value);
if (res == NULL)
return -1;
***************
*** 2004,2009 ****
slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
{
! PyObject *res = PyObject_CallMethod(self, "__setitem__",
! "OO", key, value);
if (res == NULL)
return -1;
--- 2014,2024 ----
slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
{
! PyObject *res;
!
! if (value == NULL)
! res = PyObject_CallMethod(self, "__delitem__", "O", key);
! else
! res = PyObject_CallMethod(self, "__setitem__",
! "OO", key, value);
if (res == NULL)
return -1;
***************
*** 2261,2265 ****
--- 2276,2282 ----
SQSLOT("__getslice__", sq_slice);
SQSLOT("__setitem__", sq_ass_item);
+ SQSLOT("__delitem__", sq_ass_item);
SQSLOT("__setslice__", sq_ass_slice);
+ SQSLOT("__delslice__", sq_ass_slice);
SQSLOT("__contains__", sq_contains);
SQSLOT("__iadd__", sq_inplace_concat);
***************
*** 2269,2272 ****
--- 2286,2290 ----
MPSLOT("__getitem__", mp_subscript);
MPSLOT("__setitem__", mp_ass_subscript);
+ MPSLOT("__delitem__", mp_ass_subscript);
NBSLOT("__add__", nb_add);