diff options
author | Guido van Rossum <guido@python.org> | 2001-04-13 15:42:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-04-13 15:42:40 (GMT) |
commit | d9994e0115e1acfd6d3d97a048af9616778af95c (patch) | |
tree | 647dde43a572bbd84ec2e41eb60a4e352963b85c /Python/ceval.c | |
parent | d03f8fe95e6581062463694c4330b8b4024ab545 (diff) | |
download | cpython-d9994e0115e1acfd6d3d97a048af9616778af95c.zip cpython-d9994e0115e1acfd6d3d97a048af9616778af95c.tar.gz cpython-d9994e0115e1acfd6d3d97a048af9616778af95c.tar.bz2 |
Patch by Ping (SF bug 415879, Exception.__init__() causes segfault):
Calling an unbound method on a C extension class without providing
an instance can yield a segfault. Try "Exception.__init__()" or
"ValueError.__init__()".
This is a simple fix. The error-reporting bits in call_method
mistakenly treat the misleadingly-named variable "func" as a
function, when in fact it is a method.
If we let get_func_name take care of the work, all is fine.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 10b5c5d..a1b3bc2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2883,12 +2883,11 @@ call_method(PyObject *func, PyObject *arg, PyObject *kw) return NULL; } if (!ok) { - PyObject* fn = ((PyFunctionObject*) func)->func_name; + char* fn = get_func_name(func); PyErr_Format(PyExc_TypeError, "unbound method %s%smust be " "called with instance as first argument", - fn ? PyString_AsString(fn) : "", - fn ? "() " : ""); + fn ? fn : "", fn ? "() " : ""); return NULL; } Py_INCREF(arg); |