-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgrade to pyo3 0.21.2 #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me.
Generally these days I prefer change fn foo(py: Python, obj: Bound<...>) {
to fn foo(obj: Bound<...>) { let py = obj.py(); ...
But that's not a deal breaker by any stretch of the imagination.
src/datetime.rs
Outdated
let py_dt: PyObject = match &datetime.date { | ||
Some(date) => match &datetime.time { | ||
Some(t) => { | ||
let py_tz: PyObject; | ||
let tzinfo = match &datetime.offset { | ||
let tzinfo: Option<Bound<'_, PyTzInfo>> = match &datetime.offset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistically I might have been tempted to do this with match (&datetime.date, &datetime.time, &datetime.offset)
src/datetime.rs
Outdated
Some(offset) => { | ||
let tz_info = match offset { | ||
TomlOffset::Z => TzInfo::new(0, 0), | ||
TomlOffset::Custom { hours, minutes } => TzInfo::new(*hours, *minutes), | ||
}; | ||
py_tz = Py::new(py, tz_info)?.to_object(py); | ||
Some(py_tz.extract(py)?) | ||
Some(Bound::new(py, tz_info)?.into_any().downcast_into()?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is one of the more painful part of the current design, I will probably add .cast_into()
as a future replacement for .into_any().downcast_into()
. PyO3/pyo3#3988 (comment)
@@ -9,30 +9,40 @@ use toml::value::Datetime; | |||
use crate::py_type::PyTypeLookup; | |||
|
|||
pub struct SerializePyObject<'py> { | |||
obj: &'py PyAny, | |||
py: Python<'py>, | |||
obj: Bound<'py, PyAny>, | |||
none_value: Option<&'py str>, | |||
ob_type_lookup: &'py PyTypeLookup, | |||
} | |||
|
|||
impl<'py> SerializePyObject<'py> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be that you can rely on toml::value::Value
implementing Deserialize
and use pythonize::depythonize
here. Not sure if you need some special logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need custom logic.
@davidhewitt, a quick review would be much appreciated.