diff options
Diffstat (limited to 'py/modules/IcePy/Util.cpp')
-rw-r--r-- | py/modules/IcePy/Util.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp index 08d294c660e..bc0101ad351 100644 --- a/py/modules/IcePy/Util.cpp +++ b/py/modules/IcePy/Util.cpp @@ -43,21 +43,27 @@ IcePy::getStringArg(PyObject* p, const string& arg, string& val) } else if(p != Py_None) { - // - // Get name of current function. - // - PyFrameObject *f = PyThreadState_GET()->frame; - PyObjectHandle code = PyObject_GetAttrString(reinterpret_cast<PyObject*>(f), STRCAST("f_code")); - assert(code.get()); - PyObjectHandle func = PyObject_GetAttrString(code.get(), STRCAST("co_name")); - assert(func.get()); - string funcName = getString(func.get()); + string funcName = getFunction(); PyErr_Format(PyExc_ValueError, STRCAST("%s expects a string for argument '%s'"), funcName.c_str(), arg.c_str()); return false; } return true; } +string +IcePy::getFunction() +{ + // + // Get name of current function. + // + PyFrameObject *f = PyThreadState_GET()->frame; + PyObjectHandle code = PyObject_GetAttrString(reinterpret_cast<PyObject*>(f), STRCAST("f_code")); + assert(code.get()); + PyObjectHandle func = PyObject_GetAttrString(code.get(), STRCAST("co_name")); + assert(func.get()); + return getString(func.get()); +} + IcePy::PyObjectHandle::PyObjectHandle(PyObject* p) : _p(p) { |