diff options
Diffstat (limited to 'sources/shiboken2/generator/shiboken2')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/overloaddata.cpp | 28 |
2 files changed, 11 insertions, 25 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 6572fca9a..b42ee2927 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -3257,7 +3257,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe { Indentation indent(INDENT); s << INDENT << "PyObject *value{};\n"; - s << INDENT << "PyObject *kwds_dup = PyDict_Copy(kwds);\n"; + s << INDENT << "Shiboken::AutoDecRef kwds_dup(PyDict_Copy(kwds));\n"; for (const AbstractMetaArgument *arg : args) { const int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex()); @@ -3302,7 +3302,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe s << INDENT << "if (PyDict_Size(kwds_dup) > 0) {\n"; { Indentation indent(INDENT); - s << INDENT << "errInfo = kwds_dup;\n"; + s << INDENT << "errInfo = kwds_dup.release();\n"; if (!(func->isConstructor() && func->ownerClass()->isQObject())) s << INDENT << "goto " << cpythonFunctionName(func) << "_TypeError;\n"; else @@ -5230,6 +5230,10 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn << ">(int(PyLong_AsLong(self)));\n"; s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName() << ">(int(PyLong_AsLong(" << PYTHON_ARG << ")));\n"; + // PYSIDE-1436: Need to error check self as well because operators are used + // sometimes with swapped args. + s << INDENT << "if (PyErr_Occurred())\n" << INDENT + << "return nullptr;\n"; s << "#else\n"; s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName() << ">(int(PyInt_AsLong(self)));\n"; diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 193384853..5edb65630 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -30,6 +30,7 @@ #include <reporthandler.h> #include <graph.h> #include "overloaddata.h" +#include "messages.h" #include "ctypenames.h" #include "indentor.h" #include "shibokengenerator.h" @@ -153,28 +154,6 @@ static QString getImplicitConversionTypeName(const AbstractMetaType *containerTy + types.join(QLatin1String(", ")) + QLatin1String(" >"); } -// overloaddata.cpp -static QString msgCyclicDependency(const QString &funcName, const QString &graphName, - const OverloadData::MetaFunctionList &involvedConversions) -{ - QString result; - QTextStream str(&result); - str << "Cyclic dependency found on overloaddata for \"" << funcName - << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName) - << "\"."; - if (const int count = involvedConversions.size()) { - str << " Implicit conversions (" << count << "): "; - for (int i = 0; i < count; ++i) { - if (i) - str << ", \""; - str << involvedConversions.at(i)->signature() << '"'; - if (const AbstractMetaClass *c = involvedConversions.at(i)->implementingClass()) - str << '(' << c->name() << ')'; - } - } - return result; -} - static inline int overloadNumber(const OverloadData *o) { return o->referenceFunction()->overloadNumber(); @@ -330,7 +309,10 @@ void OverloadData::sortNextOverloads() // Process inheritance relationships if (targetType->isValue() || targetType->isObject()) { - const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), targetType->typeEntry()); + auto *te = targetType->typeEntry(); + const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), te); + if (!metaClass) + qFatal("%s", qPrintable(msgArgumentClassNotFound(m_overloads.constFirst(), te))); const AbstractMetaClassList &ancestors = m_generator->getAllAncestors(metaClass); for (const AbstractMetaClass *ancestor : ancestors) { QString ancestorTypeName = ancestor->typeEntry()->name(); |