Skip to content

BUG: function built with -F pyo3/abi3t raises TypeError at runtime (CPython 3.15.0b2-free-threaded)) #555

@neutrinoceros

Description

@neutrinoceros

Context: I'm trying out PEP 803 support in neutrinoceros/rlic#423.
I found that function bindings generated for cp315-abi3.abi3t produced a TypeError at runtime against Python 3.15.0b2 (free-threaded) + numpy 2.6.0dev0 (nightly cp315-cp315t wheel). Here's a minimal reproducer1

use pyo3::prelude::*;
use numpy::borrow::PyReadonlyArray2;

#[pymodule]
fn _core<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
    use pyo3::prelude::*;

    #[pyfunction]
    fn func<'py>(
        _py: Python<'py>,
        _array: PyReadonlyArray2<'py, f64>,
    ) -> i64 {
        0
    }
    m.add_function(wrap_pyfunction!(func, m)?)?;

    Ok(())
}
>>> import reprod
>>> import numpy as np
>>> reprod.func(np.eye(2, dtype="float64"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    reprod.func(np.eye(2, dtype="float64"))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'ndarray' object is not an instance of 'ndarray'

adjacent to #547

Footnotes

  1. minimal, but not self-contained. I can share a more fleshed out example if it helps. I just assumed the rest wasn't important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions