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.

Title: dir() hangs interpreter
Type: crash Stage: resolved
Components: Versions: Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: sfaleron, steven.daprano, vstinner
Priority: normal Keywords:

Created on 2018-08-06 13:57 by sfaleron, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit sfaleron, 2018-08-06 19:53
Messages (4)
msg323208 - (view) Author: Chris Fuller (sfaleron) Date: 2018-08-06 13:57
It's a little obscure. Nothing to get alarmed about, probably. It involves recursion and __getattr__() during object creation.

Only present with 2.7 new-style classes. Old-style 2.7 did not exhibit this behavior nor did 3.x. Checked on Linux/Cygwin/Windows.
msg323212 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-08-06 15:13
I don't think the description you give is very accurate. The description in the file says:

"Hangs/core dumps Python2 when instantiated"

(which is it? hang or core dump?)

but I can't replicate that. Instantiating A() is fine for me. (Tested in Python 2.7 on Linux.)

The whole business about "splat" is amusing but irrelevant. I can replicate the hang (no core dump) using this simpler example:

class B:
    def __getattr__(self, name):
        return name in dir(self)

Instantiating the class is fine, but calling dir() on it locks up:

>>> b = B()
>>> dir(b)

[1]+  Stopped                 python2.7 -E

(after typing Ctrl-Z in the xterm). Notice that B is an old-style class in this example. The same behaviour also occurs when inheriting from object.
msg323218 - (view) Author: Chris Fuller (sfaleron) Date: 2018-08-06 19:54
It hangs, and on Cygwin it dumped core when I hit ctrl-break. I uploaded a revised script. It';s a heisenbug, all I did was removed the unused splat method.
msg368893 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-15 01:06
> Only present with 2.7 new-style classes. Old-style 2.7 did not exhibit this behavior nor did 3.x.

Python 2 is no longer supported, I close the issue as out of date.
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78527
2020-05-15 01:06:13vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg368893

resolution: out of date
stage: resolved
2018-08-06 19:54:59sfaleronsetmessages: + msg323218
2018-08-06 19:53:10sfaleronsetfiles: +
2018-08-06 19:52:45sfaleronsetfiles: -
2018-08-06 15:13:23steven.dapranosetnosy: + steven.daprano
messages: + msg323212
2018-08-06 13:57:49sfaleroncreate