Skip to content

bpo-45431: Rename CFrame to _PyCFrame in the C API #31584

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

Merged
merged 1 commit into from
Feb 28, 2022
Merged

bpo-45431: Rename CFrame to _PyCFrame in the C API #31584

merged 1 commit into from
Feb 28, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Feb 25, 2022

Rename also struct _cframe to struct _PyCFrame.

Add a comment suggesting using public functions rather than using
directly the private _PyCFrame structure.

https://bugs.python.org/issue45431

@markshannon
Copy link
Member

Why?

@markshannon
Copy link
Member

CFrame is an internal implementation detail. It is not part of the C API.

@vstinner
Copy link
Member Author

See https://devguide.python.org/c-api/ for the organization of the C API. The name is not prefixed by _Py or _PY, so it's a public name. Even if it's not a symbol in the ABI, it is a public name in the C API.

@vstinner
Copy link
Member Author

CFrame is an internal implementation detail. It is not part of the C API.

Currently, it's a public name in the public C API. Today, it's used by PyThreadState.cframe and PyThreadState.root_cframe, and PyThreadState is public. We cannot define PyThreadState if the compiler doesn't know CFrame structure (root_cframe is an instance of the struct, not a pointer). I'm open to make PyThreadState opaque, but nobody finished the work to make that possible: see https://bugs.python.org/issue39947

@markshannon
Copy link
Member

At least put an underscore on the front of the name: _PyCFrame.
And a big "Do not use this" warning, just to be sure.

Rename also struct _cframe to struct _PyCFrame.

Add a comment suggesting using public functions rather than using
directly the private _PyCFrame structure.
@vstinner
Copy link
Member Author

At least put an underscore on the front of the name: _PyCFrame. And a big "Do not use this" warning, just to be sure.

Sure, done. I added a comment suggesting using public functions rather than using directly the private _PyCFrame structure.

Well, I would prefer to be able to move the whole PyThreadState structure right now to the internal C API, as I just did for PyFrameObject, but I would prefer to have a smoother migration. I plan to spend more time on preparing projects using PyThreadState, maybe add a few more getter functions.

@vstinner vstinner changed the title bpo-45431: Rename CFrame to PyCFrame in the C API bpo-45431: Rename CFrame to _PyCFrame in the C API Feb 27, 2022
@vstinner
Copy link
Member Author

@markshannon: Would you mind reviewing this change?

@markshannon
Copy link
Member

That looks fine, thanks.

@vstinner vstinner merged commit 7496f95 into python:main Feb 28, 2022
@vstinner vstinner deleted the cframe branch February 28, 2022 15:04
@vstinner
Copy link
Member Author

Thanks for the feedback. I now agree that _PyCFrame (private name) is better ;-)

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

Successfully merging this pull request may close these issues.

4 participants