Skip to content

Return value of Python::version should be &'static str? #5908

@bschoenmaeckers

Description

@bschoenmaeckers

Since this value is not protected by the GIL on the free-threaded build, it does not make sense that it is linked to the GIL lifetime.

This makes me wonder if it could be prone to race conditions.

pyo3/src/marker.rs

Lines 695 to 701 in 68b719f

pub fn version(self) -> &'py str {
unsafe {
CStr::from_ptr(ffi::Py_GetVersion())
.to_str()
.expect("Python version string not UTF-8")
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions