From 6363c90a20b296ab69d7b52230009928199d90df Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 8 Mar 2019 18:56:16 +0100 Subject: [PATCH] PVS: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. --- src/App/PropertyStandard.cpp | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 1ea44cead0a3..898c22c4b4f3 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -456,34 +456,7 @@ void PropertyEnumeration::setPyObject(PyObject *value) hasSetValue(); } } - else if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >= 3 - const char* str = PyUnicode_AsUTF8 (value); - if (_enum.contains(str)) { - aboutToSetValue(); - _enum.setValue(PyUnicode_AsUTF8 (value)); - hasSetValue(); - } - else { - std::stringstream out; - out << "'" << str << "' is not part of the enumeration"; - throw Base::ValueError(out.str()); - } -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - const char* str = PyString_AsString (unicode); - if (_enum.contains(str)) { - aboutToSetValue(); - _enum.setValue(PyString_AsString (unicode)); - hasSetValue(); - } - else { - std::stringstream out; - out << "'" << str << "' is not part of the enumeration"; - throw Base::ValueError(out.str()); - } - Py_DECREF(unicode); - } +#if PY_MAJOR_VERSION < 3 else if (PyString_Check(value)) { const char* str = PyString_AsString (value); if (_enum.contains(str)) { @@ -496,8 +469,8 @@ void PropertyEnumeration::setPyObject(PyObject *value) out << "'" << str << "' is not part of the enumeration"; throw Base::ValueError(out.str()); } -#endif } +#endif else if (PyUnicode_Check(value)) { #if PY_MAJOR_VERSION >=3 std::string str = PyUnicode_AsUTF8(value);