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 Mark.Shannon
Recipients Mark.Shannon, serhiy.storchaka, xxm
Date 2021-01-18.11:14:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610968485.59.0.27949984748.issue42950@roundup.psfhosted.org>
In-reply-to
Content
If you make calls in an exception handler that is handling a RecursionError, without unwinding first, then it is likely that another RecursionError may occur.

What is strange is that the second RecursionError is raised after `print(str(e))` has printed the exception, which is weird and needs further investigation.

The following code, using `list.append` shows what happens without the additional RecursionError from print.
`list.append` is safe to use as it never raises a RecursionError.

    import sys
    sys.setrecursionlimit(100)
    events = []

    def foo(c):
        try:
            c = c + 1
            events.append("ss"+str(c))
            foo(c)
        except Exception as e:
            events.append(e)
            events.append("kk")
        events.append(c)

    c = 0
    foo(c)
    for ev in events:
        print(ev)


ss1
ss2
....
ss97
maximum recursion depth exceeded while getting the str of an object
kk
97
95
......
3
2
1
History
Date User Action Args
2021-01-18 11:14:45Mark.Shannonsetrecipients: + Mark.Shannon, serhiy.storchaka, xxm
2021-01-18 11:14:45Mark.Shannonsetmessageid: <1610968485.59.0.27949984748.issue42950@roundup.psfhosted.org>
2021-01-18 11:14:45Mark.Shannonlinkissue42950 messages
2021-01-18 11:14:45Mark.Shannoncreate