The issue has been solved
Hi. This is not an issue. Rather an improvement proposal. I thought that it may be useful if better_exceptions could show values of attributes accessed by period operator.
For instance, instead of:
Traceback (most recent call last):
File "foo.py", line 9, in <module>
print(123 / X.y)
â”” <class '__main__.X'>
ZeroDivisionError: division by zero
we would get:
Traceback (most recent call last):
File "foo.py", line 9, in <module>
print(123 / X.y)
| â”” 0
â”” <class '__main__.X'>
ZeroDivisionError: division by zero

Interesting. I worry about the side effects of property access, however - since it's not just a lookup but potentially a function call, which means we'd also have to check for true property access beforehand.
But yeah, I think this could be done safely.
posted by Qix- about 6 years ago
Good point.
Potential side effects of __getattr__
could be eliminated if we inspect only attributes from __dict__
of the object (and its class, and parent classes of this class). But __getattribute__
may still cause problems.
On the other hand, better_exceptions already calls __repr__
which theoretically also can have side effects. So general safety is violated anyway.
posted by gergelyk about 6 years ago
could be eliminated if we inspect only attributes from __dict__
That's what I was thinking. inspect.getattr_static
would do nicely here.
On the other hand, better_exceptions already calls __repr__
which theoretically also can have side effects. So general safety is violated anyway.
Yes but __repr__
having side effects isn't necessarily a good idea anyway, IMO. I don't really care about that.
posted by Qix- about 6 years ago
inspect.getattr_static
- good finding. I agree regarding __repr__
.
posted by gergelyk about 6 years ago
posted by blueyed almost 6 years ago 
posted by issuehunt-app[bot] over 5 years ago 
@Qix- @gergelyk any update on this??
posted by lokesh1729 over 5 years ago
@qix- has rewarded $28.00 to @dtrckd. See it on IssueHunt
- :moneybag: Total deposit: $40.00
- :tada: Repository reward(20%): $8.00
- :wrench: Service fee(10%): $4.00
posted by issuehunt-app[bot] over 5 years ago