Author rhettinger
Recipients aganders3, aviramha, bar.harel, benjamin.peterson, brandtbucher, bukzor, georg.brandl, jmillikin, levkivskyi, miss-islington, pitrou, rhettinger, serhiy.storchaka
Date 2022-01-15.04:34:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642221282.36.0.436774763679.issue46376@roundup.psfhosted.org>
In-reply-to
Content
> It changes behavior for objects not being iterable/sequences 
> if not inheriting from `abc.collections.Sequence`.

This would be a breaking change (for example, it broke the long stable sre_parse code).

The utility of PySequence_Check and PyMapping_Check is already so low that it isn't work breaking other things to just to marginally improve these two minor and rarely used functions.

These functions will never be fully reliable.  The documentation explains that in general, we can't tell if a class with __getitem__ is a mapping or a sequence.  Sometimes hints are present (such as the tp_flags), but the can't get a reliable result.  As Guido observed, "calling PyMapping_Check() was never particularly reliable, and extension modules depending on it probably always had subtle bugs."  That was true in 2011 and it is still true today.

I recommend closing this.  These functions are mostly unimportant and unreliable and cannot be made correct.  In contrast, iterability is important and needs to be stable.  Special cases aren't important enough to break the rules.
History
Date User Action Args
2022-01-15 04:34:42rhettingersetrecipients: + rhettinger, georg.brandl, pitrou, benjamin.peterson, jmillikin, bukzor, aganders3, serhiy.storchaka, levkivskyi, bar.harel, miss-islington, brandtbucher, aviramha
2022-01-15 04:34:42rhettingersetmessageid: <1642221282.36.0.436774763679.issue46376@roundup.psfhosted.org>
2022-01-15 04:34:42rhettingerlinkissue46376 messages
2022-01-15 04:34:42rhettingercreate