PVS: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected.

This commit is contained in:
wmayer
2019-03-08 18:56:16 +01:00
parent 767e951dda
commit 9bdd92989e

View File

@@ -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);