-
Notifications
You must be signed in to change notification settings - Fork 788
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
Unable to use PyTzInfo
#1662
Comments
Indeed; this is a similar problem to the changes being looked at in #1588. In particular, there's two related pain points:
For now you can work around this by using |
Humm, I've tried that but I'm getting
|
I've updated the above PR with your suggestion in case seeing the error in CI helps, but I have no idea how to go about fixing this. |
Unngh, sorry. How about The APIs on Rust <-> Python interface boundary need some love when even I'm getting them wrong 🤦♂️ |
Nope, I'm getting
|
What is working if it helps, is the following extremely ugly workaround: let locals = PyDict::new(py);
locals.set_item("datetime", py.import("datetime")?)?;
locals.set_item("seconds", offset_seconds.to_object(py))?;
let code = "datetime.timezone(datetime.timedelta(seconds=seconds))";
let tz_info = py.eval(code, None, Some(&locals))?; Then But obviously a solution without dropping back to python would be good (not yet sure how slow the above is). |
Ok, last try: ... I think that at least one of the other methods not working is a design flaw. Sorry that you've had to suffer this. |
Okay, that works, thanks so much. (at least it wasn't me missing something obvious) |
#1588 changed |
Question / Clarification
🌍 Environment
Ubuntu 21.04
3.9.5
system
rustc --version
):rustc 1.52.1 (9bc8c42bb 2021-05-09)
0.13.2
version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
: noDetails
As described at #884 (comment) and in tests here, I assumed should be able to "subclass"
PyTzInfo
and use it inPyDateTime::new
, but I'm gettingWhat am I doing wrong?
partial code:
Full example of my (very naive) attempt at solving this: samuelcolvin/rtoml#25
The text was updated successfully, but these errors were encountered: