From 82ed25c15a8f79011161356cae5fffb49af8b24a Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Feb 2003 16:25:43 +0000 Subject: [PATCH] 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. --- Objects/typeobject.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 31ac441a62..f37bb1b653 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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); } -- 2.40.0