Skip to content

Commit

Permalink
+ fixes #1816: parseQuantity returns garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 4, 2014
1 parent d66fc09 commit 5c84e47
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Base/UnitsApiPy.cpp
Expand Up @@ -131,12 +131,12 @@ PyObject* UnitsApi::sParseQuantity(PyObject * /*self*/, PyObject *args,PyObject
if (!PyArg_ParseTuple(args, "et", "utf-8", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception

Quantity rtn;
QString qstr = QString::fromUtf8(pstr);
PyMem_Free(pstr);
Quantity rtn;
QString qstr = QString::fromUtf8(pstr);
PyMem_Free(pstr);
try {
rtn = Quantity::parse(QString::fromLatin1(pstr));
}
rtn = Quantity::parse(qstr);
}
catch (const Base::Exception&) {
PyErr_Format(PyExc_IOError, "invalid unit expression \n");
return 0L;
Expand All @@ -146,6 +146,5 @@ PyObject* UnitsApi::sParseQuantity(PyObject * /*self*/, PyObject *args,PyObject
return 0L;
}

return new QuantityPy(new Quantity(rtn));

return new QuantityPy(new Quantity(rtn));
}

0 comments on commit 5c84e47

Please sign in to comment.