Skip to content

Commit

Permalink
PVS: V517 The use of 'if (A) {...} else if (A) {...}' pattern was det…
Browse files Browse the repository at this point in the history
…ected.
  • Loading branch information
wwmayer committed Mar 8, 2019
1 parent 67df9f3 commit 6363c90
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/App/PropertyStandard.cpp
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down

0 comments on commit 6363c90

Please sign in to comment.