Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3bf9bf0

Browse files
Fix compilation issue when compiled with pym feature
1 parent d80ccc8 commit 3bf9bf0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

‎src/err.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ impl std::convert::From<openssl::error::ErrorStack> for Error {
137137
// pyo3
138138
#[cfg(feature = "pym")]
139139
impl std::convert::From<pyo3::PyErr> for Error {
140-
fn from(_: pyo3::PyErr) -> Self {
141-
Error::ScriptError("Python script went Error".to_string())
140+
fn from(x: pyo3::PyErr) -> Self {
141+
// Error::ScriptError("Python script went Error".to_string())
142+
Error::ScriptError(x.to_string())
142143
}
143144
}

‎src/pym.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ pub fn exec(module: &str) -> Result<Vec<String>, crate::Error> {
1010
let script = load_script(&module)?;
1111
let cache = Cache::new()?;
1212

13+
pyo3::prepare_freethreaded_python();
1314
// pygil
14-
let gil = Python::acquire_gil();
15-
let py = gil.python();
16-
let pym = PyModule::from_code(py,&script,"plan.py","plan")?;
15+
Python::with_gil(|py| {
16+
let fun_plan = PyModule::from_code(py,&script,
17+
"plan_script.py","plan_script")?.getattr("plan")?;
1718

1819
// args
1920
let sps = serde_json::to_string(&cache.get_problems()?)?;
2021
let stags = serde_json::to_string(&cache.get_tags()?)?;
22+
let args = (sps, stags);
2123

2224
// ret
23-
let res: Vec<String> = pym.call1("plan", (sps, stags))?.extract()?;
25+
let res: Vec<String> = fun_plan.call1(args)?.extract()?;
26+
// let res: Vec<String> = pym.call1((sps, stags))?.extract()?;
2427

2528
Ok(res)
29+
})
2630
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /