This commit is contained in:
Philipp Moritz committed 2017-08-31 22:52:13 -07:00
1 parent 8e8e90114a
commit caf8516532
1 file changed
+5
+5
View File
@@ -325,10 +325,15 @@ Status CallCustomCallback(PyObject* context, PyObject* method_name, PyObject* el
std::stringstream ss;
ScopedRef repr(PyObject_Repr(elem));
RETURN_IF_PYERROR();
#if PY_MAJOR_VERSION >= 3
ScopedRef ascii(PyUnicode_AsASCIIString(repr.get()));
RETURN_IF_PYERROR();
ss << "error while calling callback on " << PyBytes_AsString(ascii.get())
<< ": handler not registered";
#else
ss << "error while calling callback on " << PyString_AsString(repr.get())
<< ": handler not registered";
#endif
return Status::SerializationError(ss.str());
} else {
*result = PyObject_CallMethodObjArgs(context, method_name, elem, NULL);