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.

Author rhettinger
Recipients aganders3, aviramha, bar.harel, benjamin.peterson, brandtbucher, bukzor, georg.brandl, levkivskyi, methane, miss-islington, pitrou, rhettinger, serhiy.storchaka
Date 2022-01-15.07:11:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642230680.07.0.45108869154.issue46376@roundup.psfhosted.org>
In-reply-to
Content
> what about simply excluding TPFLAGS_MAPPING from PySequence 
> and TPFLAGS_Sequence from PyMapping? It will remove the types 
> that are 100% not sequences or mappings, as these flags 
> are mutually exclusive by definition.

This is more plausible than the proposed breaking change.


> The result will be much more accurate

If they can't be made fully reliable, why would we ever recommend that someone use these functions in real code?  They can be made to guess better than they guess now, but there is still guesswork.  

ISTM developers should follow the structure pattern matching implementation and refuse the temptation to guess.  If a class declares itself as a mapping or sequence, that is reliable information.  In contrast, these functions attempt to divine meaning in the absence of a clear declaration.  Using these functions will likely result in subtle bugs.

Once Py_TPFLAGS_MAPPING and Py_TPFLAGS_SEQUENCE became available, we should have deprecated these functions.  No one should use them anymore. Their core design is flawed; they tried to deduce semantics from structural artifacts.
History
Date User Action Args
2022-01-15 07:11:20rhettingersetrecipients: + rhettinger, georg.brandl, pitrou, benjamin.peterson, methane, bukzor, aganders3, serhiy.storchaka, levkivskyi, bar.harel, miss-islington, brandtbucher, aviramha
2022-01-15 07:11:20rhettingersetmessageid: <1642230680.07.0.45108869154.issue46376@roundup.psfhosted.org>
2022-01-15 07:11:20rhettingerlinkissue46376 messages
2022-01-15 07:11:19rhettingercreate