mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.3.x] fixed : exception registration for python 3
git-svn-id: https://pykd.svn.codeplex.com/svn@90966 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
0df2fba54f
commit
d6190121d3
@ -29,28 +29,28 @@ 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<TBaseExcept, python::detail::not_specified>::value)
|
if (boost::is_same<TBaseExcept, python::detail::not_specified>::value)
|
||||||
{
|
{
|
||||||
basedtype = python::handle<>(PyExc_Exception);
|
exceptPyType<TExcept>::pyExceptType =
|
||||||
|
python::handle<>(PyErr_NewExceptionWithDoc(
|
||||||
|
const_cast<char*>(fullName.c_str()),
|
||||||
|
const_cast<char*>(classDesc.c_str()),
|
||||||
|
NULL,
|
||||||
|
NULL));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
basedtype = exceptPyType<TBaseExcept>::pyExceptType;
|
exceptPyType<TExcept>::pyExceptType =
|
||||||
|
python::handle<>(PyErr_NewExceptionWithDoc(
|
||||||
|
const_cast<char*>(fullName.c_str()),
|
||||||
|
const_cast<char*>(classDesc.c_str()),
|
||||||
|
exceptPyType<TBaseExcept>::pyExceptType.get(),
|
||||||
|
NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
python::dict ob_dict;
|
python::scope().attr(className.c_str()) = exceptPyType<TExcept>::pyExceptType;
|
||||||
|
|
||||||
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<TExcept>::pyExceptType = python::handle<>( ob.ptr() );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user