-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showcase of PyO3/pyo3#340 and PyO3/pyo3#341.
- Loading branch information
0 parents
commit e7f940b
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "pyo3bug" | ||
version = "0.1.0" | ||
authors = ["Manuel Vázquez Acosta <manuel@merchise.org>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
name = "pyo3bug" | ||
crate-type = ["cdylib"] | ||
|
||
|
||
[dependencies.pyo3] | ||
git = "https://github.com/PyO3/pyo3" | ||
features = ["extension-module", "python3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pymodule] | ||
fn pyo3bug(_py: Python, _m: &PyModule) -> PyResult<()> { | ||
Ok(()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use pyo3::types::{IntoPyDict, PyDateTime}; | ||
|
||
#[test] | ||
fn pydelta_conversion() { | ||
let gil = Python::acquire_gil(); | ||
let py = gil.python(); | ||
let datetime = py.import("datetime").unwrap(); | ||
let locals = [("datetime", datetime)].into_py_dict(py); | ||
let now: &PyDateTime = py | ||
.eval("datetime.datetime.utcnow()", None, Some(&locals)) | ||
.unwrap() | ||
.downcast() | ||
.unwrap(); | ||
println!("{:?}", now); | ||
} | ||
} |