diff options
| -rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 11 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/sbkenum.cpp | 10 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/sbkenum_p.h | 1 |
3 files changed, 8 insertions, 14 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 7d1a3aa96..c0dacb372 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -5785,9 +5785,14 @@ void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum break; } } - s << "// PYSIDE-1735: Resolving the whole enum class at the end for API compatibility.\n" - << "EType = morphLastEnumToPython();\n" - << enumVarTypeObj << " = EType;\n"; + if (cppEnum.enumKind() != AnonymousEnum) { + s << "// PYSIDE-1735: Resolving the whole enum class at the end for API compatibility.\n" + << "EType = morphLastEnumToPython();\n" + << enumVarTypeObj << " = EType;\n"; + } else { + s << "// PYSIDE-1735: Skip an Anonymous enum class for Python coercion.\n" + << enumVarTypeObj << " = EType;\n"; + } if (cppEnum.typeEntry()->flags()) { s << "// PYSIDE-1735: Mapping the flags class to the same enum class.\n" << cpythonTypeNameExt(cppEnum.typeEntry()->flags()) << " =\n" diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp index 8f3548ca5..485cf24df 100644 --- a/sources/shiboken6/libshiboken/sbkenum.cpp +++ b/sources/shiboken6/libshiboken/sbkenum.cpp @@ -1026,13 +1026,6 @@ PyTypeObject *morphLastEnumToPython() auto *enumType = lec.enumType; // This is temporary; SbkEnumType will be removed, soon. - auto *setp = PepType_SETP(reinterpret_cast<SbkEnumType *>(enumType)); - if (setp->replacementType) { - // For some (yet to fix) reason, initialization of the enums can happen twice. - // If that happens, use the existing new type to keep type checks correct. - return setp->replacementType; - } - auto *scopeOrModule = lec.scopeOrModule; static PyObject *enumName = String::createStaticString("IntEnum"); if (PyType_Check(scopeOrModule)) { @@ -1118,9 +1111,6 @@ PyTypeObject *morphLastEnumToPython() } } - // Protect against double initialization - setp->replacementType = newType; - // PYSIDE-1735: Old Python versions can't stand the early enum deallocation. static bool old_python_version = is_old_version(); if (old_python_version) diff --git a/sources/shiboken6/libshiboken/sbkenum_p.h b/sources/shiboken6/libshiboken/sbkenum_p.h index 705aa4d9d..3e3640b93 100644 --- a/sources/shiboken6/libshiboken/sbkenum_p.h +++ b/sources/shiboken6/libshiboken/sbkenum_p.h @@ -11,7 +11,6 @@ struct SbkEnumTypePrivate { SbkConverter *converter; const char *cppName; - PyTypeObject *replacementType; }; extern "C" { |
