[ python-Bugs-851001 ] comparing reference looped lists causes RuntimeError

SourceForge.net noreply at sourceforge.net
Sat Nov 29 03:39:59 EST 2003


Bugs item #851001, was opened at 2003-11-28 20:43
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=851001&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: George Yoshida (quiver)
Assigned to: Nobody/Anonymous (nobody)
Summary: comparing reference looped lists causes RuntimeError

Initial Comment:
On CVS HEAD Python(2.4), comparing reference 
looped lists causes RuntimeError.

>>> import sys
>>> print sys.version
2.4a0 (#1, Nov 28 2003, 11:18:42)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)]
>>> l = []
>>> l.append(l)
>>> m = l[:]
>>> l, m
([[...]], [[[...]]])
>>> l == m
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: maximum recursion depth exceeded 
in cmp
>>> m == l
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: maximum recursion depth exceeded 
in cmp

On Python 2.3 & 2.2, this doesn't happen.

>>> import sys
>>> print sys.version
2.3.2 (#1, Oct  6 2003, 10:07:16)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)]
>>> l = []
>>> l.append(l)
>>> m = l[:]
>>> l, m
([[...]], [[[...]]])
>>> l == m
True

The results of Python 2.2 is same as Python 2.3 
except that True/False is denoted as 1/0.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-11-29 03:39

Message:
Logged In: YES 
user_id=80475

This is a feature.
Quoth Misc/NEWS:

Python no longer tries to be smart about recursive
comparisons. When comparing containers with cyclic
references to themselves it will now just hit the recursion
limit.  See SF patch 825639.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=851001&group_id=5470



More information about the Python-bugs-list mailing list