internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spyder-ide/spyder

Issue:
Code completion raise exception when the editor widget is floating
I'm using dual monitor and the editor widget is floating so I can put it in another monitor.
When the editor widget is floating, the code completion  will raise an exception

```
Traceback (most recent call last):
File "d:\spyder\spyderlib\utils\introspection\plugin_manager.py", line 402, in _introspection_complete
  self._handle_pending()
File "d:\spyder\spyderlib\utils\introspection\plugin_manager.py", line 356, in _handle_pending
  self._post_message('')
File "d:\spyder\spyderlib\utils\introspection\plugin_manager.py", line 480, in _post_message
    try:
AttributeError: 'SpyderDockWidget' object has no attribute 'statusBar'
```



Discussion:
@blink1073, this is for you :-)


Resolving patch:
diff --git a/spyderlib/utils/introspection/plugin_manager.py b/spyderlib/utils/introspection/plugin_manager.py
--- a/spyderlib/utils/introspection/plugin_manager.py
+++ b/spyderlib/utils/introspection/plugin_manager.py
@@ -477,9 +477,12 @@ def _post_message(self, message, timeout=60000):
         Post a message to the main window status bar with a timeout in ms
         """
         if self.editor_widget:
-            statusbar = self.editor_widget.window().statusBar()
-            statusbar.showMessage(message, timeout)
-            QApplication.processEvents()
+            try:
+                statusbar = self.editor_widget.window().statusBar()
+                statusbar.showMessage(message, timeout)
+                QApplication.processEvents()
+            except AttributeError:
+                pass
 
 
 def memoize(obj):


Test patch:
Repository: spyder-ide/spyder

Issue:
Exception on autocomplete in the internal console
## Description
- _What steps will reproduce the problem?_
1. Press `Ctrl+Esc` in the internal console without any text
- _What is the expected output? What do you see instead?_
  This traceback shows up:

```
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/internalshell.py", line 348, in keyPressEvent
    self.postprocess_keyevent(event)
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/shell.py", line 744, in postprocess_keyevent
    ShellBaseWidget.postprocess_keyevent(self, event)
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/shell.py", line 375, in postprocess_keyevent
    self._key_ctrl_space()
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/shell.py", line 781, in _key_ctrl_space
    self.show_code_completion(automatic=False)
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/shell.py", line 909, in show_code_completion
    obj_dir = self.get_dir(last_obj)
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/internalshell.py", line 419, in get_dir
    obj, valid = self._eval(objtxt)
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/internalshell.py", line 415, in _eval
    return self.interpreter.eval(text)
  File "/usr/lib/python3.4/site-packages/spyderlib/interpreter.py", line 305, in eval
    assert is_text_string(text)
AssertionError
```
- _Please provide any additional information below_
## Version and main components
- Spyder Version:  3.0.0dev 
- Python Version:  3.4.3
- Qt Version    :  4.8.6, PyQt4 (API v2) 4.11.3 on Linux
## Optional dependencies

pyflakes >=0.6.0:  0.8.1 (OK)
pep8 >=0.6      :  1.6.2 (OK)
pygments >=1.6  :  2.0.2 (OK)
IPython >=3.0   :  3.1.0 (OK)
zmq >=13.0.0    :  14.5.0 (OK)
pandas >=0.13.1 :  0.16.0 (OK)
sphinx >=0.6.6  :  1.2.3 (OK)
psutil >=0.3    :  2.2.1 (OK)
rope >=0.9.2    :  0.9.4-1 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
matplotlib >=1.0:  1.4.3 (OK)
sympy >=0.7.3   :  None (NOK)
pylint >=0.25   :  1.4.3 (OK)



Discussion:

Resolving patch:
diff --git a/spyderlib/widgets/shell.py b/spyderlib/widgets/shell.py
--- a/spyderlib/widgets/shell.py
+++ b/spyderlib/widgets/shell.py
@@ -884,6 +884,9 @@ def show_code_completion(self, automatic):
         text = to_text_string(self.get_current_line_to_cursor())
         last_obj = self.get_last_obj()
         
+        if not text:
+            return
+
         if text.startswith('import '):
             obj_list = self.get_module_completion(text)
             words = text.split(' ')


Test patch:
Repository: spyder-ide/spyder

Issue:
Context menu for tabs in editor should allow "close all but this" and "close all to the right"
Similar to Chrome and Sublime Text, this is very useful after working on many files at the same time and needing to clean house!



Discussion:

Resolving patch:
diff --git a/spyderlib/widgets/editor.py b/spyderlib/widgets/editor.py
--- a/spyderlib/widgets/editor.py
+++ b/spyderlib/widgets/editor.py
@@ -345,8 +345,16 @@ def __init__(self, parent, actions):
                 icon=ima.icon('editcopy'),
                 triggered=lambda:
                 QApplication.clipboard().setText(self.get_current_filename()))
+
+        close_right = create_action(self, _("Close all to the right"), 
+                    icon=ima.icon('filelist'),
+                    triggered=self.close_all_right)
+        close_all_but_this = create_action(self, _("Close all but this"), 
+                    icon=ima.icon('filelist'),
+                    triggered=self.close_all_but_this)
+
         self.menu_actions = actions + [None, fileswitcher_action,
-                                       copy_to_cb_action]
+                                       copy_to_cb_action, None, close_right, close_all_but_this]
         self.outlineexplorer = None
         self.inspector = None
         self.unregister_callback = None
@@ -1131,6 +1139,18 @@ def close_all_files(self):
         while self.close_file():
             pass
 
+    def close_all_right(self):
+        """ Close all files opened to the right """
+        num = self.get_stack_index()
+        n = self.get_stack_count()
+        for i in range(num, n-1):
+            self.close_file(num+1)
+    
+    def close_all_but_this(self):
+        """Close all files but the current one"""
+        self.close_all_right()
+        for i in range(0, self.get_stack_count()-1  ):
+            self.close_file(0)
 
     #------ Save
     def save_if_changed(self, cancelable=False, index=None):
diff --git a/spyderlib/widgets/tabs.py b/spyderlib/widgets/tabs.py
--- a/spyderlib/widgets/tabs.py
+++ b/spyderlib/widgets/tabs.py
@@ -218,6 +218,7 @@ def add_corner_widgets(self, widgets, corner=Qt.TopRightCorner):
         
     def contextMenuEvent(self, event):
         """Override Qt method"""
+        self.setCurrentIndex(self.tabBar().tabAt(event.pos()))
         if self.menu:
             self.menu.popup(event.globalPos())
             


Test patch:
Repository: spyder-ide/spyder

Issue:
fontawesome.ttf not found
I installed it normally via setuup.py.

After selecting the Spyder 3 icon theme, it crashes on start:

``` pytb
Traceback (most recent call last):
  File "/usr/bin/spyder3", line 3, in <module>
    start_app.main()
  File "/usr/lib/python3.4/site-packages/spyderlib/start_app.py", line 119, in main
    from spyderlib import spyder
  File "/usr/lib/python3.4/site-packages/spyderlib/spyder.py", line 146, in <module>
    from spyderlib.utils.environ import WinUserEnvDialog
  File "/usr/lib/python3.4/site-packages/spyderlib/utils/environ.py", line 18, in <module>
    from spyderlib.widgets.dicteditor import DictEditor
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/dicteditor.py", line 1236, in <module>
    class DictEditor(QDialog):
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/dicteditor.py", line 1251, in DictEditor
    icon=ima.icon('dictedit'), remote=False, parent=None):
  File "/usr/lib/python3.4/site-packages/spyderlib/utils/icon_manager.py", line 233, in icon
    qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=_resource['directory'])
  File "/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/__init__.py", line 26, in load_font
    return _instance().load_font(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/__init__.py", line 17, in _instance
    ('ei', 'elusiveicons-webfont.ttf', 'elusiveicons-webfont-charmap.json'))
  File "/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/iconic_font.py", line 124, in __init__
    self.load_font(*fargs)
  File "/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/iconic_font.py", line 153, in load_font
    with open(os.path.join(directory, ttf_filename), 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/fonts/fontawesome-4.3.0.ttf'
```

and indeed, `/usr/lib/python3.4/site-packages/spyderlib/external/qtawesome/` only contains the json files.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -212,7 +212,7 @@ def get_packages():
 else:
     SCRIPTS.append('spyder')
 EXTLIST = ['.mo', '.svg', '.png', '.css', '.html', '.js', '.chm', '.ini',
-           '.txt', '.rst', '.qss', '.tff', '.json']
+           '.txt', '.rst', '.qss', '.ttf', '.json']
 if os.name == 'nt':
     SCRIPTS += ['spyder.bat']
     EXTLIST += ['.ico']


Test patch:
Repository: spyder-ide/spyder

Issue:
Autoparens appear when autocompleting in the import section
Autoparens is a great addition, but it should not be applied everywhere, such as whem importing something....

For example if I have this and then press `Tab` in this case (\* denotes cursor location)

``` python
from spyderlib.qt.QtGui import QToolButton, QToolT*
```

We get

``` python
from spyderlib.qt.QtGui import QToolButton, QToolTip()
```

Which is not very helpful....

Any thoughts @blink1073?



Discussion:
Hmm, that's a tricky one.  What if we only apply it if there is an `=` sign in the line?

I would rather make some helper function in the order of...

`is_import_statement()`

So you would know you are inside an import statement..?

This would be very useful for other cases, like auto formatting import statements

I'm not sure how to do that for import continuation lines like:

``` python
from IPython import (
   blah, blah2, blah3
```

can we do a lookup of the `import` word in the previous lines?

Oh, duh, we're already checking for imports, this is actually simple then.

—
Sent from Mailbox

On Sun, Aug 2, 2015 at 6:37 PM, Gonzalo Peña-Castellanos
notifications@github.com wrote:

> ## can we do a lookup of the `import` word in the previous lines?
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/spyder-ide/spyder/issues/2581#issuecomment-127083934

:+1:


Resolving patch:
diff --git a/spyderlib/widgets/sourcecode/base.py b/spyderlib/widgets/sourcecode/base.py
--- a/spyderlib/widgets/sourcecode/base.py
+++ b/spyderlib/widgets/sourcecode/base.py
@@ -67,13 +67,6 @@ def show_list(self, completion_list, automatic=True):
         completion_list = [c[0] for c in completion_list]
         if len(completion_list) == 1 and not automatic:
             self.textedit.insert_completion(completion_list[0])
-            try:
-                if self.textedit.close_parentheses_enabled:
-                    if types[0] in ['class', 'function', 'method']:
-                        self.textedit.handle_close_parentheses('')
-            except AttributeError:
-                pass
-            return
 
         self.completion_list = completion_list
         self.clear()
@@ -162,14 +155,6 @@ def keyPressEvent(self, event):
         if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
            or key == Qt.Key_Tab:
             self.item_selected()
-            if self.type_list[self.currentRow()] not in ['class', 'function',
-                                                         'method']:
-                return
-            try:
-                if self.textedit.close_parentheses_enabled:
-                    self.textedit.handle_close_parentheses('')
-            except AttributeError:
-                pass
         elif key in (Qt.Key_Return, Qt.Key_Enter,
                      Qt.Key_Left, Qt.Key_Right) or text in ('.', ':'):
             self.hide()


Test patch:
Repository: spyder-ide/spyder

Issue:
Call tips and auto completion tips go out of screen on a second monitor
![1](https://cloud.githubusercontent.com/assets/13564252/9120711/ec261c9e-3c4b-11e5-963d-38a58a399936.png)
![2](https://cloud.githubusercontent.com/assets/13564252/9120712/ec29b304-3c4b-11e5-9dc8-9898002f4abb.png)
I have two monitors and it only happens when the window is in the second monitor. 



Discussion:
I don't know how Qt handle other monitors. Seems tricky to fix.

@ccordoba12 I tried to fix it but I can not even found where the call tips is handled. It seems they are handled in https://github.com/spyder-ide/spyder/blob/df0b2ec50e3981c7157592eaec2b866f1c9c6b86/spyderlib/widgets/calltip.py#L194?
But nothing is printed after I added print(screen_rect) or debug_print(screen_rect). I tried to raise an Exception() here and nothing happened.
What is the proper way to print some debug information when developing spyder? And do you know where the call tips is handled?
Did I missed something and the call tips is actually handled there but my modification is not effective?

All `print`'s are redirected to the Internal console, so please take a look there.

@cy18 Inside Spyder go to `View` menu `panes` and then `Internal console`


Resolving patch:
diff --git a/spyderlib/widgets/calltip.py b/spyderlib/widgets/calltip.py
--- a/spyderlib/widgets/calltip.py
+++ b/spyderlib/widgets/calltip.py
@@ -198,7 +198,7 @@ def show_tip(self, point, tip, wrapped_tiplines):
 
         vertical = 'bottom'
         horizontal = 'Right'
-        if point.y() + tip_height > screen_rect.height():
+        if point.y() + tip_height > screen_rect.height() + screen_rect.y():
             point_ = text_edit.mapToGlobal(cursor_rect.topRight())
             # If tip is still off screen, check if point is in top or bottom
             # half of screen.
@@ -211,7 +211,7 @@ def show_tip(self, point, tip, wrapped_tiplines):
                     vertical = 'top'
             else:
                 vertical = 'top'
-        if point.x() + tip_width > screen_rect.width():
+        if point.x() + tip_width > screen_rect.width() + screen_rect.x():
             point_ = text_edit.mapToGlobal(cursor_rect.topRight())
             # If tip is still off-screen, check if point is in the right or
             # left half of the screen.


Test patch:
Repository: spyder-ide/spyder

Issue:
PySide can not be used on 2.3.6
If PyQt4 is not installed, `sip` is also unavailable, so import fails earlier that a try/except block that sets PySide as a fallback.

PySide can not be used on 2.3.6
If PyQt4 is not installed, `sip` is also unavailable, so import fails earlier that a try/except block that sets PySide as a fallback.



Discussion:

Resolving patch:
diff --git a/spyderlib/qt/__init__.py b/spyderlib/qt/__init__.py
--- a/spyderlib/qt/__init__.py
+++ b/spyderlib/qt/__init__.py
@@ -16,21 +16,21 @@
 
 if API == 'pyqt':
     # Since Spyder 2.3.6 we only support API #2
-    import sip
-    try:
-        sip.setapi('QString', 2)
-        sip.setapi('QVariant', 2)
-        sip.setapi('QDate', 2)
-        sip.setapi('QDateTime', 2)
-        sip.setapi('QTextStream', 2)
-        sip.setapi('QTime', 2)
-        sip.setapi('QUrl', 2)
-    except AttributeError:
-        pass
-
     try:
+        import sip
+        try:
+            sip.setapi('QString', 2)
+            sip.setapi('QVariant', 2)
+            sip.setapi('QDate', 2)
+            sip.setapi('QDateTime', 2)
+            sip.setapi('QTextStream', 2)
+            sip.setapi('QTime', 2)
+            sip.setapi('QUrl', 2)
+        except AttributeError:
+            pass
+        
         from PyQt4.QtCore import PYQT_VERSION_STR as __version__
-    except ImportError:
+    except ImportError: # May fail on sip or on PyQt4 import
         # Switching to PySide
         API = os.environ['QT_API'] = 'pyside'
         API_NAME = 'PySide'


Test patch:
Repository: spyder-ide/spyder

Issue:
Autocomplete does not insert correct word when requested with Ctrl+Space
To reproduce: in a python editor, start typing something and when the word is long enough so that there should be only one auto-complete suggestion, invoke it with <kbd>Ctrl</kbd>+<kbd>Space</kbd>. For example, type `enume` and invoke the auto-completion. Because there is only one suggestion, the word is automatically completed. However the auto-complete menu opens anyway, and if I press <kbd>Enter</kbd> to validate and close it, the word is replaced with one where the beginning of the word is repeated. For example, in the case of `enumerate`, it is replaced with `enumenumerate`.

This does NOT happen when there is more than one auto-complete suggestion or when the auto-complete is automatically triggered when typing a dot, even if there is a single suggestion. In both these cases, the word is not automatically completed and pressing <kbd>Enter</kbd> correctly finishes the word.

Also, the problem occurs in latest Spyder 3.0.0dev, but not in the stable release that I have (2.2.5). In 2.2.5, the auto-complete menu does not open and the word is automatically completed to the single suggestion, which is I think the correct behavior (this is also what Eclipse does if I remember correctly). So it seems to be a regression. Will happily help fix it if given pointers.



Discussion:
@blink1073, this one seems for you :-)

Yes I have noticed this behavior and I can confirm, please @blink1073 take a look :-p


Resolving patch:
diff --git a/spyderlib/widgets/sourcecode/base.py b/spyderlib/widgets/sourcecode/base.py
--- a/spyderlib/widgets/sourcecode/base.py
+++ b/spyderlib/widgets/sourcecode/base.py
@@ -67,6 +67,7 @@ def show_list(self, completion_list, automatic=True):
         completion_list = [c[0] for c in completion_list]
         if len(completion_list) == 1 and not automatic:
             self.textedit.insert_completion(completion_list[0])
+            return
 
         self.completion_list = completion_list
         self.clear()


Test patch:
Repository: spyder-ide/spyder

Issue:
Cannot change between UI tabs on OSX
## Description

**What steps will reproduce the problem?**
1. Start Spyder via python bootstrap.py
2. Try to change between Console, History Log, IPython Console, Object Inspector, Variable Explorer, etc.
3. The tab selectors now look like this:  
   ![image](https://cloud.githubusercontent.com/assets/12973799/9127414/9b1b2ef6-3c88-11e5-87e4-1e9523b6b623.png)  
   ...and the tabs have not changed state.
4. If I change to a different app, and then change back to Spyder, the originally-selected tab and the last-selected tab will be highlighted, like so (IPython console tab initially selected, then clicked on Console, and then History log):  
   ![image](https://cloud.githubusercontent.com/assets/12973799/9127433/fad33172-3c88-11e5-8462-931b214fe2d3.png)  
   But the UI is still showing the IPython console tab.

I can get a particular tab to show up if I first hide the pane and then make it visible again via the View > Panes menu items.
## Version and main components
- Spyder Version: 3.0.0b1 
- Python Version: 2.7.10
- Qt Versions: 4.8.6, PyQt4 (API v2) 4.11.3 on Darwin
## Optional dependencies

```
pyflakes >=0.5.0:  0.9.2 (OK)
pep8 >=0.6      :  1.6.2 (OK)
pygments >=1.6  :  2.0.2 (OK)
IPython >=3.0   :  3.2.0 (OK)
zmq >=13.0.0    :  14.7.0 (OK)
pandas >=0.13.1 :  0.16.2 (OK)
sphinx >=0.6.6  :  1.3.1 (OK)
psutil >=0.3    :  2.2.1 (OK)
rope >=0.9.4    :  0.9.4 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
matplotlib >=1.0:  1.4.3 (OK)
sympy >=0.7.3   :  0.7.6 (OK)
pylint >=0.25   :  None (NOK)

```



Discussion:
I see the same thing.  @goanpeca:

``` bash
 $ git bisect bad
e042cfc9a153baa91101f41aa52ff4cb1c6dee4f is the first bad commit
commit e042cfc9a153baa91101f41aa52ff4cb1c6dee4f
Author: Gonzalo Peña <goanpeca@gmail.com>
Date:   Sun Apr 26 23:08:33 2015 +0200

    Add drag support for dockwidgets sharing same position

:040000 040000 86292e5630d8b9371a6d8ce2cb9595fe376b9a9d 468580d4e3247fd8eede540d113a524c7dacc622 M  spyderlib
```

Hmmm ... I need a mac! :s 

I thought that was the case too. @goanpeca, this needs to be fixed for beta2.


Resolving patch:
diff --git a/spyderlib/plugins/__init__.py b/spyderlib/plugins/__init__.py
--- a/spyderlib/plugins/__init__.py
+++ b/spyderlib/plugins/__init__.py
@@ -131,6 +131,7 @@ def eventFilter(self,  obj,  event):
     def tab_pressed(self, event):
         """Method called when a tab from a QTabBar has been pressed."""
         self.from_index = self.dock_tabbar.tabAt(event.pos())
+        self.dock_tabbar.setCurrentIndex(self.from_index)
 
         if event.button() == Qt.RightButton:
             if self.from_index == -1:


Test patch:
Repository: spyder-ide/spyder

Issue:
Profiler config does not carry command line arguments correctly
Currently their is no run configuration for the profiler. Issue #1110 was opened to request it and indeed it would be nice. In the meanwhile, from what I can see the profiler uses the Run config associated with the file. Indeed if I add command line options in the run config and start the profiler, the options are used. But there seem to be a bug in this mechanism. To reproduce:
1. Create or open a file that parses the command line but accepts an empty one. For example:
   
   ```
   parser = argparse.ArgumentParser()
   parser.add_argument('--opt', dest='optionalarg')
   args = parser.parse_args()
   ```
   
   Profile it without giving command line options to make sure it's fine.
2. Create or open another file that also parses the command line. Profile it **with** command line options that the first file would **not** accept.
3. Come back to the first file, and profile it with <kbd>F10</kbd>

Expected behaviour: The file should be profiled with the options used during the first profiling (i.e. no option) .
Actual behaviour: It is run with the command line options that were given to the second file. If using my example, the argument parser will tell you that it encountered an unknown argument. 

To workaround it, I have to open the Run config, put some command line arguments (even if don't want any), run the file, re-open the config, remove the arguments, and that's only when the file will be run as expected.



Discussion:

Resolving patch:
diff --git a/spyderplugins/p_profiler.py b/spyderplugins/p_profiler.py
--- a/spyderplugins/p_profiler.py
+++ b/spyderplugins/p_profiler.py
@@ -130,7 +130,7 @@ def analyze(self, filename):
             self.dockwidget.raise_()
         pythonpath = self.main.get_spyder_pythonpath()
         runconf = runconfig.get_run_configuration(filename)
-        wdir, args = None, None
+        wdir, args = None, []
         if runconf is not None:
             if runconf.wdir_enabled:
                 wdir = runconf.wdir


Test patch: