mirror of
https://github.com/facebook/sapling.git
synced 2024-12-27 06:52:23 +03:00
cpython-ext: serialize Rust str into Python str type
Summary: Previously Rust str was serialized into bytes. To be Python 3 friendly, let's serialize it into `str`. Reviewed By: markbt Differential Revision: D19797706 fbshipit-source-id: 388eb044dc7e25cdc438f0c3d6fa5a5740f22e3d
This commit is contained in:
parent
3376363721
commit
ad8190713b
@ -160,7 +160,11 @@ impl<'a, 'b> ser::Serializer for &'a Serializer<'b> {
|
||||
}
|
||||
|
||||
fn serialize_str(self, v: &str) -> Result<PyObject> {
|
||||
self.serialize_bytes(v.as_bytes())
|
||||
if cfg!(feature = "python2") {
|
||||
Ok(PyBytes::new(self.py, v.as_bytes()).into_object())
|
||||
} else {
|
||||
Ok(PyUnicode::new(self.py, v).into_object())
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_bytes(self, v: &[u8]) -> Result<PyObject> {
|
||||
|
Loading…
Reference in New Issue
Block a user