8000 [BUG] Py_TYPE and Py_REFCNT are used in limited api (3.11) · Issue #6853 · cython/cython · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[BUG] Py_TYPE and Py_REFCNT are used in limited api (3.11) #6853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
benoit9126 opened this issue May 9, 2025 · 3 comments
Closed

[BUG] Py_TYPE and Py_REFCNT are used in limited api (3.11) #6853

< 8000 a class="author text-bold Link--secondary" data-hovercard-z-index-override="111" data-hovercard-type="user" data-hovercard-url="/users/benoit9126/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/benoit9126">benoit9126 opened this issue May 9, 2025 · 3 comments

Comments

@benoit9126
Copy link
benoit9126 commented May 9, 2025

Describe the bug

I am trying to compile a wheel using the limited API feature of Cython 3.1 and when I use abi3audit to check the built wheel, some symbols should have not been used. I am building the wheel for Python 3.11 stable ABI and abi3audit has found symbols that will be in the stable API for version 3.14 of Python.

Code to reproduce the behaviour:

With this code, only Py_TYPE appears in the built wheel. In my use case, Py_REFCNT also appears.

cpdef int test(int a, int b):
    return a + b

Expected behaviour

I would have expected my wheel to be compatible with the stable API of version 3.11.

OS

Linux

Python version

3.12.7

Cython version

3.1.0

Additional context

I am currently using the following compiler directives for building my wheel

-Xboundscheck=False -Xlanguage_level=3   -Xembedsignature=True  -Xc_string_type=str -Xc_string_encoding=utf-8  -Xwraparound=False

The resulting abi3audit command line and results:

abi3audit --report --assume-minimum-abi3 3.11 build/cy_test.abi3.so 
{
  "specs": {
    "build/cy_test.abi3.so": {
      "kind": "object",
      "object": {
        "name": "cy_test.abi3.so",
        "result": {
          "is_abi3": true,
          "is_abi3_baseline_compatible": false,
          "baseline": "3.11",
          "computed": "3.14",
          "non_abi3_symbols": [],
          "future_abi3_objects": {
            "Py_TYPE": "3.14"
          }
        }
      }
    }
  }
}
@da-woods
Copy link
Contributor
da-woods commented May 9, 2025

I think this is a false positive from abi3audit.

The status of the various macros in the limited API is really badly documented and they've been resistant to documenting it further (although I'm definitely not the only one that's been confused by it). But I believe they are in the Limited API and are OK to use.

In Python 3.12 Py_TYPE looks to be a static inline function (https://github.com/python/cpython/blob/0b05ead877f909b7efe712db758012d9dbece7ce/Include/object.h#L218) which means that it will be included independently into each binary.

In Python 3.14 it gets changed into a non-static function which has to be linked to the definition in Python.

So I think abi3audit is just seeing the static inline definition and misreporting it. Py_REFCNT is almost certainly similar.

If you try to use your library in Python 3.11 does it work?

@benoit9126
Copy link
Author

@da-woods You are right! It works fine despite the error coming from abi3audit. Sorry for the inconvenience.

@da-woods
Copy link
Contributor
da-woods commented May 9, 2025

No problem. Thanks for trying out the limited API mode.

Do report the issue to abi3audit if you haven't already.

I'll close this issue since I think we're both convinced it's a false positive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0