Merge pull request #621 from arvidn/py-converter

fix python binding for python 3
This commit is contained in:
Arvid Norberg 2016-04-15 22:26:32 -04:00
commit 5801aea5b4
1 changed files with 6 additions and 5 deletions

View File

@ -35,10 +35,12 @@ struct tuple_to_endpoint
{
if (!PyTuple_Check(x)) return NULL;
if (PyTuple_Size(x) != 2) return NULL;
if (!PyString_Check(PyTuple_GetItem(x, 0))) return NULL;
if (!PyNumber_Check(PyTuple_GetItem(x, 1))) return NULL;
extract<std::string> ip(object(borrowed(PyTuple_GetItem(x, 0))));
if (!ip.check()) return NULL;
extract<int> port(object(borrowed(PyTuple_GetItem(x, 1))));
if (!port.check()) return NULL;
lt::error_code ec;
lt::address::from_string(PyString_AsString(PyTuple_GetItem(x, 0)), ec);
lt::address::from_string(ip, ec);
if (ec) return NULL;
return x;
}
@ -50,8 +52,7 @@ struct tuple_to_endpoint
object o(borrowed(x));
new (storage) T(lt::address::from_string(
extract<std::string>(o[0]))
, extract<int>(o[1]));
extract<std::string>(o[0])), extract<int>(o[1]));
data->convertible = storage;
}
};