This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyCFunction_New is not exported with PyAPI_FUNC
Type: Stage: patch review
Components: C API Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: petr.viktorin Nosy List: erlendaasland, petr.viktorin, shihai1991, vstinner
Priority: normal Keywords: patch

Created on 2021-02-16 16:07 by petr.viktorin, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 24551 merged petr.viktorin, 2021-02-16 16:33
Messages (7)
msg387119 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-02-16 16:07
PyCFunction_New is part of the Stable ABI (see bpo-21354), but it is not declared as PyAPI_FUNC, and thus not exported with GCC's -fvisibility=hidden.
To match Windows, it should be declared.

(I don't think this has any real impact, I just want to fix it before enabling automatic tests on such issues.)
msg387120 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-16 16:27
Oh, it's not listed by Doc/data/stable_abi.dat and so not checked by Tools/scripts/stable_abi.py.

It's implemented explicitly as a function only for the stable ABI:

PyObject *
PyCFunction_New(PyMethodDef *ml, PyObject *self)
{
    return PyCFunction_NewEx(ml, self, NULL);
}

So yeah, it should be exported.

By the way, I would suggest to move "#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)" to Include/cpython/methodobject.h to clarify that the limited C API should call "PyCFunction_New()" and not call "PyCFunction_NewEx()".
msg387121 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-02-16 16:38
> By the way, I would suggest to move "#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)" to Include/cpython/methodobject.h 

OK, I'll add that move to the PR.

> Oh, it's not listed by Doc/data/stable_abi.dat and so not checked by Tools/scripts/stable_abi.py.

I'm planning to rework this for PEP 652 (which is how I found the issue in the first place), so I'll not add it there now.
msg387122 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-02-16 16:44
> By the way, I would suggest to move "#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)" to Include/cpython/methodobject.h 

Wait no, I wrote too soon.
PyCFunction_NewEx is part of the limited API as well, even though it's undocumented. People can call it.
msg387163 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2021-02-17 16:42
>> PyCFunction_NewEx is part of the limited API as well, even though it's undocumented. People can call it.
>
>Wait no, I wrote too soon.
>PyCFunction_NewEx is part of the limited API as well, even though it's >undocumented. People can call it.

Find some 3rd user calling this function in: https://searchcode.com/?q=PyCFunction_NewEx+. So I prefer to keep it too.
If calling `PyCFunction_New()` is better than `PyCFunction_NewEx()`, MAYBE we can add some description info in PR 24551.
msg387564 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-02-23 12:24
New changeset 7bb1cafa4e3d648669212ea4c6d11d6eafc6da23 by Petr Viktorin in branch 'master':
bpo-43239: Export PyCFunction_New with PyAPI_FUNC (GH-24551)
https://github.com/python/cpython/commit/7bb1cafa4e3d648669212ea4c6d11d6eafc6da23
msg404406 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-10-20 08:59
It seems to me that this issue can be closed as fixed. Do you have further PR's for this, Petr?
History
Date User Action Args
2022-04-11 14:59:41adminsetstatus: pending -> open
github: 87405
2021-10-20 08:59:18erlendaaslandsetstatus: open -> pending
nosy: + erlendaasland
messages: + msg404406

2021-02-23 12:24:04petr.viktorinsetmessages: + msg387564
2021-02-17 16:42:33shihai1991setnosy: + shihai1991
messages: + msg387163
2021-02-16 16:44:19petr.viktorinsetmessages: + msg387122
2021-02-16 16:38:47petr.viktorinsetmessages: + msg387121
2021-02-16 16:33:46petr.viktorinsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23334
2021-02-16 16:27:28vstinnersetnosy: + vstinner
messages: + msg387120
2021-02-16 16:07:52petr.viktorincreate