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 private structs to use names closer to types
Type: Stage: resolved
Components: C API Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: nascheme, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2018-11-28 00:12 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg330564 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-11-28 00:12
To prevent a compiler warning/error (on clang), I had modify Include/object.h and Include/pystate.h:

* Replace "PyTypeObject" with "struct _typeobject"
* Replace "PyInterpreterState" with "struct _is"
* Replace "PyThreadState" with "struct _ts"

=> see commit 9bdd2de84c1af55fbc006d3f892313623bd0195c of bpo-35134.

I propose to rename "struct _ts" to "struct PyThreadState" or "struct _PyThreadState", and do a similar change for "struct _ts" and "struct _typeobject". My intent is to make the Include/object.h and Include/pystate.h less surprising.

Maybe "struct _frame" should also be renamed to "struct _PyFrameObject"?

--

Python header files use many "private" C structures (struct):

struct _addr_pair
struct _arena PyArena
struct _ceval_runtime_state
struct _dictkeysobject
struct _err_stackitem
struct _frame
struct _gc_runtime_state
struct _gil_runtime_state gil
struct _heaptypeobject
struct _is
struct _longobject
struct _object
struct _odictobject PyODictObject
struct _pending_calls
struct _pycontextobject
struct _pycontexttokenobject
struct _pycontextvarobject
struct _symtable_entry
struct _traceback
struct _ts
struct _typeobject
struct _warnings_runtime_state
struct _xid
struct _xidregitem

The following structures are documented:

* struct _frozen:
  https://docs.python.org/dev/c-api/import.html#c._frozen
* struct _inittab:
  https://docs.python.org/dev/c-api/import.html#c._inittab
* struct _node:
  https://docs.python.org/dev/c-api/veryhigh.html#c.PyParser_SimpleParseString
msg330578 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-28 08:07
I don't know reasons against using the same name for the structure and the type. This can break extensions written before exposing the current Python C API in Python 1.5, but they should be already broken several times.

This is a cosmetic but large change. I suggest to ask on Python-Dev for the case if somebody has objections or better idea.
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79514
2021-09-21 22:26:52vstinnersetstatus: open -> closed
resolution: rejected
stage: resolved
2021-05-26 22:41:12vstinnersetcomponents: + C API, - Interpreter Core
title: Rename private structs to use names closer to types -> [C API] Rename private structs to use names closer to types
2018-11-28 08:07:44serhiy.storchakasetmessages: + msg330578
2018-11-28 00:12:47vstinnersetnosy: + nascheme, serhiy.storchaka
2018-11-28 00:12:34vstinnercreate