saferepr() can create proper representations of classes with broken __getattribute__ (#7145)
()
| 165 | |
| 166 | |
| 167 | def test_broken_getattribute(): |
| 168 | """saferepr() can create proper representations of classes with |
| 169 | broken __getattribute__ (#7145) |
| 170 | """ |
| 171 | |
| 172 | class SomeClass: |
| 173 | def __getattribute__(self, attr): |
| 174 | raise RuntimeError |
| 175 | |
| 176 | def __repr__(self): |
| 177 | raise RuntimeError |
| 178 | |
| 179 | assert saferepr(SomeClass()).startswith( |
| 180 | "<[RuntimeError() raised in repr()] SomeClass object at 0x" |
| 181 | ) |