diff Objects/typeobject.c @ 24463:ebc8667f325a 2.2

Backport: SF patch 588728 (Nathan Srebro). The __delete__ method wrapper for descriptors was not supported (I added a test, too.)
author Guido van Rossum <guido@python.org>
date Thu, 01 Aug 2002 19:03:43 +0000
parents 15ee445af07f
children a7dbe4e7f5de
line wrap: on
line diff
--- a/Objects/typeobject.c	Wed Jul 31 11:19:49 2002 +0000
+++ b/Objects/typeobject.c	Thu Aug 01 19:03:43 2002 +0000
@@ -2720,6 +2720,22 @@
 	Py_INCREF(Py_None);
 	return Py_None;
 }
+  
+static PyObject *
+wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped)
+{
+	descrsetfunc func = (descrsetfunc)wrapped;
+	PyObject *obj;
+	int ret;
+
+	if (!PyArg_ParseTuple(args, "O", &obj))
+		return NULL;
+	ret = (*func)(self, obj, NULL);
+	if (ret < 0)
+		return NULL;
+	Py_INCREF(Py_None);
+	return Py_None;
+}
 
 static PyObject *
 tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
@@ -3775,6 +3791,8 @@
 	       "descr.__get__(obj[, type]) -> value"),
 	TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set,
 	       "descr.__set__(obj, value)"),
+	TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set,
+	       wrap_descr_delete, "descr.__delete__(obj)"),
 	FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init,
 	       "x.__init__(...) initializes x; "
 	       "see x.__class__.__doc__ for signature",