classification
Title: [C API] Rename CFrame or hide it to only export names starting with Py
Type: Stage:
Components: C API Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, vstinner
Priority: normal Keywords:

Created on 2021-10-11 09:50 by vstinner, last changed 2021-10-11 11:02 by vstinner.

Messages (5)
msg403639 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 09:50
#include <Python.h> should only define names which start with "Py" (Py, _Py, PY, _PY), but it now defines a structure called "CFrame" in Include/cpython/pystate.h.

We should either make the whole PyThreadState structure private (move it to the internal C API), or rename CFrame (to PyCFrame?).
msg403640 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 09:50
See also bpo-45316: [C API] Functions not exported with PyAPI_FUNC().
msg403642 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 09:52
See also the old isssue with "READONLY": bpo-2897 "PyMemberDef missing in limited API / Deprecate structmember.h".
msg403648 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-10-11 10:50
Struct names aren't exported as symbols.

$ nm ./python | grep CFrame

So, I assume that are worried about name clashes for code that has
#include "Python.h".


Isn't the threadstate struct supposed to be opaque?
If so, then shouldn't it be moved to an internal header?


I don't want to add a "Py" prefix to the name of the CFrame struct.
The names of the various frames are confusing enough, without adding a "Py" prefix to something that isn't a Python frame.
msg403649 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 11:02
Mark Shannon:
> Struct names aren't exported as symbols.

Right.

> So, I assume that are worried about name clashes for code that has
> #include "Python.h".

Right :-)

> Isn't the threadstate struct supposed to be opaque?

Technically, it's public. I'm working on making it opaque in bpo-39947.
History
Date User Action Args
2021-10-11 11:02:09vstinnersetmessages: + msg403649
2021-10-11 10:50:26Mark.Shannonsetmessages: + msg403648
2021-10-11 09:52:37vstinnersetmessages: + msg403642
2021-10-11 09:50:27vstinnersetmessages: + msg403640
2021-10-11 09:50:03vstinnercreate