Repository: spyder-ide/spyder

Issue:
"%reset -s" is giving an error in the IPython console
## Description of your problem
When I type '%reset -s' to clear all the variables, instead it prints error message and does not clear all the variables. However, '%reset' works without any issue. Also, this only happens with spyder versions 3.0.0b7 or above. With 3.0.0b6 and below it works without any issue.

**What steps will reproduce the problem?**
The command %reset -s (and I choose y)
or just type %reset -sf (to force yes)

**What is the expected output? What do you see instead?**
Expected behavior is to clear all the variables.
Instead, below error message is printed in the Internal console, and the variables in the variable explorer are not cleared. Also, after this, any command in the IPython console prints the same error message, and new variables never display in the variable explorer.

>>> Traceback (most recent call last):
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\qtconsole\base_frontend_mixin.py", line 163, in _dispatch
Traceback (most recent call last):
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\qtconsole\base_frontend_mixin.py", line 163, in _dispatch
    handler(msg)
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\spyder\widgets\ipythonconsole\namespacebrowser.py", line 188, in _handle_execute_reply
    self.handle_exec_method(msg)
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 227, in handle_exec_method
    properties = ast.literal_eval(data['text/plain'])
TypeError: 'NoneType' object is not subscriptable
    handler(msg)
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\spyder\widgets\ipythonconsole\namespacebrowser.py", line 188, in _handle_execute_reply
    self.handle_exec_method(msg)
  File "c:\winpython-64bit-3.5.2.2\python-3.5.2.amd64\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 224, in handle_exec_method
    view = ast.literal_eval(data['text/plain'])
TypeError: 'NoneType' object is not subscriptable



**Please provide any additional information below**
However, '%reset' works without any issue.
Also, this only happens with spyder versions 3.0.0b7 or above. With 3.0.0b6 and below it works without any issue.


## Versions and main components

Spyder Version: 3.0.1
Python Version: 3.5.2
Operating system: Windows 7 64-Bit
IPython: 5.1.0


## Dependencies

Please go to the menu entry `Help > Optional Dependencies` (or
`Help > Dependencies`), press the button `Copy to clipboard`
and paste the contents below:
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.2 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.6.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.4.8 (OK)
sympy >=0.7.3    :  1.0 (OK)




Discussion:
The same error happens also if run "get_ipython().magic('reset -sf')", both in the console and within a script.

Thanks, we'll fix this error in Spyder 3.0.2 :-)


Resolving patch:
diff --git a/spyder/widgets/ipythonconsole/shell.py b/spyder/widgets/ipythonconsole/shell.py
--- a/spyder/widgets/ipythonconsole/shell.py
+++ b/spyder/widgets/ipythonconsole/shell.py
@@ -233,7 +233,7 @@ def handle_exec_method(self, msg):
                 reply = user_exp[expression]
                 data = reply.get('data')
                 if 'get_namespace_view' in method:
-                    if 'text/plain' in data:
+                    if data is not None and 'text/plain' in data:
                         view = ast.literal_eval(data['text/plain'])
                         self.sig_namespace_view.emit(view)
                     else:


Test patch: