[New-bugs-announce] [issue35333] Rename private structs to use names closer to types

STINNER Victor report at bugs.python.org
Tue Nov 27 19:12:34 EST 2018


New submission from STINNER Victor <vstinner at redhat.com>:

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

----------
components: Interpreter Core
messages: 330564
nosy: vstinner
priority: normal
severity: normal
status: open
title: Rename private structs to use names closer to types
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35333>
_______________________________________


More information about the New-bugs-announce mailing list