aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-11-06 14:53:53 +0100
committerChristian Tismer <tismer@stackless.com>2020-11-11 16:43:38 +0000
commit381ae9c30149fe7cfffdf79cfd7f1d12449474b6 (patch)
treedac3814a1490dd46f5a5d8a81d5fecfa89204ecc
parent6beb602f897669796700e6a230bc8503bd495e8f (diff)
shiboken: Ensure that `seterror_argument` always gets a function arg
The call to the internal function `seterror_argument` is generated by cppgenerator for all generated classes. The constructor is special cased, so that for `SomeClass.__init__` only `SomeClass` is generated. For error handling, we should always see the failed function name, regardless of any convention. This has become a real problem with the new error handler written in C that can not easily deduce if a function or class is passed. Task-number: PYSIDE-1019 Change-Id: I073f8e866c6bbce5dd842ef4be5d6c6c5421db0f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp2
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.cpp10
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.h2
3 files changed, 9 insertions, 5 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index c06f072d1..e41ae5b80 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -2301,7 +2301,7 @@ void CppGenerator::writeErrorSection(QTextStream &s, OverloadData &overloadData)
const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
s << Qt::endl << INDENT << cpythonFunctionName(rfunc) << "_TypeError:\n";
Indentation indentation(INDENT);
- QString funcName = fullPythonFunctionName(rfunc);
+ QString funcName = fullPythonFunctionName(rfunc, true);
QString argsVar = pythonFunctionWrapperUsesListOfArguments(overloadData)
? QLatin1String("args") : QLatin1String(PYTHON_ARG);
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
index 09c9cc501..328ca3a08 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
@@ -363,7 +363,7 @@ QString ShibokenGenerator::fullPythonClassName(const AbstractMetaClass *metaClas
return fullClassName;
}
-QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *func)
+QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *func, bool forceFunc)
{
QString funcName;
if (func->isOperatorOverload())
@@ -372,10 +372,14 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *fu
funcName = func->name();
if (func->ownerClass()) {
QString fullClassName = fullPythonClassName(func->ownerClass());
- if (func->isConstructor())
+ if (func->isConstructor()) {
funcName = fullClassName;
- else
+ if (forceFunc)
+ funcName.append(QLatin1String(".__init__"));
+ }
+ else {
funcName.prepend(fullClassName + QLatin1Char('.'));
+ }
}
else {
funcName = packageName() + QLatin1Char('.') + func->name();
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h
index d2aaa5b1a..0fc872848 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.h
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h
@@ -235,7 +235,7 @@ protected:
QString wrapperName(const AbstractMetaClass *metaClass) const;
QString fullPythonClassName(const AbstractMetaClass *metaClass);
- QString fullPythonFunctionName(const AbstractMetaFunction *func);
+ QString fullPythonFunctionName(const AbstractMetaFunction *func, bool forceFunc=false);
bool wrapperDiagnostics() const { return m_wrapperDiagnostics; }