[New-bugs-announce] [issue19235] Add a dedicated subclass for recursion errors

Elazar Gershuni report at bugs.python.org
Sat Oct 12 18:41:47 CEST 2013

New submission from Elazar Gershuni:

There's no dedicated StackOverflowErrorException, So there is no way to accurately distinguish a recursion overflow from a general RuntimeError. 

One cannot use the exception message, since the docs explicitly says that "Exception messages are not part of the Python API", and checking for

    len(traceback.extract_tb(trace)) >= sys.getrecursionlimit()-1

is ugly, and (AFAIK) not guaranteed to be correct.

Use case: I've found this while trying to create a cycle detector that will compress the traceback of such errors.

See discussion in python-ideas:

An cycle-detection implementation:

components: Library (Lib)
messages: 199595
nosy: elazar
priority: normal
severity: normal
status: open
title: Add a dedicated subclass for recursion errors
type: enhancement
versions: Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list