Skip to content

Commit

Permalink
Merge pull request #1170 from alex/run-code-abi3
Browse files Browse the repository at this point in the history
Use limited APIs for Py::run_code
  • Loading branch information
kngwyu authored Sep 9, 2020
2 parents cc6d266 + 97dde18 commit 53e33aa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,11 @@ impl<'p> Python<'p> {
.unwrap_or_else(|| ffi::PyModule_GetDict(mptr));
let locals = locals.map(AsPyPointer::as_ptr).unwrap_or(globals);

let res_ptr = ffi::PyRun_StringFlags(
code.as_ptr(),
start,
globals,
locals,
::std::ptr::null_mut(),
);
let code_obj = ffi::Py_CompileString(code.as_ptr(), "<string>\0".as_ptr() as _, start);
if code_obj.is_null() {
return Err(PyErr::fetch(self));
}
let res_ptr = ffi::PyEval_EvalCode(code_obj, globals, locals);

self.from_owned_ptr_or_err(res_ptr)
}
Expand Down

0 comments on commit 53e33aa

Please sign in to comment.