From d6190121d34449d9908b5ccd42328116bdcf7174 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 22 Mar 2016 07:37:13 +0000 Subject: [PATCH] [0.3.x] fixed : exception registration for python 3 git-svn-id: https://pykd.svn.codeplex.com/svn@90966 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgexcept.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pykd/dbgexcept.h b/pykd/dbgexcept.h index 3200b98..66bd439 100644 --- a/pykd/dbgexcept.h +++ b/pykd/dbgexcept.h @@ -26,31 +26,31 @@ template< class TExcept, class TBaseExcept = python::detail::not_specified > class exception { public: - - exception( const std::string& className, const std::string& classDesc ) + + exception(const std::string& className, const std::string& classDesc) { - python::handle<> basedtype; + std::string fullName = "pykd." + className; - if ( boost::is_same::value ) + if (boost::is_same::value) { - basedtype = python::handle<>(PyExc_Exception); + exceptPyType::pyExceptType = + python::handle<>(PyErr_NewExceptionWithDoc( + const_cast(fullName.c_str()), + const_cast(classDesc.c_str()), + NULL, + NULL)); } else { - basedtype = exceptPyType::pyExceptType; + exceptPyType::pyExceptType = + python::handle<>(PyErr_NewExceptionWithDoc( + const_cast(fullName.c_str()), + const_cast(classDesc.c_str()), + exceptPyType::pyExceptType.get(), + NULL)); } - python::dict ob_dict; - - ob_dict["__doc__"] = classDesc; - - python::tuple ob_bases = python::make_tuple( basedtype ); - - python::object ob = python::object( python::handle<>(Py_TYPE(basedtype.get()) ) )( className, ob_bases, ob_dict ); - - python::scope().attr( className.c_str() ) = ob; - - exceptPyType::pyExceptType = python::handle<>( ob.ptr() ); + python::scope().attr(className.c_str()) = exceptPyType::pyExceptType; } };