On Sun, Oct 4, 2020 at 1:24 AM Serhiy Storchaka <storchaka@gmail.com> wrote:
04.10.20 01:06, Guido van Rossum пише:
> On Sat, Oct 3, 2020 at 9:28 AM Serhiy Storchaka <storchaka@gmail.com
> <mailto:storchaka@gmail.com>> wrote:
>     The code of object.__dir__() is very old, it predates new-style classes,
>     and currently it gathers names using different algorithm than used in
>     object.__getattr__(), so object.__dir__() does not always return a list
>     of names accepted by object.__getattr__().
> Would anything break if we changed `dir()` to use `__mro__` instead of
> `__bases__`? It would probably be simpler.

It is what I planned to play with. Also we can consider using
_PyObject_GetDictPtr() instead of resolving the __dict__ attribute and
Py_TYPE() instead of resolving the __class__ attribute.

>     > I think all that hackery may predate (and may even have been an
>     > inspiration for features of) new-style classes.
>     I wonder whether it should pass with Python 2.
> I suppose you meant "pass" as in "die". I agree.

Do we need a deprecation period?

If the code can be written such that a DeprecationWarning can be raised if the __bases__ path is taken then yes unless you ask the SC to skip it and they agree to it: https://www.python.org/dev/peps/pep-0387/#basic-policy-for-backwards-compatibility.