Skip to content

[BUG] Unused function warnings using py_safe_call_object_once #7560

@ngoldbaum

Description

@ngoldbaum

Describe the bug

When I try to build a branch of SciPy where I fix a thread-safety issue with py_safe_call_object_once, I get some compiler warnings about unused functions:

scipy/spatial/_ckdtree.cpython-314t-darwin.so.p/_ckdtree.cpp:3714:29: warning: function '__pyx_libcpp_mutex_limited_api_ensure_gil' is not needed and will not be emitted [-Wunneeded-internal-declaration]
 3714 |     static PyGILState_STATE __pyx_libcpp_mutex_limited_api_ensure_gil() {
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scipy/spatial/_ckdtree.cpython-314t-darwin.so.p/_ckdtree.cpp:3732:16: warning: function '__pyx_libcpp_mutex_has_gil' is not needed and will not be emitted [-Wunneeded-internal-declaration]
 3732 |     static int __pyx_libcpp_mutex_has_gil() {
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
scipy/spatial/_ckdtree.cpython-314t-darwin.so.p/_ckdtree.cpp:3852:17: warning: unused function '__pyx_libcpp_mutex_unlock' [-Wunused-function]
 3852 |     inline void __pyx_libcpp_mutex_unlock() {} // no-op
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings generated.

Code to reproduce the behaviour:

Sorry, I don't have a small runnable example. I suspect all that's needed is cimporting and calling py_safe_call_object_once.

Expected behaviour

No compiler warnings.

OS

MacOS

Python version

3.14.3t

Cython version

3.2.4

Additional context

No response

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