Barry Warsaw avatar Barry Warsaw committed b1792a6

Backport patch 2.206:

----------------------------
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.

Comments (0)

Files changed (1)

Objects/typeobject.c

 
 	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);
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.