Skip to content

Migrate from deprecated gil-refs API to Bound API #10

@xuan-w

Description

@xuan-w

Background

PyO3's gil-refs feature (used via &PyModule in lib.rs) is deprecated as of PyO3 0.21 and was removed in PyO3 0.23+. We currently pin to PyO3 0.22 which still supports gil-refs but emits deprecation warnings during compilation.

What needs to change

In src/lib.rs, the module function signature uses the old GIL-ref pattern:

#[pymodule]
fn schematodes(_py: Python, m: &PyModule) -> PyResult<()> {

This needs to be migrated to the Bound API:

#[pymodule]
fn schematodes(m: &Bound<'_, PyModule>) -> PyResult<()> {

The wrap_pyfunction! and m.add_class calls may also need minor updates.

Why

  • Allows upgrading to PyO3 0.23+ (latest is 0.28+)
  • Removes deprecation warnings during build
  • Keeps schematodes compatible with future Rust/PyO3 ecosystem

Deprecation warnings from current build

warning: use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument
warning: use of deprecated constant: this function has implicit defaults for the trailing `Option<T>` arguments

References

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