From 1f8a32e3bc1100f84ae2cfdf1c992a9031ca38f5 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 1 Feb 2014 04:02:58 +0000 Subject: [PATCH] merged python binding fixes from RC_o_16 --- ChangeLog | 1 + bindings/python/src/error_code.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index e3a8fea9b..6b0d460aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * improve error_code and error_category support in python bindings * fix python binding for external_ip_alert 0.16.14 release diff --git a/bindings/python/src/error_code.cpp b/bindings/python/src/error_code.cpp index 987d92973..97d884613 100644 --- a/bindings/python/src/error_code.cpp +++ b/bindings/python/src/error_code.cpp @@ -32,17 +32,45 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include using namespace boost::python; using namespace libtorrent; +using boost::system::error_category; void bind_error_code() { + class_("error_category", no_init) + .def("name", &error_category::name) + .def("message", &error_category::message) + .def(self == self) + .def(self < self) + .def(self != self) + ; + class_("error_code") .def(init<>()) .def("message", &error_code::message) .def("value", &error_code::value) .def("clear", &error_code::clear) + .def("category", &error_code::category + , return_internal_reference<>()) + .def("assign", &error_code::assign) ; + + def("get_libtorrent_category", &get_libtorrent_category + , return_internal_reference<>()); + + def("get_http_category", &get_http_category + , return_internal_reference<>()); + + def("get_bdecode_category", &get_bdecode_category + , return_internal_reference<>()); + + def("generic_category", &boost::system::generic_category + , return_internal_reference<>()); + + def("system_category", &boost::system::system_category + , return_internal_reference<>()); }