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 vlad2
Recipients vlad2
Date 2021-01-28.01:45:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611798337.38.0.626995188313.issue43048@roundup.psfhosted.org>
In-reply-to
Content
Python's standard logger provides an exception() method, which is to be called from except blocks to log out exception traces by pulling from sys.exc_info().

Per https://github.com/python/cpython/blob/3.9/Lib/logging/__init__.py#L617 , logger.exception('my message') eventually boils down to something like traceback.print_exception(ei[0], ei[1], ei[2], None, some_buffer) where ei is the sys.exc_info().

However, the traceback code generates that printout by constructing a TracebackException recursively for every `except` context.

In turn, if a RecursionError was generated from an exception thrown across many except blocks, the TracebackException construction itself will have a RecursionError. This is particularly bad in cases where you'd want to capture this failure information, such as when you're printing the exception, since you'll never find out about the originating error.

Certain (well-used) libraries rely on try/except for control flow, and occasionally do recurse in their except blocks, so such exceptions are not hypothetical.

A solution to this might be to avoid constructing a TracebackException, and instead unwind traceback context using a while loop.
History
Date User Action Args
2021-01-28 01:45:37vlad2setrecipients: + vlad2
2021-01-28 01:45:37vlad2setmessageid: <1611798337.38.0.626995188313.issue43048@roundup.psfhosted.org>
2021-01-28 01:45:37vlad2linkissue43048 messages
2021-01-28 01:45:36vlad2create