[accerciser] IPython: Avoid using input splitter when not really needed
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accerciser] IPython: Avoid using input splitter when not really needed
- Date: Sat, 8 Jun 2019 19:21:15 +0000 (UTC)
commit 3008be6e0cbf6d42b55354405b37693b5c4c62c6
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date: Sat Jun 8 21:19:02 2019 +0200
IPython: Avoid using input splitter when not really needed
We can replace it, like IPython's interactiveshell, with a much simpler
loop. Hopefully that will get us compatible on longer term. It at least
works with IPython 7.2.0
Fixes #5
plugins/ipython_view.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/plugins/ipython_view.py b/plugins/ipython_view.py
index f7355d4..53664cf 100755
--- a/plugins/ipython_view.py
+++ b/plugins/ipython_view.py
@@ -134,6 +134,12 @@ class IterableIPShell:
#
self.__update_namespace()
+ # Avoid using input splitter when not really needed.
+ # Perhaps it could work even before 5.8.0
+ # But it definitely does not work any more with >= 7.0.0
+ self.no_input_splitter = parse_version(IPython.release.version) >= parse_version('5.8.0')
+ self.lines = []
+
def __update_namespace(self):
'''
Update self.IP namespace for autocompletion with sys.modules
@@ -175,14 +181,21 @@ class IterableIPShell:
except:
self.IP.showtraceback()
else:
- self.IP.input_splitter.push(line)
- self.iter_more = self.IP.input_splitter.push_accepts_more()
+ if self.no_input_splitter:
+ self.lines.append(self.IP.raw_input(self.prompt))
+ self.iter_more = self.IP.check_complete('\n'.join(self.lines))[0] == 'incomplete'
+ else:
+ self.IP.input_splitter.push(line)
+ self.iter_more = self.IP.input_splitter.push_accepts_more()
self.prompt = self.generatePrompt(self.iter_more)
if (self.IP.SyntaxTB.last_syntax_error and
self.IP.autoedit_syntax):
self.IP.edit_syntax_error()
if not self.iter_more:
- if parse_version(IPython.release.version) >= parse_version("2.0.0-dev"):
+ if self.no_input_splitter:
+ source_raw = '\n'.join(self.lines)
+ self.lines = []
+ elif parse_version(IPython.release.version) >= parse_version("2.0.0-dev"):
source_raw = self.IP.input_splitter.raw_reset()
else:
source_raw = self.IP.input_splitter.source_raw_reset()[1]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]