From c6f6b4ef3318ab55b53384856b948d428a24f313 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Mon, 12 Aug 2019 18:12:20 +0200 Subject: Make signatures even more writable When implementing QtCore.Slot.__signature__, the following extension to writable signatures became useful: Signatures were corrected to be writable if they were not set by the signature module at all. But we should also allow assignment when the signature was set to None. This feature is only used for exploration; the correct way to implement a new signature is to integrate it into the normal generation process, as being done for QtCore.Slot.__signature__. Change-Id: I010e505a376993f27c46bd1c14e327e44d375abd Reviewed-by: Friedemann Kleint --- sources/shiboken2/libshiboken/signature.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sources/shiboken2/libshiboken/signature.cpp') diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index 2f080edad..2cade65e0 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -730,7 +730,9 @@ static int pyside_set___signature__(PyObject *op, PyObject *value) { // By this additional check, this function refuses write access. - if (get_signature_intern(op, nullptr)) { + // We consider both nullptr and Py_None as not been written. + Shiboken::AutoDecRef has_val(get_signature_intern(op, nullptr)); + if (!(has_val.isNull() || has_val == Py_None)) { PyErr_Format(PyExc_AttributeError, "Attribute '__signature__' of '%.50s' object is not writable", Py_TYPE(op)->tp_name); -- cgit v1.2.3