fix python2 related code

This commit is contained in:
Nikolay Kim 2017-07-19 13:22:26 -07:00
parent 13820f4ce3
commit 1035aaae49
1 changed files with 2 additions and 2 deletions

View File

@ -66,9 +66,9 @@ impl PyString {
/// even if the bytes are not valid UTF-8.
/// For unicode strings, returns the underlying representation used by Python.
pub fn data(&self) -> PyStringData {
if let Ok(bytes) = self.cast_as::<PyBytes>() {
if let Some(bytes) = self.cast_as::<PyBytes>() {
PyStringData::Utf8(bytes.data())
} else if let Ok(unicode) = self.cast_as::<PyUnicode>() {
} else if let Some(unicode) = self.cast_as::<PyUnicode>() {
unicode.data()
} else {
panic!("PyString is neither `str` nor `unicode`")