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 yselivanov
Recipients BTaskaya, aeros, asvetlov, carltongibson, chris.jerdonek, eamanu, felixxm, yselivanov
Date 2020-05-21.00:11:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590019890.19.0.731143371768.issue40696@roundup.psfhosted.org>
In-reply-to
Content
Just a note, __context__ cycles can theoretically be longer than 2 nodes. I've encountered cycles like `exc.__context__.__context__.__context__ is exc` a few times in my life, typically resulting from some weird third-party libraries.

The only solution is to use a `set()` collection to track already visited exceptions.

To make it fast I propose to modify the code to:

1. Do a fast traverse with a regular while loop without tracking (no set())

2. If the number of iterations is longer than 100 and there's still no top context found -- go to (3)

3. Do a slower implementation with set()
History
Date User Action Args
2020-05-21 00:11:30yselivanovsetrecipients: + yselivanov, asvetlov, chris.jerdonek, eamanu, BTaskaya, aeros, carltongibson, felixxm
2020-05-21 00:11:30yselivanovsetmessageid: <1590019890.19.0.731143371768.issue40696@roundup.psfhosted.org>
2020-05-21 00:11:30yselivanovlinkissue40696 messages
2020-05-21 00:11:29yselivanovcreate