pyax team mailing list archive
-
pyax team
-
Mailing list archive
-
Message #00043
Re: [Bug 319792] Re: clist has a bug that limits how a clist instance canbe used.
I have run into the str() and __repr__() problem many times while coding my
huge (125,000+ lines) library of reusable code and I have had to code around
it by ensuring I never issue a str() during a __repr__() when the result can
be recursive.
See also the following from a quick Google search:
[Python-3000] PEP: str(container) should call str(item), not repr ... -->
http://mail.python.org/pipermail/python-3000/2008-May/013876.html
http://www.google.com/search?rlz=1C1GGLS_enUS291US304&sourceid=chrome&ie=UTF-8&q=str+and+__repr__+for+python
Enjoy. :-)
--------------------------------------------------
From: "Kevin Shuk" <surf@xxxxxxxxxxxxx>
Sent: Thursday, January 22, 2009 2:37 PM
To: <raychorn@xxxxxxxxxxx>
Subject: [Bug 319792] Re: clist has a bug that limits how a clist instance
canbe used.
> Thank you for the report & suggested fix. I did not realise the bit
> about str() using __repr__() - learn something new every day!
>
> My plan is to come up with a test case that shows the broken behavior,
> then apply your suggested fix and merge into trunk as soon as possible.
>
> ** Changed in: pyax
> Importance: Undecided => Medium
> Assignee: (unassigned) => Kevin Shuk (surf)
> Status: New => In Progress
>
> --
> clist has a bug that limits how a clist instance can be used.
> https://bugs.launchpad.net/bugs/319792
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Salesforce.com Apex API library for Python: In Progress
>
> 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.
>
--
clist has a bug that limits how a clist instance can be used.
https://bugs.launchpad.net/bugs/319792
You received this bug notification because you are a member of pyax
Developers, which is the registrant for pyax.
References