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

Issue:
Cycle tabs via Ctrl-PageUp/PageDown
_From [minzas...@gmail.com](https://code.google.com/u/100341682938742242760/) on 2014-03-04T06:21:23Z_

Ctrl+Tab cycles through tabs, while Ctrl+PageUp/PageDown stops at last/first tab. This patch changes the behavior: when Ctrl+PageUp is pressed on the last tab, it moves to the first tab, and vice versa.

**Attachment:** [cycle_tabs.patch](http://code.google.com/p/spyderlib/issues/detail?id=1749)

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1749_



Discussion:
Related to this, Ctrl+(Shift+)Tab cycles through tabs in order of usage, while Ctrl+PageUp/PageDown cycles through tabs in order of appearance. Cycling through tabs in order of usage is not really useful it seems (you get apparently inexplicable jumps from one tab to another, until you realize it cycles in order of usage).

@vtraag, I disagree that the cycling is not intuitive.  Ideally, the tabs would automatically reorder to preserve "most-recentness", similar to what you get when you hit `Alt+Tab` for most recent processes.  However, I'd argue that most times people are toggling back and forth between two files, regardless of the order they were opened in.  For what its worth, we have the same behaviour as the Sublime Text editor.

Indeed I'm often switching between two files, and then it's useful. The problem starts when you are searching for another file among the ones you have open... Anyway, I'm now just resorting to Ctrl+PageUp/PageDown, which works fine for my purposes.

+1 to the patch.

> Ctrl+(Shift+)Tab cycles through tabs in order of usage [...] Cycling through tabs in order of usage is not really useful it seems

I think this _would_ be useful, but for me this also just cycles  in order of appearance (in Spyder 2.3.1 from WinPython-64bit-3.4.2.2.exe).

>  Ideally, the tabs would automatically reorder

No! Sometimes I want to define the order by myself, (see #564).

@jondo, by that I mean _ideally for me_.


Resolving patch:
diff --git a/spyderlib/widgets/tabs.py b/spyderlib/widgets/tabs.py
--- a/spyderlib/widgets/tabs.py
+++ b/spyderlib/widgets/tabs.py
@@ -229,11 +229,17 @@ def keyPressEvent(self, event):
         handled = False
         if ctrl and self.count() > 0:
             index = self.currentIndex()
-            if key == Qt.Key_PageUp and index > 0:
-                self.setCurrentIndex(index-1)
+            if key == Qt.Key_PageUp:
+                if index > 0:
+                    self.setCurrentIndex(index - 1)
+                else:
+                    self.setCurrentIndex(self.count() - 1)
                 handled = True
-            elif key == Qt.Key_PageDown and index < self.count()-1:
-                self.setCurrentIndex(index+1)
+            elif key == Qt.Key_PageDown:
+                if index < self.count() - 1:
+                    self.setCurrentIndex(index + 1)
+                else:
+                    self.setCurrentIndex(0)
                 handled = True
         if not handled:
             QTabWidget.keyPressEvent(self, event)


Test patch:
Repository: spyder-ide/spyder

Issue:
Spyder2.3.3 Code completion breaks
Hi everyone,

first of all, a big thank you for developing this great spyder IDE. It is by far my weapon of choice and I enjoyed diving into python a lot more thanks to it. 

Now to my problem, which I am assuming is on my machine, but I cannot figure it out so I hope you guys can help me:

I just installed spyder 2.3.3 on a fresh ubuntu trusty installation and also installed jedi and rope with pip.

However, when I try to use auto completion (e.g. for the module time) I get the following error message from the internal console:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spyderlib/utils/introspection/plugin_manager.py", line 58, in _handle_incoming
    self._threads[name].wait()
KeyError: PyQt4.QtCore.QString(u'rope')

I already tried to debug this error myself by adding basic "prints" in the file, but in my oppionion the key should be present. What I did find however was that I had to use the python3 print with the (). Is that something you forced, or does my system try to use python3 for some reason?

I hope this is the correct place to state such an individual problem and maybe someone can help me.

Edit: I just tried updating my spyder in my VM running Ubuntu precise and I get the same error. I installed spyder2.3.3 from source there since the pip installer would not work (threw the error:
error: option --single-version-externally-managed not recognized).

Am I missing something that I must do before code completion works?



Discussion:
Hi @BlackZ, can you try changing that line in the file to `self._threads[str(name)].wait()`?

Hi @blink1073, I just tested it and it seems to work when I add the str conversion to the following line (result=..) as well:

```
    self._threads[str(name)].wait()
    if self.result:
        return
    result = self._threads[str(name)].result
```

Thanks a lot! Is this a general bug or is something fishy with my python installation?

@blink1073 do you want to do a PR based on what @BlackZ reported?

Yep, forthcoming.


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
@@ -55,6 +55,8 @@ def _handle_timeout(self):
         self.waiting = False
 
     def _handle_incoming(self, name):
+        # coerce to a str in case it is a QString
+        name = str(name)
         self._threads[name].wait()
         if self.result:
             return
@@ -67,7 +69,7 @@ def _handle_incoming(self, name):
 
     def _make_async_call(self, plugin, info):
         """Trigger an introspection job in a thread"""
-        self._threads[plugin.name] = thread = IntrospectionThread(plugin, info)
+        self._threads[str(plugin.name)] = thread = IntrospectionThread(plugin, info)
         thread.request_handled.connect(self._handle_incoming)
         thread.start()
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Spyder crashing on very long output
Spyder Version:  2.3.0rc
Python Version:  3.4.0
Qt Version    :  4.8.6, PyQt4 (API v2) 4.10.4 on Linux
pyflakes >=0.6.0:  0.8.1 (OK)
pep8 >=0.6      :  1.4.6 (OK)
IPython >=0.13  :  None (NOK)
pygments >=1.6  :  1.6 (OK)
sphinx >=0.6.6  :  1.2.3 (OK)
psutil >=0.3    :  1.2.1 (OK)
rope >=0.9.2    :  0.9.3 (OK)
matplotlib >=1.0:  1.4.3 (OK)
pylint >=0.25   :  1.1.0 (OK)

What steps will reproduce the problem?
1. Run a script that produces very long output within a short timespan.
   (E.g. theanets do a lot of logging when learning – like hundreds of lines being written into the output all within a few seconds.)
2. Watch spyder crash.

The expected behaviour is not to crash, but display the output.

I am attaching the [trace](https://spyderlib.googlecode.com/issues/attachment?aid=21930000000&name=stacktrace&token=ABZ6GAeRpbBxnaLVvAe4Ss1cfNpmqaFz4Q%3A1426497266268) that gets printed upon the crash. A stack overflow of some sort seems to be going on.

Also – I can fix the problem by commenting out line 276 in spyderlib/widgets/externalshell/baseshell.py:

```
def write_output(self):
    self.shell.write(self.get_stdout(), flush=True)
    #QApplication.processEvents()
```

Is it really absolutely necessary to call processEvents on every write? I mean, surely the updates will get drawn in the next update of the GUI regardless of whether we do this.

I am attaching a [patch](https://spyderlib.googlecode.com/issues/attachment?aid=21930000001&name=spyder.patch&token=ABZ6GAdEJj-u0QrWiBMpGgH1et0FM1ykXw%3A1426497266268) which removes the line in case you may find the solution acceptable.



Discussion:
@michalgregor, thanks a lot for taking the time to post your issue report here. Unfortunately, your patch is unreadable because you changed the end-of-lines of `baseshell.py`, and so the patch is equivalent to the entire file! :-)

Could you open a pull request with your changes so that it is easier for us to review and merge it?

Besides, your links (i.e. _trace_ and _patch_) are giving 404 errors on Google Code. I'd suggest to post the traceback here (or as a gist, if it's too long) and remove the link to _patch_.


Resolving patch:
diff --git a/spyderlib/widgets/externalshell/baseshell.py b/spyderlib/widgets/externalshell/baseshell.py
--- a/spyderlib/widgets/externalshell/baseshell.py
+++ b/spyderlib/widgets/externalshell/baseshell.py
@@ -291,7 +291,6 @@ def get_stderr(self):
     
     def write_output(self):
         self.shell.write(self.get_stdout(), flush=True)
-        QApplication.processEvents()
         
     def send_to_process(self, qstr):
         raise NotImplementedError


Test patch:
Repository: spyder-ide/spyder

Issue:
Incorrect setting of Qt API n°2
Even when the API n°2 is selected some Qt objects still use the API n°1. I typically get this type of warning each time I run one of my program (which use the enaml library which sets those to API n°2) :

Warning/PyQt4-Spyder (API 'QDate' has already been set to version 1)
Warning/PyQt4-Spyder (API 'QDateTime' has already been set to version 1)
Warning/PyQt4-Spyder (API 'QTextStream' has already been set to version 1)
Warning/PyQt4-Spyder (API 'QTime' has already been set to version 1)
Warning/PyQt4-Spyder (API 'QUrl' has already been set to version 1)

As we can ignore the sip setapi errors and that my program actually does not use those it is fine but still not ideal
If anybody can point me to the where this is set in Spyder I will be happy to do a PR to fix that.



Discussion:
:+1: 

Is this happening in 2.3.4 or in master? Qt API 1 won't be supported since Spyder 3.0, and we are not going to release more bug fixes for 2.3.

So my recommendation would be to switch to master, and if you continue to see these errors, then we can see what we can do about them. Else, you should wait unitl 3.0 is released (hopefully in the summer :-)

I can confirm that this still happens into latest master.

Ok, I don't understand what can be happening in this case. So please give us a simple and reproducible example that we can use to test and fix this problem in our side.

I have the same problem. With a `grep setapi` I found:

```
spyderlib/qt/__init__.py:34:        sip.setapi('QString', 2)
spyderlib/qt/__init__.py:35:        sip.setapi('QVariant', 2)
```

There are other apis that are not set to version 2, see http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
The fix is very easy, it's only a matter of using `setapi` on missing values.


Resolving patch:
diff --git a/spyderlib/qt/__init__.py b/spyderlib/qt/__init__.py
--- a/spyderlib/qt/__init__.py
+++ b/spyderlib/qt/__init__.py
@@ -33,6 +33,11 @@
     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:
         # PyQt < v4.6. The actual check is done by requirements.check_qt()
         # call from spyder.py


Test patch:
Repository: spyder-ide/spyder

Issue:
Disable icons in menus on Mac OS X
Most OS X apps do not include icons in their menus. It would be nice to have an option to disable icons on Mac OS X (maybe this should even be the default behavior).



Discussion:
Hi @cle1109 can you post a couple of images of how spyder looks in your setup, and how other "normal" applications look? just to get the feeling of the issue?

Cheers

Sure! Here are some Spyder menus:

![spyder-mac-00](https://cloud.githubusercontent.com/assets/4377312/6915623/e0b8aa4a-d795-11e4-9dac-741d4e91bd61.jpg)
![spyder-mac-01](https://cloud.githubusercontent.com/assets/4377312/6915627/ebd0455a-d795-11e4-805a-2f6b0766b0ab.jpg)
![spyder-mac-02](https://cloud.githubusercontent.com/assets/4377312/6915631/f191566e-d795-11e4-89c5-73d79112b4ce.jpg)

Menus of real/native Mac applications look more like this:
![excel-mac-00](https://cloud.githubusercontent.com/assets/4377312/6915640/111476c4-d796-11e4-9494-fff2d5c687ac.jpg)
![excel-mac-01](https://cloud.githubusercontent.com/assets/4377312/6915641/141177c8-d796-11e4-8748-46bf91f14dab.jpg)
![finder-mac-00](https://cloud.githubusercontent.com/assets/4377312/6915645/171b052e-d796-11e4-9a6c-7acd167f898a.jpg)
![finder-mac-01](https://cloud.githubusercontent.com/assets/4377312/6915646/19ef7988-d796-11e4-92f3-3f9227a5419c.jpg)

Note that sometimes there are exceptions to the rule (last image, places actually do have icons in the menu), but I think Spyder would look best without icons.

Seems reasonable, what do you think @ccordoba12?

We just need to disable icons for menus on Mac, period :-) There is no need to add an option for this.

As @cle1109 rightly points out, icons in menus are not part of Mac applications at all, so we need to follow that convention too.

Good! 

since I do not work on a Mac (although I could make the PR) I think is better that someone with access to one takes this one, right? @cle1109 want to give it a try?


Resolving patch:
diff --git a/spyderlib/spyder.py b/spyderlib/spyder.py
--- a/spyderlib/spyder.py
+++ b/spyderlib/spyder.py
@@ -79,7 +79,7 @@
                                 QKeySequence, QDockWidget, QAction,
                                 QDesktopServices)
 from spyderlib.qt.QtCore import (Signal, QPoint, Qt, QSize, QByteArray, QUrl,
-                                 Slot, QTimer)
+                                 Slot, QTimer, QCoreApplication)
 from spyderlib.qt.compat import (from_qvariant, getopenfilename,
                                  getsavefilename)
 # Avoid a "Cannot mix incompatible Qt library" error on Windows platforms
@@ -2778,6 +2778,10 @@ def run_spyder(app, options, args):
         for a in args:
             main.open_external_file(a)
 
+    # Don't show icons in menus for Mac
+    if sys.platform == 'darwin':
+        QCoreApplication.setAttribute(Qt.AA_DontShowIconsInMenus, True)
+
     # Open external files with our Mac app
     if running_in_mac_app():
         app.sig_open_external_file.connect(main.open_external_file)


Test patch:
Repository: spyder-ide/spyder

Issue:
Object Inspector Text on Mac OS X is Misleading
On Mac OSX, the object inspector defaults to `Cmd+I`, but the default message still says: `Here you can get help of any object by pressing Ctrl+I in front of it, either on the Editor or the Console.`.  I could not figure out where this text is located.



Discussion:

Resolving patch:
diff --git a/spyderlib/plugins/inspector.py b/spyderlib/plugins/inspector.py
--- a/spyderlib/plugins/inspector.py
+++ b/spyderlib/plugins/inspector.py
@@ -743,11 +743,16 @@ def show_intro_message(self):
                           "a left parenthesis next to an object. You can "
                           "activate this behavior in %s.")
         prefs = _("Preferences > Object Inspector")
+        if sys.platform == 'darwin':
+            shortcut = "Cmd+I"
+        else:
+            shortcut = "Ctrl+I"
+
         if self.is_rich_text_mode():
             title = _("Usage")
             tutorial_message = _("New to Spyder? Read our")
             tutorial = _("tutorial")
-            intro_message = intro_message % ("<b>Ctrl+I</b>", "<br><br>",
+            intro_message = intro_message % ("<b>"+shortcut+"</b>", "<br><br>",
                                              "<i>"+prefs+"</i>")
             self.set_rich_text_html(usage(title, intro_message,
                                           tutorial_message, tutorial),
@@ -756,7 +761,7 @@ def show_intro_message(self):
             install_sphinx = "\n\n%s" % _("Please consider installing Sphinx "
                                           "to get documentation rendered in "
                                           "rich text.")
-            intro_message = intro_message % ("Ctrl+I", "\n\n", prefs)
+            intro_message = intro_message % (shortcut, "\n\n", prefs)
             intro_message += install_sphinx
             self.set_plain_text(intro_message, is_code=False)
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Editor: Move suggested completion item to top of window
_From [w0run.go...@gmail.com](https://code.google.com/u/106279936266297459333/) on 2014-07-01T16:19:46Z_

If I type

import pylab as py

Then, when I type:
  py.s 

then the flying window comes up and shows "py.s_" at the bottom of the window- all other "py.s" offerings are out of sight below the window. It would be much better to have the first matching item at the top of the window, so the others can be seen below. I looked through the editor preferences, and this did not seem to be one of them.

Using Spyder 2.30.rc with Anaconda.

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1876_



Discussion:
_From [ccordoba12](https://code.google.com/u/ccordoba12/) on 2014-11-18T18:04:10Z_

Good suggestion.

**Labels:** Cat-CodeCompletion MS-v2.4  


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
@@ -19,7 +19,7 @@
                                 QTextEdit, QTextCharFormat, QToolTip,
                                 QListWidget, QPlainTextEdit, QPalette,
                                 QMainWindow, QTextOption, QMouseEvent,
-                                QTextFormat, QClipboard)
+                                QTextFormat, QClipboard, QAbstractItemView)
 from spyderlib.qt.QtCore import Signal, Slot, Qt, QEventLoop, QEvent, QPoint
 from spyderlib.qt.compat import to_qvariant
 
@@ -163,6 +163,8 @@ def update_current(self):
                     completion_text = completion_text.lower()
                 if completion.startswith(completion_text):
                     self.setCurrentRow(row)
+                    self.scrollTo(self.currentIndex(),
+                                  QAbstractItemView.PositionAtTop)
                     break
             else:
                 self.hide()


Test patch:
Repository: spyder-ide/spyder

Issue:
Spyder can't switch lines of code when those two lines are the last two in the file
Spyder (Python2.7)

Should be an easy fix.

If you try to use alt+arrows to switch two lines of code in a .py file, the will not switch iff the two lines are the last two lines of code (counting empty lines)

-Chris



Discussion:
@blink1073, could you take a look at this one?

On it. 


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
@@ -792,6 +792,7 @@ def __move_line_or_selection(self, after_current_line=True):
         cursor = self.textCursor()
         cursor.beginEditBlock()
         start_pos, end_pos = self.__save_selection()
+        add_linesep = False
         if to_text_string(cursor.selectedText()):
             # Check if start_pos is at the start of a block
             cursor.setPosition(start_pos)
@@ -811,22 +812,41 @@ def __move_line_or_selection(self, after_current_line=True):
             start_pos = cursor.position()
             cursor.movePosition(QTextCursor.NextBlock)
             end_pos = cursor.position()
+            # check if on last line
+            if end_pos == start_pos:
+                cursor.movePosition(QTextCursor.End)
+                end_pos = cursor.position()
+                if start_pos == end_pos:
+                    cursor.endEditBlock()
+                    return
+                add_linesep = True
         cursor.setPosition(start_pos)
         cursor.setPosition(end_pos, QTextCursor.KeepAnchor)
-        
+
         sel_text = to_text_string(cursor.selectedText())
+        if add_linesep:
+            sel_text += os.linesep
         cursor.removeSelectedText()
-        
+
         if after_current_line:
             text = to_text_string(cursor.block().text())
+            if not text:
+                cursor.insertText(sel_text)
+                cursor.endEditBlock()
+                return
             start_pos += len(text)+1
             end_pos += len(text)+1
             cursor.movePosition(QTextCursor.NextBlock)
+            if cursor.position() < start_pos:
+                cursor.movePosition(QTextCursor.End)
+                sel_text = os.linesep + sel_text
+                end_pos -= 1
         else:
             cursor.movePosition(QTextCursor.PreviousBlock)
             text = to_text_string(cursor.block().text())
             start_pos -= len(text)+1
             end_pos -= len(text)+1
+
         cursor.insertText(sel_text)
 
         cursor.endEditBlock()


Test patch:
Repository: spyder-ide/spyder

Issue:
Code completion is failing on Python consoles
The introduction of icons for completions on the Editor broke completions in our Python consoles.

For example, after running

```
import <Tab>
```

I'm getting this traceback on the internal console

``` python-traceback
Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/shell.py", line 312, in keyPressEvent
    self.postprocess_keyevent(event)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/shell.py", line 744, in postprocess_keyevent
    ShellBaseWidget.postprocess_keyevent(self, event)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/shell.py", line 372, in postprocess_keyevent
    self._key_tab()
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/shell.py", line 776, in _key_tab
    self.show_code_completion(automatic=False)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/shell.py", line 921, in show_code_completion
    automatic=automatic)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/widgets/sourcecode/base.py", line 909, in show_completion_list
    underscore = set([(comp, t) for (comp, t) in completions
ValueError: too many values to unpack
```

@blink1073, could you take a look at it?



Discussion:

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
@@ -900,8 +900,11 @@ def hide_completion_widget(self):
     def show_completion_list(self, completions, completion_text="",
                              automatic=True):
         """Display the possible completions"""
-        c = completions
-        if len(c) == 0 or (len(c) == 1 and c[0][0] == completion_text):
+        if not completions:
+            return
+        if not isinstance(completions[0], tuple):
+            completions = [(c, '') for c in completions]
+        if len(completions) == 1 and completions[0][0] == completion_text:
             return
         self.completion_text = completion_text
         # Sorting completion list (entries starting with underscore are 


Test patch: