clist has a bug that limits how a clist instance can be used.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pyax |
Fix Committed
|
Medium
|
Kevin Shuk |
Bug Description
clist uses the following method however __repr__ methods must take care to use some method other than the str() method when producing a representation of a clist because the method below causes stack overflow problems at runtime.
def __repr__(self):
return "clist(%s)" %str(self)
A better method would be to represent the clist as a list of items rather than as a representation of the whole list.
This bug affects how clist instances get handled by a method that needs to represent the clist - this does not happen often however when it does happen the method above fails.
The reason is str() uses __repr__() - this is common for all Python objects that seek to use str() to form a representation of an object where the item being rendered by str() is the object itself.
Try this instead:
def __repr__(self): [str(item) for item in self]))
return "clist(%s)" % (','.join(
This method fails whenever any items in a clist happens to be a clist instance.