Bug Description
I'm getting error[E0425]: cannot find type `c_int` in this scope while trying to compile pyo3-ffi with Python 3.11.
This is for pyo3-ffi 0.26.0, but I can see that in the latest main the c_int declaration is still gated behind cfg(Py_3_12):
|
#[cfg(Py_3_12)] |
|
use std::ffi::c_int; |
and still used ungated in the declaration of _Py_NegativeRefcount:
|
#[cfg(all(py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] |
|
fn _Py_NegativeRefcount(filename: *const c_char, lineno: c_int, op: *mut PyObject); |
Full build logs: https://gist.github.com/fofoni/af1ff66279a1c5e1c41a396979f28e89
If I manually change #[cfg(Py_3_12)] to #[cfg(Py_3_11)] in $CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.26.0/src/refcount.rs, the build finishes successfully.
Steps to Reproduce
I can reproduce this while trying to build pydantic-core. This was reported here: pydantic/pydantic#12866
Backtrace
error[E0425]: cannot find type `c_int` in this scope
--> /home/pedro/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.26.0/src/refcount.rs:150:62
|
150 | fn _Py_NegativeRefcount(filename: *const c_char, lineno: c_int, op: *mut PyObject);
| ^^^^^ not found in this scope
|
note: found an item that was configured out
--> /home/pedro/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.26.0/src/refcount.rs:6:15
|
5 | #[cfg(Py_3_12)]
| ------- the item is gated here
6 | use std::ffi::c_int;
| ^^^^^
help: consider importing one of these type aliases
|
1 + use std::ffi::c_int;
|
1 + use std::os::raw::c_int;
|
1 + use core::ffi::c_int;
|
1 + use libc::c_int;
|
Your operating system and version
Ubuntu 24.04.2 LTS
Your Python version (python --version)
Python 3.11.14 (tags/v3.11.14:cd1c3a63428, Feb 26 2026, 08:30:42) [GCC 13.3.0] on linux (Debug build, from source)
Your Rust version (rustc --version)
rustc 1.93.1 (01f6ddf75 2026-02-11)
Your PyO3 version
pyo3-ffi 0.26.0
How did you install python? Did you use a virtualenv?
Build from source: ./configure --with-pydebug, and using -O0.
Bug Description
I'm getting
error[E0425]: cannot find type `c_int` in this scopewhile trying to compile pyo3-ffi with Python 3.11.This is for pyo3-ffi 0.26.0, but I can see that in the latest main the
c_intdeclaration is still gated behindcfg(Py_3_12):pyo3/pyo3-ffi/src/refcount.rs
Lines 5 to 6 in 86c48d3
and still used ungated in the declaration of
_Py_NegativeRefcount:pyo3/pyo3-ffi/src/refcount.rs
Lines 151 to 152 in 86c48d3
Full build logs: https://gist.github.com/fofoni/af1ff66279a1c5e1c41a396979f28e89
If I manually change
#[cfg(Py_3_12)]to#[cfg(Py_3_11)]in$CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.26.0/src/refcount.rs, the build finishes successfully.Steps to Reproduce
I can reproduce this while trying to build pydantic-core. This was reported here: pydantic/pydantic#12866
Backtrace
Your operating system and version
Ubuntu 24.04.2 LTS
Your Python version (
python --version)Python 3.11.14 (tags/v3.11.14:cd1c3a63428, Feb 26 2026, 08:30:42) [GCC 13.3.0] on linux (Debug build, from source)
Your Rust version (
rustc --version)rustc 1.93.1 (01f6ddf75 2026-02-11)
Your PyO3 version
pyo3-ffi 0.26.0
How did you install python? Did you use a virtualenv?
Build from source:
./configure --with-pydebug, and using-O0.