PyString::from_object may fail

This commit is contained in:
Nikolay Kim 2017-05-04 22:03:23 -07:00
parent a3823cec8e
commit e128fa8224
1 changed files with 2 additions and 2 deletions

View File

@ -231,9 +231,9 @@ impl PyString {
new_impl(py, s)
}
pub fn from_object(py: Python, src: &PyObject, encoding: &str, errors: &str) -> PyString {
pub fn from_object(py: Python, src: &PyObject, encoding: &str, errors: &str) -> PyResult<PyString> {
unsafe {
err::cast_from_owned_ptr_or_panic(
err::result_cast_from_owned_ptr(
py, ffi::PyUnicode_FromEncodedObject(
src.as_ptr(), encoding.as_ptr() as *const i8, errors.as_ptr() as *const i8))
}