Skip to content

Commit 0dd01d5

Browse files
committed
Added compatibility fix for ipython 6.3.1
1 parent 5fe04de commit 0dd01d5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

psyplot_gui/fmt_widget.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import yaml
66
from functools import partial
77
from collections import defaultdict
8-
from itertools import chain, accumulate
8+
from itertools import chain
99
import logging
1010
from warnings import warn
1111
from IPython.core.interactiveshell import ExecutionResult
@@ -23,6 +23,11 @@
2323
import psyplot.plotter as psyp
2424
from psyplot.data import isstring
2525

26+
try:
27+
from IPython.core.interactiveshell import ExecutionInfo
28+
except ImportError:
29+
ExecutionInfo = None
30+
2631

2732
logger = logging.getLogger(__name__)
2833

@@ -539,9 +544,14 @@ def run_code(self):
539544
import psyplot.project as psy
540545
psy.gcp().update(**{key: yaml.load(text)})
541546
else:
542-
e = ExecutionResult()
543-
self.shell.run_code("psy.gcp().update(%s={'%s': %s})" % (
544-
param, key, text), e)
547+
code = "psy.gcp().update(%s={'%s': %s})" % (param, key, text)
548+
if ExecutionInfo is not None:
549+
info = ExecutionInfo(raw_cell=code, store_history=False,
550+
silent=True, shell_futures=False)
551+
e = ExecutionResult(info)
552+
else:
553+
e = ExecutionResult()
554+
self.shell.run_code(code, e)
545555
try:
546556
e.raise_error()
547557
except Exception: # reset the console and clear the error message

0 commit comments

Comments
 (0)