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 danbst
Recipients danbst
Date 2020-11-04.11:44:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604490271.59.0.652277780579.issue42259@roundup.psfhosted.org>
In-reply-to
Content
First, here's an example using str():

```
class NiceObject:
    def __str__(self):
        return str(self.__dict__)
    def __repr__(self):
        return str(self)

s = NiceObject()
s.self = s
```
This outputs:
```
>>> s
{'self': {...}}
```

When I replace str() call with pprint.saferepr(), I end up in infinite recursion.
```
import pprint

class ReallyNiceObject:
    def __str__(self):
        return pprint.saferepr(self.__dict__)
    def __repr__(self):
        return str(self)
```

Same happens for pprint.pformat(), with depth set.

Is this expected behavior?
History
Date User Action Args
2020-11-04 11:44:31danbstsetrecipients: + danbst
2020-11-04 11:44:31danbstsetmessageid: <1604490271.59.0.652277780579.issue42259@roundup.psfhosted.org>
2020-11-04 11:44:31danbstlinkissue42259 messages
2020-11-04 11:44:31danbstcreate