ionelmc / python-hunter

Hunter is a flexible code tracing toolkit.
https://python-hunter.readthedocs.io/
BSD 2-Clause "Simplified" License
794 stars 46 forks source link

Types supported by `safe_repr` #83

Closed GertBurger closed 3 years ago

GertBurger commented 4 years ago

I was wondering what the scope limitations for safe_repr is?

Often I run into issues with builtin data types that are not rendered in a usable fashion and if having support for that falls within the scope of safe_repr or if the project's opinion is that repr_func should be used.

Clearly arbitrary and user defined objects should be handled by a repr func but does python builtins also fall in that category?

ionelmc commented 4 years ago

Do you have examples of builtin types that aren't displayed? Note that safe_repr doesn't support subclasses of builtins due to the inherent unsafety of isinstance (it would trigger whatever descriptor is on __class__ unfortunately). Also see this.

Hunter could have a almost_safe_repr (that would work like the old repr that used isinstance and such) but I'd like to hear your usecase first.

ionelmc commented 4 years ago

Also, search for repr in https://python-hunter.readthedocs.io/en/latest/changelog.html to see how it evolved.

GertBurger commented 4 years ago

Right now the ones that I often long for are:

I guess one would have to verify that their repr()'s are suitable for inclusion into safe_repr() though

ionelmc commented 4 years ago

Dully noted. Will add support for those.

GertBurger commented 4 years ago

ta, I don't mind doing the work if you are busy...

ionelmc commented 4 years ago

Sure, why not 🥳

guettli commented 3 years ago

@GertBurger I think this issue was solved via https://github.com/ionelmc/python-hunter/commit/63ed6fd3b35029eac198b859f013e8edf0c77586

Maybe you want to close it?

GertBurger commented 3 years ago

:+1: