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 steven.daprano
Recipients steven.daprano
Date 2021-01-01.05:16:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609478187.83.0.886724654093.issue42801@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-01-01 05:16:27steven.dapranosetrecipients: + steven.daprano
2021-01-01 05:16:27steven.dapranosetmessageid: <1609478187.83.0.886724654093.issue42801@roundup.psfhosted.org>
2021-01-01 05:16:27steven.dapranolinkissue42801 messages
2021-01-01 05:16:27steven.dapranocreate