diff options
author | Kefu Chai <kchai@redhat.com> | 2017-04-21 06:50:18 +0200 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2017-04-21 08:39:44 +0200 |
commit | cef433eccb012d05fb1bd4d04478c61d6c9c02e0 (patch) | |
tree | 30da6376317cbee946ddbcb5ff57c7805d67c35f /src/mgr/PyModules.cc | |
parent | mgr/MgrPyModule::handle_command: order stringstreams to match intent (diff) | |
download | ceph-cef433eccb012d05fb1bd4d04478c61d6c9c02e0.tar.xz ceph-cef433eccb012d05fb1bd4d04478c61d6c9c02e0.zip |
mgr: move handle_pyerror() from MgrPyModules to MgrPyModule
so we can reuse it in a more sane way.
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | src/mgr/PyModules.cc | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 247e6b3fcd3..0926757844a 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -286,31 +286,6 @@ PyObject *PyModules::get_python(const std::string &what) } } -//XXX courtesy of http://stackoverflow.com/questions/1418015/how-to-get-python-exception-text -#include <boost/python.hpp> -// decode a Python exception into a string -std::string handle_pyerror() -{ - using namespace boost::python; - using namespace boost; - - PyObject *exc,*val,*tb; - object formatted_list, formatted; - PyErr_Fetch(&exc,&val,&tb); - handle<> hexc(exc),hval(allow_null(val)),htb(allow_null(tb)); - object traceback(import("traceback")); - if (!tb) { - object format_exception_only(traceback.attr("format_exception_only")); - formatted_list = format_exception_only(hexc,hval); - } else { - object format_exception(traceback.attr("format_exception")); - formatted_list = format_exception(hexc,hval,htb); - } - formatted = str("").join(formatted_list); - return extract<std::string>(formatted); -} - - std::string PyModules::get_site_packages() { std::stringstream site_packages; |