Skip to content

Commit

Permalink
ENH Work around IPython regression
Browse files Browse the repository at this point in the history
Jug shell fails in newer versions of IPython, see ipython/ipython#13966
  • Loading branch information
luispedro committed May 11, 2023
1 parent dee23ce commit 86809d7
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions jug/subcommands/shell.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2008-2022, Luis Pedro Coelho <[email protected]>
# Copyright (C) 2008-2023, Luis Pedro Coelho <[email protected]>
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -99,23 +99,17 @@ class ShellCommand(SubCommand):
def run(self, store, options, jugspace, *args, **kwargs):
try:
import IPython
if IPython.version_info[0] >= 1:
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.ipapp import load_default_config
else:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
from IPython.frontend.terminal.ipapp import load_default_config
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.ipapp import load_default_config
config = load_default_config()
ipshell = InteractiveShellEmbed(config=config, display_banner=_ipython_banner)
if IPython.core.getipython.get_ipython() is None:
ipshell = InteractiveShellEmbed.instance(config=config, display_banner=_ipython_banner)
else:
ipshell = InteractiveShellEmbed(config=config, display_banner=_ipython_banner)
except ImportError:
try:
# Fallback for older Python:
from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed(banner=_ipython_banner)
except ImportError:
import sys
sys.stderr.write(_ipython_not_found_msg)
sys.exit(1)
import sys
sys.stderr.write(_ipython_not_found_msg)
sys.exit(1)

def _load_all():
'''
Expand Down

0 comments on commit 86809d7

Please sign in to comment.