Skip to content

Commit

Permalink
Fix crash in check for terminal ipython
Browse files Browse the repository at this point in the history
`getattr` will raise an exception, so return `None` as a default
  • Loading branch information
jeffyjefflabs authored Mar 29, 2021
1 parent 2b923ab commit 2e43863
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wurlitzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def load_ipython_extension(ip):
Use: %load_ext wurlitzer
"""
if not getattr(ip, 'kernel'):
if not getattr(ip, 'kernel', None):
warnings.warn(
"wurlitzer extension doesn't do anything in terminal IPython"
)
Expand All @@ -379,7 +379,7 @@ def unload_ipython_extension(ip):
Use: %unload_ext wurlitzer
"""
if not getattr(ip, 'kernel'):
if not getattr(ip, 'kernel', None):
return
ip.events.unregister('pre_execute', sys_pipes_forever)
ip.events.unregister('post_execute', stop_sys_pipes)
Expand Down

0 comments on commit 2e43863

Please sign in to comment.