aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-29 09:38:01 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-30 13:04:12 +0100
commitf36f85d0a58b742b9fe0c947a3f402563de4e389 (patch)
tree2176ccc3c7382d48522a8e30db1103fe668845ca /sources
parentf391cd15394abf69581cc6cbe3663927f053342e (diff)
Fix errors calling deprecated functions with warning-as-error set
This causes the warning to be set as error, which causes problems in subsequent functions. Bail out immediately in that case. Fixes: PYSIDE-2136 Pick-to: 6.4 Change-Id: I409e8c7315d5952084e1a0d506cb1c26889e93d5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp9
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp5
2 files changed, 11 insertions, 3 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 47fb271f9..1b6c46f57 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -3370,12 +3370,15 @@ void CppGenerator::writeFunctionCalls(TextStream &s, const OverloadData &overloa
static void writeDeprecationWarning(TextStream &s,
const GeneratorContext &context,
- const AbstractMetaFunctionCPtr &func)
+ const AbstractMetaFunctionCPtr &func,
+ CppGenerator::ErrorReturn errorReturn)
{
s << "Shiboken::Warnings::warnDeprecated(\"";
if (auto *cls = context.metaClass())
s << cls->name() << "\", ";
- s << '"' << func->signature().replace(u"::"_s, u"."_s) << "\");\n";
+ // Check error in case "warning-as-error" is set.
+ s << '"' << func->signature().replace(u"::"_s, u"."_s) << "\");\n"
+ << "if (PyErr_Occurred())\n" << indent << errorReturn << outdent;
}
void CppGenerator::writeSingleFunctionCall(TextStream &s,
@@ -3385,7 +3388,7 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s,
ErrorReturn errorReturn) const
{
if (func->isDeprecated())
- writeDeprecationWarning(s, context, func);
+ writeDeprecationWarning(s, context, func, errorReturn);
if (func->functionType() == AbstractMetaFunction::EmptyFunction) {
s << "Shiboken::Errors::setPrivateMethod(\""
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index 4bac1c9a5..c5eae2fbb 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -11,10 +11,12 @@
#include "autodecref.h"
#include "sbkpython.h"
#include "signature.h"
+#include "helper.h"
#include <cstring>
#include <vector>
#include <sstream>
+#include <iostream>
#define SbkEnumType_Check(o) (Py_TYPE(Py_TYPE(o)) == SbkEnumType_TypeF())
using enum_func = PyObject *(*)(PyObject *, PyObject *);
@@ -878,6 +880,9 @@ EnumValueType getValue(PyObject *enumItem)
if (useOldEnum)
return reinterpret_cast<SbkEnumObject *>(enumItem)->ob_value;
+ std::cerr << __FUNCTION__ << ' ' << Shiboken::debugPyObject(enumItem)
+ << " err=" << Shiboken::debugPyObject(PyErr_Occurred()) << '\n';
+
AutoDecRef pyValue(PyObject_GetAttrString(enumItem, "value"));
return PyLong_AsLongLong(pyValue);
}