classification
Title: Rename private structs to use names closer to types
Type: Stage:
Components: Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: nascheme, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2018-11-28 00:12 by vstinner, last changed 2018-11-28 08:07 by serhiy.storchaka.

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
2018-11-28 08:07:44serhiy.storchakasetmessages: + msg330578
2018-11-28 00:12:47vstinnersetnosy: + nascheme, serhiy.storchaka
2018-11-28 00:12:34vstinnercreate