Yury Selivanov <yseliva...@gmail.com> added the comment:
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() ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40696> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com