Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipython integration #24

Open
nixjdm opened this issue Dec 8, 2018 · 4 comments
Open

ipython integration #24

nixjdm opened this issue Dec 8, 2018 · 4 comments

Comments

@nixjdm
Copy link
Collaborator

nixjdm commented Dec 8, 2018

There's at least a couple problems with this working with ipython.

  1. Exporting the env var seems to have no effect.
  2. This brings the formatting of tbvaccine, and some things, but not the locals I added in the shell.
from tbvaccine import TBVaccine 
try:
    some_stuff()
except:
    print(TBVaccine().format_exc())

imagine this is styled:

Traceback (most recent call last):
  File "<ipython-input-2-6c94a79ed40f>", line 4, in <module>
>   some_stuff()
|     __annotations__ = {}
|     __builtins__    = <module 'builtins' (built-in)>
|     __cached__      = None
|     __doc__         = None
|     __file__        = [path to]/bin/ipython
|     __loader__      = <_frozen_importlib_external.SourceFileLoader object at 0x7f880a16fc88>
|     __name__        = __main__
|     __package__     = None
|     __spec__        = None
|     re              = <module 're' from '[path to]/lib/python3.6/re.py'>
|     start_ipython   = <function start_ipython at 0x7f88069a18c8>
|     sys             = <module 'sys' (built-in)>
NameError: name 'some_stuff' is not defined

  1. This seems to not be any different from a normal exception in ipython. It looks identical either way.
import tbvaccine
tbvaccine.add_hook(isolate=False)

1 / 0

The same seems to hold for at least flask-shell-ipython, which is unsurprising.

Possibly out-of-scope: I have no idea really, but maybe whatever is needed to get this to work would also suffice for Jupyter as well. If we're lucky.

@skorokithakis
Copy link
Owner

Yeah, this is flaky enough that I ended up not using it myself, but also useful enough that I really should look into it and see why it doesn't work. I would expect that the global system hook would pretty-print any exception, but that doesn't seem to work either.

@nixjdm
Copy link
Collaborator Author

nixjdm commented Dec 8, 2018

The addition of printing locals is the selling point for me :) That's a large part of why Sentry is great too. It can make debugging a ton easier.

@skorokithakis
Copy link
Owner

Definitely agreed, it's a great tool, if I can get it working :P

@alexmojaki
Copy link

It's not well advertised, but you can make ipython show local variables by running %xmode Verbose. https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-xmode

ipython tracebacks will also be improved with the release of 8.0, e.g. see ipython/ipython#12150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants