Commit f6bd7de2 authored by Shane Hathaway's avatar Shane Hathaway

Fixed a segfault bug in the repr of extension class methods.

If self->meth is something other than a PyFunction,
for example an ExtensionClass Method object, the blind cast breaks.  The
new code uses the string "(?)" if self->meth is not a function.
parent e58e8b2f
......@@ -21,7 +21,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,\n"
" - They can be called to create instances.\n"
"\n"
"$Id: ExtensionClass.c,v 1.56 2002/06/18 23:19:02 jeremy Exp $\n"
"$Id: ExtensionClass.c,v 1.57 2002/08/22 16:55:53 shane Exp $\n"
;
#include <stdio.h>
......@@ -826,7 +826,15 @@ PMethod_repr(PMethod *self)
char *func_name, buf[8192];
int n;
func_name = PyString_AS_STRING(((PyFunctionObject*)self->meth)->func_name);
if (PyFunction_Check(self->meth)) {
func_name = PyString_AS_STRING(
((PyFunctionObject*)self->meth)->func_name);
}
else {
/* self->meth is some other kind of object */
func_name = "(?)";
}
if (self->self) {
PyObject *repr = PyObject_Repr(self->self);
if (!repr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment