From e128fa82249ef8f31233689af6c02c5751bf0eaa Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 4 May 2017 22:03:23 -0700 Subject: [PATCH] PyString::from_object may fail --- src/objects/string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objects/string.rs b/src/objects/string.rs index c73f3eaa..59b9e7c5 100644 --- a/src/objects/string.rs +++ b/src/objects/string.rs @@ -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 { 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)) }