[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2022-01-03 Thread Irit Katriel
Irit Katriel added the comment: The documentation change in the PR clarifies the current state of things. @serhiy.storchaka - do you have a view on whether we should aim for an actual fix, or just document and close? -- ___ Python tracker

[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2021-12-28 Thread Irit Katriel
Change by Irit Katriel : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2021-12-25 Thread Andrei Kulakov
Andrei Kulakov added the comment: The recursion protection in `saferepr` applies when two conditions are met: - the structure is subclassed from list, tuple or dict - __repr__ is not overriden In this case neither condition is met. However, the recursion is caused by the `__repr__` so when

[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2021-12-25 Thread Andrei Kulakov
Change by Andrei Kulakov : -- keywords: +patch nosy: +andrei.avk nosy_count: 2.0 -> 3.0 pull_requests: +28477 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30256 ___ Python tracker

[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2020-11-04 Thread Irit Katriel
Irit Katriel added the comment: I think this is a bug. There is recursion detection in pprint for dicts, lists and tuples, but it only applies when __repr__ has not been overridden in a subclass. If you remove the __repr__ definition from NiceObject then str(s) works. -- nosy:

[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2020-11-04 Thread Danylo Hlynskyi
New submission from Danylo Hlynskyi : 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