summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Util.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2009-10-27 13:20:39 -0700
committerMark Spruiell <mes@zeroc.com>2009-10-27 13:20:39 -0700
commit370cfa6a7f7a3bb188dfb66bad09f3283a07aab8 (patch)
tree61b68c219c6c637f8621673d3b96bc8ad624c261 /py/modules/IcePy/Util.cpp
parentbug 4333 - fixing TestUtil issue (diff)
downloadice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.tar.bz2
ice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.tar.xz
ice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.zip
bug 4335 - Python segfault
Diffstat (limited to 'py/modules/IcePy/Util.cpp')
-rw-r--r--py/modules/IcePy/Util.cpp24
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)
{