]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport patch 2.206:
authorBarry Warsaw <barry@python.org>
Thu, 29 May 2003 15:13:18 +0000 (15:13 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 29 May 2003 15:13:18 +0000 (15:13 +0000)
    ----------------------------
    revision 2.206
    date: 2003/02/11 16:25:43;  author: gvanrossum;  state: Exp;  lines: +9 -0
    Add basic arg sanity checking to wrap_descr_get().  This is called
    when Python code calls a descriptor's __get__ method.  It should
    translate None to NULL in both argument positions, and insist that at
    least one of the argument positions is not NULL after this
    transformation.
    ----------------------------

which fixes SF bug # 736892, forcing function to act like an unbound
method dumps core.

Objects/typeobject.c

index a150f5d5e499b593a3fa591916357440a6596254..45c95793c14ee7c99237e7e7485d7458232ea510 100644 (file)
@@ -2749,6 +2749,15 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
 
        if (!PyArg_ParseTuple(args, "O|O", &obj, &type))
                return NULL;
+       if (obj == Py_None)
+               obj = NULL;
+       if (type == Py_None)
+               type = NULL;
+       if (type == NULL &&obj == NULL) {
+               PyErr_SetString(PyExc_TypeError,
+                               "__get__(None, None) is invalid");
+               return NULL;
+       }
        return (*func)(self, obj, type);
 }