From 2409575d28fc7c9cae44c9085c7457ddfb54f893 Mon Sep 17 00:00:00 2001 From: Richard Willis <32576259+RichardEWillis@users.noreply.github.com> Date: Fri, 5 May 2023 00:18:21 -0700 Subject: [PATCH] Fix for the gf shell. Supports newer versions of IPython, v3.11+ (#414) IPython.terminal broke the greatfet shell such that any attempt to use it resulted in an exception ending in: Exception 'NoneType' object has no attribute 'check_complete' This was traced to a change in IPython, version 8.11 and has broken other projects as well, refer to this issue in the IPython project: ipython/ipython#13966 This PR fixes the problem, as suggested in the issue report (linked above). It should be compatible with IPython v8.11 and later, and also backwards compatible for earlier versions of the library as well (as per the above issues last comment). I tested the raw Python script (greatefet_shell.py) but have not managed to generate an install (.egg ?) using the README instructions. The .py file, when run directly, no longer creates an exception and the shell runs normally. --- host/greatfet/commands/greatfet_shell.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/host/greatfet/commands/greatfet_shell.py b/host/greatfet/commands/greatfet_shell.py index f859bfab..fbbca74c 100755 --- a/host/greatfet/commands/greatfet_shell.py +++ b/host/greatfet/commands/greatfet_shell.py @@ -15,7 +15,6 @@ from greatfet.util.interactive import GreatFETShellMagics import IPython -from IPython.terminal.interactiveshell import TerminalInteractiveShell def main(): @@ -69,7 +68,10 @@ def main(): # Create a new shell, and give it access to our created GreatFET object. - shell = TerminalInteractiveShell() + if IPython.core.getipython.get_ipython() is None: + shell = IPython.terminal.embed.InteractiveShellEmbed.instance() + else: + shell = IPython.terminal.embed.InteractiveShellEmbed() shell.push('gf') # Create nice aliases for our primary interfaces.