summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-11 16:25:43 (GMT)
committerGuido van Rossum <guido@python.org>2003-02-11 16:25:43 (GMT)
commit82ed25c15a8f79011161356cae5fffb49af8b24a (patch)
treed9be188a2d7766d1ab616ff3fdfbd5a303f88653 /Objects
parentada859c1112f306472995763e21beb357359be9f (diff)
downloadcpython-82ed25c15a8f79011161356cae5fffb49af8b24a.zip
cpython-82ed25c15a8f79011161356cae5fffb49af8b24a.tar.gz
cpython-82ed25c15a8f79011161356cae5fffb49af8b24a.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 31ac441..f37bb1b 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);
}