summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-02-23 13:58:03 +0100
committerChristian Tismer <tismer@stackless.com>2019-02-25 11:51:25 +0000
commit5ae663ff57efb4735ef1e69055ea68d904deb3b3 (patch)
treeb0276f3f925cef1e309ece41f8bf330d3a47659c
parent78b2438037504ae80eaf6b01d49df9ddb660656a (diff)
Allow Subclassing PyCFunction in Extension Modules
The signature module tries to figure out if it has to act upon functions by examining their type. It was too specific to check for PyCFunction, directly. A user had built a subclass of PyCFunction and used it with 'inspect.signature', which then revealed wrong behavior. This patch removes that restriction. Change-Id: I7e126ce5750ec5c308cbd1bd1bc4ca4d5eb51e17 Fixes: PYSIDE-950 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index d6c26ac7..61a09777 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -169,7 +169,7 @@ GetClassOfFunc(PyObject *ob)
{
if (PyType_Check(ob))
return ob;
- if (Py_TYPE(ob) == &PyCFunction_Type)
+ if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return _get_class_of_cf(ob);
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)
return _get_class_of_sm(ob);
@@ -703,7 +703,7 @@ get_signature(PyObject *self, PyObject *args)
if (Py_TYPE(ob) == PepFunction_TypePtr)
Py_RETURN_NONE;
- if (Py_TYPE(ob) == &PyCFunction_Type)
+ if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return pyside_cf_get___signature__(ob, modifier);
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)
return pyside_sm_get___signature__(ob, modifier);