]> granicus.if.org Git - python/commitdiff
Add basic arg sanity checking to wrap_descr_get(). This is called
authorGuido van Rossum <guido@python.org>
Tue, 11 Feb 2003 16:25:43 +0000 (16:25 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Feb 2003 16:25:43 +0000 (16:25 +0000)
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.

Objects/typeobject.c

index 31ac441a6244a6508861869c9628450bda29673f..f37bb1b653106812e270a673c5b58e0fc39ba777 100644 (file)
@@ -3433,6 +3433,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);
 }