Skip to content

Commit

Permalink
Merge from 3.x: PR #4918
Browse files Browse the repository at this point in the history
Fixes #4873
  • Loading branch information
ccordoba12 committed Aug 10, 2017
2 parents bdc8eea + 41019da commit 65ac436
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
15 changes: 15 additions & 0 deletions spyder/plugins/tests/test_ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ def close_console():
#==============================================================================
# Tests
#==============================================================================
@flaky(max_runs=3)
def test_console_import_namespace(ipyconsole, qtbot):
"""Test an import of the form 'from foo import *'."""
# Wait until the window is fully up
shell = ipyconsole.get_current_shellwidget()
qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)

# Import numpy
with qtbot.waitSignal(shell.executed):
shell.execute('from numpy import *')

# Assert we get the e value correctly
assert shell.get_value('e') == 2.718281828459045


@flaky(max_runs=3)
def test_console_disambiguation(ipyconsole, qtbot):
"""Test the disambiguation of dedicated consoles."""
Expand Down
8 changes: 5 additions & 3 deletions spyder/utils/ipython/spyder_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def get_namespace_view(self):
settings = self.namespace_view_settings
if settings:
ns = self._get_current_namespace()
view = make_remote_view(ns, settings, EXCLUDED_NAMES)
view = repr(make_remote_view(ns, settings, EXCLUDED_NAMES))
return view
else:
return repr(None)

def get_var_properties(self):
"""
Expand All @@ -138,9 +140,9 @@ def get_var_properties(self):
'array_ndim': self._get_array_ndim(value)
}

return properties
return repr(properties)
else:
return {}
return repr(None)

def get_value(self, name):
"""Get the value of a variable"""
Expand Down
8 changes: 6 additions & 2 deletions spyder/widgets/ipythonconsole/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
mode and Spyder
"""

import ast

from qtpy.QtCore import Qt

from qtconsole.rich_jupyter_widget import RichJupyterWidget
Expand Down Expand Up @@ -52,10 +54,12 @@ def refresh_from_pdb(self, pdb_state):
self.sig_pdb_step.emit(fname, lineno)

if 'namespace_view' in pdb_state:
self.sig_namespace_view.emit(pdb_state['namespace_view'])
self.sig_namespace_view.emit(ast.literal_eval(
pdb_state['namespace_view']))

if 'var_properties' in pdb_state:
self.sig_var_properties.emit(pdb_state['var_properties'])
self.sig_var_properties.emit(ast.literal_eval(
pdb_state['var_properties']))

# ---- Private API (overrode by us) ----------------------------
def _handle_input_request(self, msg):
Expand Down
6 changes: 4 additions & 2 deletions spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,15 @@ def handle_exec_method(self, msg):
data = reply.get('data')
if 'get_namespace_view' in method:
if data is not None and 'text/plain' in data:
view = ast.literal_eval(data['text/plain'])
literal = ast.literal_eval(data['text/plain'])
view = ast.literal_eval(literal)
else:
view = None
self.sig_namespace_view.emit(view)
elif 'get_var_properties' in method:
if data is not None and 'text/plain' in data:
properties = ast.literal_eval(data['text/plain'])
literal = ast.literal_eval(data['text/plain'])
properties = ast.literal_eval(literal)
else:
properties = None
self.sig_var_properties.emit(properties)
Expand Down

0 comments on commit 65ac436

Please sign in to comment.