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.

classification
Title: infinite recursion when using collections.Sequence in a recursive function (Py30a2)
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, mark
Priority: normal Keywords:

Created on 2007-12-13 15:41 by mark, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug.py mark, 2007-12-13 15:41
Messages (2)
msg58536 - (view) Author: Mark Summerfield (mark) * Date: 2007-12-13 15:41
In the attached file there are two tiny functions, flatten1() and
flatten2(). There is only one difference between them:
flatten1() has the line:
    if isinstance(x, list):
and flatten2() has this line instead:
    if isinstance(x, collections.Sequence):

flatten1() works perfectly in Python 2.5.1 and Python 30a2 (just comment
out the flatten2() code).
But flatten2() goes into "infinite" recursion in Python 30a2 when trying
to flatten list "c".
msg58537 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-13 17:31
The bug is in your code; a string is considered a sequence but its
elements are also strings (of length 1).
History
Date User Action Args
2022-04-11 14:56:28adminsetgithub: 45953
2007-12-13 17:31:03gvanrossumsetstatus: open -> closed
resolution: not a bug
messages: + msg58537
nosy: + gvanrossum
2007-12-13 15:41:06markcreate