diff options
author | Guido van Rossum <guido@python.org> | 2002-03-18 03:05:36 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-03-18 03:05:36 (GMT) |
commit | 09f2187704cdacc4e3f86b357d110445541e6ad7 (patch) | |
tree | ad782ffc9bfe9407df2fc1964345c37435f14036 /Objects | |
parent | 7eac98d6359533d762753f8bd730ed3c7c6e720a (diff) | |
download | cpython-09f2187704cdacc4e3f86b357d110445541e6ad7.zip cpython-09f2187704cdacc4e3f86b357d110445541e6ad7.tar.gz cpython-09f2187704cdacc4e3f86b357d110445541e6ad7.tar.bz2 |
Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault
The proper fix is not quite what was submitted; it's really better to
take the class of the object passed rather than calling PyMethod_New
with NULL pointer args, because that can then cause other core dumps
later.
I also added a testcase for the fix to classmethods() in test_descr.py.
I'll apply this to 2.3 too.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/funcobject.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c index f24cbcf..426b8f4 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -474,6 +474,8 @@ cm_descr_get(PyObject *self, PyObject *obj, PyObject *type) "uninitialized classmethod object"); return NULL; } + if (type == NULL) + type = (PyObject *)(obj->ob_type); return PyMethod_New(cm->cm_callable, type, (PyObject *)(type->ob_type)); } |