Merge pull request #1170 from alex/run-code-abi3

Use limited APIs for Py::run_code
This commit is contained in:
Yuji Kanagawa 2020-09-10 00:01:55 +09:00 committed by GitHub
commit 53e33aab3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -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)
}