Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clippy fixes
  • Loading branch information
arihant2math committed Apr 17, 2025
commit 94ba8949163053085d77c1554bc428858d8471c0
10 changes: 6 additions & 4 deletions capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub struct PyStatus {
pub exitcode: ffi::c_int,
}

#[allow(clippy::missing_safety_doc)]
/// # Safety
/// err_msg and func are null.
#[unsafe(export_name = "PyStatus_Ok")]
pub unsafe extern "C" fn status_ok() -> PyStatus {
PyStatus {
Expand All @@ -56,9 +57,10 @@ thread_local! {
}

#[unsafe(export_name = "Py_Initialize")]
pub unsafe extern "C" fn initialize() {
pub extern "C" fn initialize() {
// TODO: This sort of reimplemented what has already been done in the bin/lib crate, try reusing that.
let settings = vm::Settings::default();
#[allow(clippy::type_complexity)]
let init_hooks: Vec<Box<dyn FnOnce(&mut vm::VirtualMachine)>> = vec![];
let interp = vm::Interpreter::with_init(settings, |vm| {
for hook in init_hooks {
Expand All @@ -74,12 +76,12 @@ pub unsafe extern "C" fn initialize() {
}

#[unsafe(export_name = "Py_IsInitialized")]
pub unsafe extern "C" fn is_initialized() -> i32 {
pub extern "C" fn is_initialized() -> i32 {
VM.with(|vm_ref| vm_ref.borrow().is_some() as i32)
}

#[unsafe(export_name = "Py_Finalize")]
pub unsafe extern "C" fn finalize() {
pub extern "C" fn finalize() {
VM.with(|vm_ref| {
*vm_ref.borrow_mut() = None;
});
Expand Down