cool-RR / PySnooper

Never use print for debugging again
MIT License
16.34k stars 951 forks source link

Reduce dependency on `sys.gettrace` #197

Closed cool-RR closed 3 years ago

cool-RR commented 3 years ago

I tried to use PySnooper on my Brython app, and it failed so I opened this issue for them. It's interesting, we use sys.gettrace which turns out to be a CPython implementation detail rather than a Python language feature.

Would be cool if we other stopped depending on sys.gettrace, or provided a nice error message or a workaround for implementations that don't have it.

cool-RR commented 3 years ago

@alexmojaki This also affects your snoop.

alexmojaki commented 3 years ago

Are you saying other platforms support settrace but not gettrace?

alexmojaki commented 3 years ago

Also there's plenty of other implementation details being used, like everything involving frames. I'm impressed that Brython seems to support some of that, but from playing with the console it doesn't seem to support frame.f_lasti or code.co_varnames.

cool-RR commented 3 years ago

LOL, Pierre implemented that right now: https://github.com/brython-dev/brython/issues/1499

Unfortunately PySnooper still doesn't work on Brython, can't figure out why.

Are you saying other platforms support settrace but not gettrace?

I've checked PyPy and they do have gettrace. Honestly, it seems to be pretty simple logic, so it wouldn't be crazy to suggest on python-ideas to change the definition of it to be part of the language-- Or try to understand why it was defined as an implementation detail in the first place.

Also there's plenty of other implementation details being used, like everything involving frames. I'm impressed that Brython seems to support some of that, but from playing with the console it doesn't seem to support frame.f_lasti or code.co_varnames.

Ah, that might be a dealbreaker.

I was also very impressed with Brython. I was expecting something limited like MicroPython, but I'm doing crazy things like abstract base classes and annotations, and Brython's down for anything. It's a lot of fun to be editing Python code in my favorite IDE and having it run in the browser.

alexmojaki commented 3 years ago

settrace is an implementation detail, which is not surprising. The only thing I find surprising in all this is that Brython had settrace but not gettrace.

cool-RR commented 3 years ago

Ah, didn't know that. That would make this issue pointless.