Repository: spyder-ide/spyder

Issue:
Spyder crashes after creating a new file from Project/File Explorer
## Description

**What steps will reproduce the problem?**
1. In the Project explorer or File explorer, right click to pop up the context menu, and then select menu "New -> File...". 
2. In the "New file" dialog, input the file name and click the Save button.
3. The new file is saved to the disk, and immediately Spyder crashes, with the following error log:

> Traceback (most recent call last):
>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/app/spyder.py", line 2536, in open_file
>     self.variableexplorer.import_data(fname)
>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/plugins/variableexplorer.py", line 169, in import_data
>     nsb.import_data(filename=fname)
> TypeError: import_data() got an unexpected keyword argument 'filename'
> Abort trap: 6

**What is the expected output? What do you see instead?**

**Please provide any additional information below**
This is the latest dev version on May 26.
## Version and main components
- Spyder Version: 3.0.0dev 
- Python Version: 2.7.11
- Qt Versions: 5.5.1, PyQt5 5.5.1 on Darwin
## Dependencies

```
pyflakes >=0.5.0:  1.0.0 (OK)
pep8 >=0.6      :  1.7.0 (OK)
pygments >=1.6  :  2.1 (OK)
qtconsole >=4.0 :  4.1.1 (OK)
nbconvert >=4.0 :  4.1.0 (OK)
pandas >=0.13.1 :  0.17.1 (OK)
numpy >=1.7     :  1.11.0 (OK)
sphinx >=0.6.6  :  1.3.3 (OK)
rope >=0.9.4    :  0.9.4-1 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
psutil >=0.3    :  3.4.2 (OK)
matplotlib >=1.0:  1.5.1 (OK)
sympy >=0.7.3   :  0.7.6.1 (OK)
pylint >=0.25   :  1.5.2 (OK)

```

Spyder crashes after creating a new file from Project/File Explorer
## Description

**What steps will reproduce the problem?**
1. In the Project explorer or File explorer, right click to pop up the context menu, and then select menu "New -> File...". 
2. In the "New file" dialog, input the file name and click the Save button.
3. The new file is saved to the disk, and immediately Spyder crashes, with the following error log:

> Traceback (most recent call last):
>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/app/spyder.py", line 2536, in open_file
>     self.variableexplorer.import_data(fname)
>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/plugins/variableexplorer.py", line 169, in import_data
>     nsb.import_data(filename=fname)
> TypeError: import_data() got an unexpected keyword argument 'filename'
> Abort trap: 6

**What is the expected output? What do you see instead?**

**Please provide any additional information below**
This is the latest dev version on May 26.
## Version and main components
- Spyder Version: 3.0.0dev 
- Python Version: 2.7.11
- Qt Versions: 5.5.1, PyQt5 5.5.1 on Darwin
## Dependencies

```
pyflakes >=0.5.0:  1.0.0 (OK)
pep8 >=0.6      :  1.7.0 (OK)
pygments >=1.6  :  2.1 (OK)
qtconsole >=4.0 :  4.1.1 (OK)
nbconvert >=4.0 :  4.1.0 (OK)
pandas >=0.13.1 :  0.17.1 (OK)
numpy >=1.7     :  1.11.0 (OK)
sphinx >=0.6.6  :  1.3.3 (OK)
rope >=0.9.4    :  0.9.4-1 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
psutil >=0.3    :  3.4.2 (OK)
matplotlib >=1.0:  1.5.1 (OK)
sympy >=0.7.3   :  0.7.6.1 (OK)
pylint >=0.25   :  1.5.2 (OK)

```

Spyder crashes after deleting a folder in File explorer
## Description

**What steps will reproduce the problem?**
1. In the File explorer, right click on a folder. In the popped up menu, select "Delete..." and click "Yes" button in the next confirmation dialog.
2. The folder is deleted, and immediately Spyder crashes, with the following error log:

>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/widgets/explorer.py", line 515, in delete
>     yes_to_all = self.delete_file(fname, multiple, yes_to_all)
>   File "/Users/shenggao/anaconda/lib/python2.7/site-packages/spyderlib/widgets/explorer.py", line 497, in delete_file
>     self.parent_widget.removed_tree.emit(fname)
> AttributeError: 'Explorer' object has no attribute 'removed_tree'
> Abort trap: 6

**What is the expected output? What do you see instead?**

**Please provide any additional information below**

This is the latest dev version on May 26.
## Version and main components
- Spyder Version: 3.0.0dev 
- Python Version: 2.7.11
- Qt Versions: 5.5.1, PyQt5 5.5.1 on Darwin
## Dependencies

```
pyflakes >=0.5.0:  1.0.0 (OK)
pep8 >=0.6      :  1.7.0 (OK)
pygments >=1.6  :  2.1 (OK)
qtconsole >=4.0 :  4.1.1 (OK)
nbconvert >=4.0 :  4.1.0 (OK)
pandas >=0.13.1 :  0.17.1 (OK)
numpy >=1.7     :  1.11.0 (OK)
sphinx >=0.6.6  :  1.3.3 (OK)
rope >=0.9.4    :  0.9.4-1 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
psutil >=0.3    :  3.4.2 (OK)
matplotlib >=1.0:  1.5.1 (OK)
sympy >=0.7.3   :  0.7.6.1 (OK)
pylint >=0.25   :  1.5.2 (OK)

```



Discussion:

Resolving patch:
diff --git a/spyderlib/plugins/editor.py b/spyderlib/plugins/editor.py
--- a/spyderlib/plugins/editor.py
+++ b/spyderlib/plugins/editor.py
@@ -1521,7 +1521,7 @@ def _clone_file_everywhere(self, finfo):
             editor = editorstack.clone_editor_from(finfo, set_current=False)
             self.register_widget_shortcuts("Editor", editor)
     
-    @Slot()
+#    @Slot(str)
     def new(self, fname=None, editorstack=None, text=None):
         """
         Create a new file - Untitled
@@ -1842,7 +1842,7 @@ def removed_tree(self, dirname):
         dirname = osp.abspath(to_text_string(dirname))
         for fname in self.get_filenames():
             if osp.abspath(fname).startswith(dirname):
-                self.__close(fname)
+                self.close_file_from_name(fname)
     
     def renamed(self, source, dest):
         """File was renamed in file explorer widget or in project explorer"""
diff --git a/spyderlib/plugins/explorer.py b/spyderlib/plugins/explorer.py
--- a/spyderlib/plugins/explorer.py
+++ b/spyderlib/plugins/explorer.py
@@ -31,6 +31,7 @@ class Explorer(ExplorerWidget, SpyderPluginMixin):
     open_interpreter = Signal(str)
     edit = Signal(str)
     removed = Signal(str)
+    removed_tree = Signal(str)
     renamed = Signal(str, str)
     create_module = Signal(str)
     run = Signal(str)
@@ -67,6 +68,7 @@ def register_plugin(self):
         self.main.add_dockwidget(self)
         self.edit.connect(self.main.editor.load)
         self.removed.connect(self.main.editor.removed)
+        self.removed_tree.connect(self.main.editor.removed_tree)
         self.renamed.connect(self.main.editor.renamed)
         self.main.editor.open_dir.connect(self.chdir)
         self.create_module.connect(self.main.editor.new)
diff --git a/spyderlib/plugins/variableexplorer.py b/spyderlib/plugins/variableexplorer.py
--- a/spyderlib/plugins/variableexplorer.py
+++ b/spyderlib/plugins/variableexplorer.py
@@ -166,7 +166,7 @@ def import_data(self, fname):
         if self.count():
             nsb = self.current_widget()
             nsb.refresh_table()
-            nsb.import_data(filename=fname)
+            nsb.import_data(filenames=fname)
             if self.dockwidget and not self.ismaximized:
                 self.dockwidget.setVisible(True)
                 self.dockwidget.raise_()


Test patch: