Title: Expose Py_TPFLAGS_ values from Python
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, benjamin.peterson, erik.bray
Priority: normal Keywords:

Created on 2015-08-27 13:50 by erik.bray, last changed 2019-12-21 06:43 by BTaskaya.

Messages (3)
msg249233 - (view) Author: Erik Bray (erik.bray) * (Python triager) Date: 2015-08-27 13:50
Although admittedly rare, I've on more than one occasion wanted to inspect the tp_flags of a given class.  It seems silly to me that although tp_flags is exposed to Python via type.__flags__, I then have to go rummaging around in Include/object.h in order to actually interpret the value of that attribute.

It would be nice, then, if the Py_TPFLAGS_* values were exposed as constants somewhere in Python (perhaps in the sys module)?

If it's agreed this is a good idea I'll gladly provide a patch if someone can point me toward where this would best live.
msg249235 - (view) Author: Erik Bray (erik.bray) * (Python triager) Date: 2015-08-27 14:00
Alternatively (or additionally) it would be nice if type.__flags__ were some PyStructSequence-based type (though as a subtype of int for backwards compat).
msg358761 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2019-12-21 06:43
IMHO inspect would be a better place to put these constants (like CO_ flags).
Date User Action Args
2019-12-21 06:43:00BTaskayasetnosy: + BTaskaya

messages: + msg358761
versions: + Python 3.9, - Python 3.6
2016-01-14 18:41:41SilentGhostsetnosy: + benjamin.peterson

versions: + Python 3.6
2015-08-27 14:00:36erik.braysetmessages: + msg249235
2015-08-27 13:50:54erik.braycreate