On Sun, Oct 4, 2020 at 1:24 AM Serhiy Storchaka <storch...@gmail.com> wrote:
> 04.10.20 01:06, Guido van Rossum пише: > > On Sat, Oct 3, 2020 at 9:28 AM Serhiy Storchaka <storch...@gmail.com > > <mailto:storch...@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.
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/Y4TFXMXMCWL763FIJX73QO6AKELJZHTT/ Code of Conduct: http://python.org/psf/codeofconduct/