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

Issue:
Fix Indentation always uses 4 spaces instead of the selected number of spaces
## Description of your problem

When performing `Fix Indentation` to convert tabs to spaces, it always converts to 4 spaces instead of the preference setting.




Discussion:
@rlaverde, please solve this one, given that you've done a lot of work about tabs and spaces.

Resolving patch:
diff --git a/spyder/utils/sourcecode.py b/spyder/utils/sourcecode.py
--- a/spyder/utils/sourcecode.py
+++ b/spyder/utils/sourcecode.py
@@ -71,9 +71,9 @@ def has_mixed_eol_chars(text):
     return repr(correct_text) != repr(text)
 
 
-def fix_indentation(text):
+def fix_indentation(text, indent_chars):
     """Replace tabs by spaces"""
-    return text.replace('\t', ' '*4)
+    return text.replace('\t', indent_chars)
 
     
 def is_builtin(text):
diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py
--- a/spyder/widgets/sourcecode/codeeditor.py
+++ b/spyder/widgets/sourcecode/codeeditor.py
@@ -907,9 +907,9 @@ def remove_trailing_spaces(self):
         cursor.endEditBlock()
 
     def fix_indentation(self):
-        """Replace tabs by 4 spaces."""
+        """Replace tabs by spaces."""
         text_before = to_text_string(self.toPlainText())
-        text_after = sourcecode.fix_indentation(text_before)
+        text_after = sourcecode.fix_indentation(text_before, self.indent_chars)
         if text_before != text_after:
             # We do the following rather than using self.setPlainText
             # to benefit from QTextEdit's undo/redo feature.


Test patch:
diff --git a/spyder/widgets/sourcecode/tests/test_indentation.py b/spyder/widgets/sourcecode/tests/test_indentation.py
--- a/spyder/widgets/sourcecode/tests/test_indentation.py
+++ b/spyder/widgets/sourcecode/tests/test_indentation.py
@@ -94,11 +94,11 @@ def test_fix_indentation(code_editor_indent_bot):
                 "\tprint(self.b)\n"
                 "\n"
                 )
-    # Fix indentation replaces tabs with 4 spaces and not indent_chars spaces.
-    fixed = ("    \n"
-             "class a():    \n"
-             "    self.b = 1\n"
-             "    print(self.b)\n"
+    # Fix indentation replaces tabs with indent_chars spaces.
+    fixed = ("  \n"
+             "class a():  \n"
+             "  self.b = 1\n"
+             "  print(self.b)\n"
              "\n"
              )
     editor.set_text(original)
Repository: spyder-ide/spyder

Issue:
Spyder not starting in macOS because pyopengl is present


I updated python and spyder using "conda update spyder" and "conda update python" respectively on MacOSX. Is this a python error or a spyder error? 

Please find attached the conda list output listing the versions.

Thanks for your support. 
--------
Traceback (most recent call last):
File "/Users/Nagraj/anaconda3/bin/spyder", line 7, in 
[conda_list.txt](https://github.com/spyder-ide/spyder/files/1590875/conda_list.txt)

from spyder.app.start import main
File "/Users/Nagraj/anaconda3/lib/python3.6/site-packages/spyder/app/start.py", line 19, in 
from OpenGL import GL
File "/Users/Nagraj/anaconda3/lib/python3.6/site-packages/OpenGL/GL/__init__.py", line 3, in 
from OpenGL import error as _error
File "/Users/Nagraj/anaconda3/lib/python3.6/site-packages/OpenGL/error.py", line 12, in 
from OpenGL import platform, _configflags
File "/Users/Nagraj/anaconda3/lib/python3.6/site-packages/OpenGL/platform/__init__.py", line 35, in 
_load()
File "/Users/Nagraj/anaconda3/lib/python3.6/site-packages/OpenGL/platform/__init__.py", line 29, in _load
plugin = plugin_class()
TypeError: 'NoneType' object is not callable



Discussion:
Do you have `pyopengl` installed?

Resolving patch:
diff --git a/spyder/app/start.py b/spyder/app/start.py
--- a/spyder/app/start.py
+++ b/spyder/app/start.py
@@ -16,8 +16,7 @@
 # See issue 3332
 try:
     from OpenGL import GL
-except ImportError:
-    # pyopengl is not present when installed using conda
+except:
     pass
 
 # Local imports


Test patch:
Repository: spyder-ide/spyder

Issue:
Improve how we detect that Spyder is running under Anaconda
See https://stackoverflow.com/a/47610844/438386 for a robust approach to do this.


Discussion:

Resolving patch:
diff --git a/spyder/config/utils.py b/spyder/config/utils.py
--- a/spyder/config/utils.py
+++ b/spyder/config/utils.py
@@ -157,7 +157,7 @@ def get_edit_extensions():
 # Detection of OS specific versions
 #==============================================================================
 def is_ubuntu():
-    "Detect if we are running in an Ubuntu-based distribution"
+    """Detect if we are running in an Ubuntu-based distribution"""
     if sys.platform.startswith('linux') and osp.isfile('/etc/lsb-release'):
         release_info = open('/etc/lsb-release').read()
         if 'Ubuntu' in release_info:
@@ -169,7 +169,7 @@ def is_ubuntu():
 
 
 def is_gtk_desktop():
-    "Detect if we are running in a Gtk-based desktop"
+    """Detect if we are running in a Gtk-based desktop"""
     if sys.platform.startswith('linux'):
         xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '')
         if xdg_desktop:
@@ -185,7 +185,7 @@ def is_gtk_desktop():
 
 
 def is_kde_desktop():
-    "Detect if we are running in a KDE desktop"
+    """Detect if we are running in a KDE desktop"""
     if sys.platform.startswith('linux'):
         xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '')
         if xdg_desktop:
@@ -200,8 +200,10 @@ def is_kde_desktop():
 
 
 def is_anaconda():
-    "Detect if we are running under Anaconda."
-    for var in os.environ:
-        if var.startswith('CONDA'):
-            return True
-    return False
+    """
+    Detect if we are running under Anaconda.
+
+    Taken from https://stackoverflow.com/a/47610844/438386
+    """
+    is_conda = osp.exists(osp.join(sys.prefix, 'conda-meta'))
+    return is_conda


Test patch:
Repository: spyder-ide/spyder

Issue:
ValueError: not enough values to unpack in the File Explorer
## Description

**What steps will reproduce the problem?**

1. 
2. 
3. 

**What is the expected output? What do you see instead?**


**Please provide any additional information below**

  File "C:\Users\overt_000\Anaconda3\lib\site-packages\spyder\widgets\explorer.py", line 154, in icon
    file_type, bin_name = mime_type.split('/')
ValueError: not enough values to unpack (expected 2, got 1)


## Version and main components

* Spyder Version: 3.2.1 
* Python Version: 3.6.2
* Qt Versions: 5.6.2, PyQt5 5.6 on Windows

## Dependencies
```
pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
numpy >=1.7      :  1.13.1 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.2.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.1.0 (OK)
pylint >=0.25    :  1.7.2 (OK)

```



Discussion:
@andfoy, please take a look at this one.
How is this going to be solved excuise my unconvenience :(
I'll fix this for our next version, to be released next week.
Thank you sir.
@ccordoba12  If it helps, every error report was on a Windows system.

EDIT:  I am able to recreate this on my Windows 7 system, so I will look into this.

Resolving patch:
diff --git a/spyder/widgets/explorer.py b/spyder/widgets/explorer.py
--- a/spyder/widgets/explorer.py
+++ b/spyder/widgets/explorer.py
@@ -153,7 +153,16 @@ def icon(self, icontype_or_qfileinfo):
                     icon = ima.icon(self.OFFICE_FILES[extension])
 
                 if mime_type is not None:
-                    file_type, bin_name = mime_type.split('/')
+                    try:
+                        # Fix for issue 5080.  Even though mimetypes.guess_type
+                        # documentation states that the return value will be
+                        # None or a tuple of the form type/subtype, in the
+                        # Windows registry, .sql has a mimetype of text\plain
+                        # instead of text/plain therefore mimetypes is
+                        # returning it incorrectly.
+                        file_type, bin_name = mime_type.split('/')
+                    except ValueError:
+                        file_type = 'text'
                     if file_type == 'text':
                         icon = ima.icon('TextFileIcon')
                     elif file_type == 'audio':


Test patch:
Repository: spyder-ide/spyder

Issue:
Keyboard shortcut hint is missing from menu item Search/Find in files
## Description of your problem

**What steps will reproduce the problem?**

1. Click on Search menu
2. Observe shortcut hints right side of menu items
3. Notice that all other menu items nicely display  a hint of keyboard shortcut, like "Search/Find text" menu item shows "Ctrl+F", but the "Search/Find in files" menu item does not show keyboard shortcut hint.


**What is the expected output? What do you see instead?**

The "Ctrl+Shift+F" hint should be showing next to menu item "Search/Find in files"

**Please provide any additional information below**

The shortcut actually works, this issue is not a bug but only enhancement for convenience/correct self-documenting.

## Versions and main components

* Spyder Version: 3.1.2
* Python Version: 3.6.0
* Operating system: Linux


## 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.10.0 (OK)
matplotlib >=1.0 :  None (NOK)
nbconvert >=4.0  :  5.1.1 (OK)
numpy >=1.7      :  None (NOK)
pandas >=0.13.1  :  None (NOK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  5.1.2 (OK)
pyflakes >=0.6.0 :  1.5.0 (OK)
pygments >=2.0   :  2.2.0 (OK)
pylint >=0.25    :  1.6.5 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.5.2 (OK)
sympy >=0.7.3    :  None (NOK)



Discussion:

Resolving patch:
diff --git a/spyder/plugins/findinfiles.py b/spyder/plugins/findinfiles.py
--- a/spyder/plugins/findinfiles.py
+++ b/spyder/plugins/findinfiles.py
@@ -16,7 +16,8 @@
 
 # Third party imports
 from qtpy.QtWidgets import QApplication
-from qtpy.QtCore import Signal, Slot
+from qtpy.QtCore import Signal, Slot, Qt
+from qtpy.QtGui import QKeySequence
 
 # Local imports
 from spyder.config.base import _
@@ -140,11 +141,14 @@ def register_plugin(self):
         self.main.projects.sig_project_closed.connect(self.unset_project_path)
         self.main.editor.open_file_update.connect(self.set_current_opened_file)
 
-        findinfiles_action = create_action(self, _("&Find in files"),
+        findinfiles_action = create_action(
+                                   self, _("&Find in files"),
                                    icon=ima.icon('findf'),
-                                   triggered=self.findinfiles_callback,
-                                   tip=_("Search text in multiple files"))        
-        
+                                   triggered=self.switch_to_plugin,
+                                   shortcut=QKeySequence(self.shortcut),
+                                   context=Qt.WidgetShortcut,
+                                   tip=_("Search text in multiple files"))
+
         self.main.search_menu_actions += [MENU_SEPARATOR, findinfiles_action]
         self.main.search_toolbar_actions += [MENU_SEPARATOR,
                                              findinfiles_action]


Test patch:
Repository: spyder-ide/spyder

Issue:
Window layout setting error
## Description

**What steps will reproduce the problem?**

1. display tab
2. close current pane
3. repeat step2.

**What is the expected output? What do you see instead?**
 - show default window layout

**Please provide any additional information below**

  File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2248, in maximize_dockwidget
    self.last_plugin.dockwidget.toggleViewAction().setDisabled(True)
AttributeError: 'NoneType' object has no attribute 'dockwidget'


## Version and main components

* Spyder Version: 3.2.3 
* Python Version: 3.6.1
* Qt Versions: 5.6.2, PyQt5 5.6 on Windows

## Dependencies
```
pyflakes >=0.6.0 :  1.5.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.1 (OK)
numpy >=1.7      :  1.12.1 (OK)
sphinx >=0.6.6   :  1.5.6 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.1.1 (OK)
sympy >=0.7.3    :  1.0 (OK)
cython >=0.21    :  0.25.2 (OK)
qtconsole >=4.2.0:  4.3.0 (OK)
IPython >=4.0    :  5.3.0 (OK)
pylint >=0.25    :  1.6.4 (OK)

```



Discussion:

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -2257,16 +2257,29 @@ def maximize_dockwidget(self, restore=False):
         if self.state_before_maximizing is None:
             if restore:
                 return
-            # No plugin is currently maximized: maximizing focus plugin
+
+            # Select plugin to maximize
             self.state_before_maximizing = self.saveState()
             focus_widget = QApplication.focusWidget()
             for plugin in self.widgetlist:
                 plugin.dockwidget.hide()
                 if plugin.isAncestorOf(focus_widget):
                     self.last_plugin = plugin
+
+            # Only plugins that have a dockwidget are part of widgetlist,
+            # so last_plugin can be None after the above "for" cycle.
+            # For example, this happens if, after Spyder has started, focus
+            # is set to the Working directory toolbar (which doesn't have
+            # a dockwidget) and then you press the Maximize button
+            if self.last_plugin is None:
+                # Using the Editor as default plugin to maximize
+                self.last_plugin = self.editor
+
+            # Maximize last_plugin
             self.last_plugin.dockwidget.toggleViewAction().setDisabled(True)
             self.setCentralWidget(self.last_plugin)
             self.last_plugin.ismaximized = True
+
             # Workaround to solve an issue with editor's outline explorer:
             # (otherwise the whole plugin is hidden and so is the outline explorer
             #  and the latter won't be refreshed if not visible)


Test patch:
Repository: spyder-ide/spyder

Issue:
UnicodeEncodeError when searching text in the Editor
## Description
after update to 3.2.6 when trying to search text in file (ctrl+f) then start typing it display error message with invite to send this issue report

**What steps will reproduce the problem?**

0.  Russian interface
1. ctrl+f
2. start typing text to search 
(it continue to appear UPD when text found))

**What is the expected output? What do you see instead?**
expected normal usual context search. error message instead

UPD:
--reset  and --defaults cant't help with that
change interface to English (was Russian) fixed error. so i suppose it some mistakes in translation file or something in utf8 of some strings

**Please provide any additional information below**

  File "f:\dev\python27\lib\site-packages\spyder\widgets\findreplace.py", line 365, in text_has_been_edited
    self.find(changed=True, forward=True, start_highlight_timer=True)
  File "f:\dev\python27\lib\site-packages\spyder\widgets\findreplace.py", line 441, in find
    total_matches=number_matches)
  File "f:\dev\python27\lib\site-packages\spyder\widgets\findreplace.py", line 575, in change_number_matches
    total_matches)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)


## Version and main components

* Spyder Version: 3.2.6 
* Python Version: 2.7.9
* Qt Versions: 4.8.6, PyQt4 (API v2) 4.11.3 on Windows

## Dependencies
```
pyflakes >=0.5.0  :  1.6.0 (OK)
pycodestyle >=2.3 :  2.3.1 (OK)
pygments >=2.0    :  2.2.0 (OK)
pandas >=0.13.1   :  0.20.3 (OK)
numpy >=1.7       :  1.13.1 (OK)
sphinx >=0.6.6    :  1.6.6 (OK)
rope >=0.9.4      :  0.10.7 (OK)
jedi >=0.9.0      :  0.11.1 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
sympy >=0.7.3     :  1.0 (OK)
cython >=0.21     :  0.25.2 (OK)
qtconsole >=4.2.0 :  4.3


Discussion:
Thanks for reporting. We'll fix this in 3.2.7.

Resolving patch:
diff --git a/spyder/widgets/findreplace.py b/spyder/widgets/findreplace.py
--- a/spyder/widgets/findreplace.py
+++ b/spyder/widgets/findreplace.py
@@ -571,11 +571,11 @@ def replace_find_selection(self, focus_replace_text=False):
     def change_number_matches(self, current_match=0, total_matches=0):
         """Change number of match and total matches."""
         if current_match and total_matches:
-            matches_string = "{} {} {}".format(current_match, _("of"),
+            matches_string = u"{} {} {}".format(current_match, _(u"of"),
                                                total_matches)
             self.number_matches_text.setText(matches_string)
         elif total_matches:
-            matches_string = "{} {}".format(total_matches, _("matches"))
+            matches_string = u"{} {}".format(total_matches, _(u"matches"))
             self.number_matches_text.setText(matches_string)
         else:
-            self.number_matches_text.setText(_("no matches"))
+            self.number_matches_text.setText(_(u"no matches"))


Test patch:
Repository: spyder-ide/spyder

Issue:
Errors pop up when change the key shortcuts in python 2.7
## Description of your problem
Hi,

I came across this pop-up error when I want to change the default shortcut of spyder27 in the conda environment of python 2.7. It seems simple to modify certain number of lines in the code. However, I am new to the development issues so I don't know how to solve this. 
![image](https://user-images.githubusercontent.com/8952869/35130685-23fd4c04-fcfd-11e7-8227-f6a9f305a813.png)

**What steps will reproduce the problem?**

I just simply open my spyder27 using command line, go to Preferences -> Keyboard shortcuts and do the modification. The error shows when I press the new shortcut before I select 'ok'.
![image](https://user-images.githubusercontent.com/8952869/35130869-04da0be0-fcfe-11e7-9807-ee0e36825eaf.png)



**What is the expected output? What do you see instead?**
Please give me any advice that I can change the default shortcuts. Thanks!

**Please provide any additional information below**
I tried that in my python 3 environment and it works fine.

## Versions and main components

* Spyder Version: 3.2.6
* Python Version: 2.7
* Qt Version: 5.6.2
* PyQt Version: 5.6.2
* Operating system: window 7


## Dependencies

Please go to the menu entry `Help > Optional Dependencies` (or
`Help > Dependencies`), press the button `Copy to clipboard`
and paste the contents below:
IPython >=4.0;<6.0:  5.4.1 (OK)
cython >=0.21     :  0.27.3 (OK)
jedi >=0.9.0      :  0.11.1 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
numpy >=1.7       :  1.13.3 (OK)
pandas >=0.13.1   :  0.22.0 (OK)
pycodestyle >=2.3 :  2.3.1 (OK)
pyflakes >=0.5.0  :  1.6.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
pylint >=0.25     :  1.8.1 (OK)
qtconsole >=4.2.0 :  4.3.1 (OK)
rope >=0.9.4      :  0.10.7 (OK)
sphinx >=0.6.6    :  1.6.6 (OK)
sympy >=0.7.3     :  1.1.1 (OK)



Discussion:
Thanks for reporting. @csabella, could you take a look at this one? This error appeared after your PR #6092.

Resolving patch:
diff --git a/spyder/plugins/shortcuts.py b/spyder/plugins/shortcuts.py
--- a/spyder/plugins/shortcuts.py
+++ b/spyder/plugins/shortcuts.py
@@ -211,7 +211,7 @@ def reject(self):
         # buttons, if the cancel button was clicked without first setting focus
         # to the button, it would cause a seg fault crash.
         self.button_cancel.setFocus()
-        super().reject()
+        super(ShortcutEditor, self).reject()
 
     @Slot()
     def accept(self):
@@ -220,7 +220,7 @@ def accept(self):
         # buttons, if the ok button was clicked without first setting focus to
         # the button, it would cause a seg fault crash.
         self.button_ok.setFocus()
-        super().accept()
+        super(ShortcutEditor, self).accept()
 
     def keyPressEvent(self, e):
         """Qt override."""


Test patch:
Repository: spyder-ide/spyder

Issue:
pdb history doesn't collapse similar text
## Description of your problem

**What steps will reproduce the problem?**

1. debug
2. enter something interesting
3. press 'n' 100 times
4. press 'up' 101 times to get back to the interesting stuff

**What is the expected output? What do you see instead?**
I don't see the point of 'up' returning the same text 100 times. 

pdb history doesn't collapse similar text
## Description of your problem

**What steps will reproduce the problem?**

1. debug
2. enter something interesting
3. press 'n' 100 times
4. press 'up' 101 times to get back to the interesting stuff

**What is the expected output? What do you see instead?**
I don't see the point of 'up' returning the same text 100 times. 



Discussion:

Resolving patch:
diff --git a/spyder/widgets/ipythonconsole/debugging.py b/spyder/widgets/ipythonconsole/debugging.py
--- a/spyder/widgets/ipythonconsole/debugging.py
+++ b/spyder/widgets/ipythonconsole/debugging.py
@@ -73,7 +73,9 @@ def _handle_input_request(self, msg):
 
         def callback(line):
             # Save history to browse it later
-            self._control.history.append(line)
+            if not (len(self._control.history) > 0
+                    and self._control.history[-1] == line):
+                self._control.history.append(line)
 
             # This is the Spyder addition: add a %plot magic to display
             # plots while debugging


Test patch: