[New-bugs-announce] [issue42801] Exception catching function crashes on recursive list
Steven D'Aprano
report at bugs.python.org
Fri Jan 1 00:16:27 EST 2021
New submission from Steven D'Aprano <steve+python at pearwood.info>:
This function crashes on the following recursive list:
def length(x):
try:
return sum(length(i) for i in x)
except Exception:
return 1
a = [[1, 2, 3], [4, 5, 6]]
a.append(a)
length(a)
Crashes:
Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
Python runtime state: initialized
Current thread 0x00007eff18d77740 (most recent call first):
File "<stdin>", line 3 in length
File "<stdin>", line 3 in <genexpr>
File "<stdin>", line 3 in length
File "<stdin>", line 3 in <genexpr>
...
Aborted (core dumped)
For brevity I've cut some of the output. There are about fifty pairs of "line 3 in length"/line 3 in <genexpr>" lines, all identical.
----------
components: Interpreter Core
messages: 384150
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: Exception catching function crashes on recursive list
type: crash
versions: Python 3.7, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42801>
_______________________________________
More information about the New-bugs-announce
mailing list