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: [C API] Rename CFrame or hide it to only export names starting with Py
Type: Stage: resolved
Components: C API Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, brandtbucher, vstinner
Priority: normal Keywords: patch

Created on 2021-10-11 09:50 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31584 merged vstinner, 2022-02-25 15:04
Messages (8)
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.
msg414000 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-25 15:06
> We should either make the whole PyThreadState structure private (move it to the internal C API), or rename CFrame (to PyCFrame?).

Well, moving PyThreadState to the internal C API is complicate. I prefer to start by renaming CFrame to PyCFrame: see GH-31584.
msg414201 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-28 15:04
New changeset 7496f9587306772b56ed074092c020f3ef16bf95 by Victor Stinner in branch 'main':
bpo-45431: Rename CFrame to _PyCFrame in the C API (GH-31584)
https://github.com/python/cpython/commit/7496f9587306772b56ed074092c020f3ef16bf95
msg414202 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-28 15:05
Ok, CFrame has been renamed.

> We should either make the whole PyThreadState structure private (move it to the internal C API)

This idea is tracked by bpo-39947.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89594
2022-02-28 15:07:04vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-28 15:05:21vstinnersetmessages: + msg414202
2022-02-28 15:04:16vstinnersetmessages: + msg414201
2022-02-25 18:34:15brandtbuchersetnosy: + brandtbucher
2022-02-25 15:06:29vstinnersetmessages: + msg414000
2022-02-25 15:04:59vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request29707
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