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

Issue:
Error when running cell for the first time in the Editor
I'm getting this error when I try to run a cell for the first time

```python-traceback
Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyder/app/mainwindow.py", line 1916, in plugin_focus_changed
    self.update_edit_menu()
  File "/home/carlos/Projects/spyder/github-repo/spyder/app/mainwindow.py", line 1965, in update_edit_menu
    widget, textedit_properties = self.get_focus_widget_properties()
  File "/home/carlos/Projects/spyder/github-repo/spyder/app/mainwindow.py", line 1953, in get_focus_widget_properties
    widget = self.previous_focused_widget
AttributeError: 'MainWindow' object has no attribute 'previous_focused_widget'
```

@rlaverde, this one is for you because this bug was introduced on PR #4022.


Discussion:
After the first time this doesn't happen anymore so it's not that bad.

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -486,6 +486,7 @@ def signal_handler(signum, frame=None):
 
         # To keep track of the last focused widget
         self.last_focused_widget = None
+        self.previous_focused_widget = None
 
         # Server to open external files on a single instance
         self.open_files_server = socket.socket(socket.AF_INET,


Test patch:
Repository: spyder-ide/spyder

Issue:
Inconsistent icon for "Find symbols in file..."
## Description of your problem
The "File: Symbol finder..." menu item has an equivalent button on the toolbar and also in a drop down menu under a "sprocket" or "gear" button along the right edge of the Editor pane next to the tabs.  In the first two instances, a '@' icon is associated with the command.  In the latter instance, however, a bullet-list icon is associated with the command -- the same icon that is associated with the "File switcher..." command.

**What steps will reproduce the problem?**

1. Click the "gear" button to the right of the tabs in the Editor pane, at the right edge.
2. Observe in the drop-down menu the two commands "File switcher..." and "Find symbols in file...".
3. In this drop-down menu, both of these commands appear with the same icon -- a bullet-list icon.  This differs from other instances (e.g., under the File menu and on the Toolbar), where the "Find symbols in file..." command has a '@' icon. 

**What is the expected output? What do you see instead?**
I expect the same '@' icon to appear in all three instances of this command.

**Please provide any additional information below**


## Versions and main components

* Spyder Version: 3.1.0
* Python Version: 2.7.13
* Operating system: Windows 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:
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.3 (OK)
pandas >=0.13.1  :  0.19.2 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.5.0 :  1.5.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 (OK)
sphinx >=0.6.6   :  1.5.1 (OK)
sympy >=0.7.3    :  1.0 (OK)



Discussion:
@andfoy, please take a look at this one :-)

Resolving patch:
diff --git a/spyder/widgets/editor.py b/spyder/widgets/editor.py
--- a/spyder/widgets/editor.py
+++ b/spyder/widgets/editor.py
@@ -346,9 +346,9 @@ def __init__(self, parent, actions):
         fileswitcher_action = create_action(self, _("File switcher..."),
                 icon=ima.icon('filelist'),
                 triggered=self.open_fileswitcher_dlg)
-        symbolfinder_action = create_action(self, 
+        symbolfinder_action = create_action(self,
                 _("Find symbols in file..."),
-                icon=ima.icon('filelist'),
+                icon=ima.icon('symbol_find'),
                 triggered=self.open_symbolfinder_dlg)
         copy_to_cb_action = create_action(self, _("Copy path to clipboard"),
                 icon=ima.icon('editcopy'),


Test patch:
Repository: spyder-ide/spyder

Issue:
Add "run selection" icon

I think this needs to be considered.  Just reoopned this.

ahed87 commented on Jan 10, 2016
Hi,
an enhancement idea triggered by issue #2490
a small (or large) suggestion related to this area would be to add one run icon.
I quite often select a piece of code and use the right-click -> "run selection or current line".
When doing that I typically have made the selection with keys, scrolled a bit with the mouse and that's when I miss an icon to press to run the selected area. I quite often end up pressing the regular run-icon when I really want to run a selection, since it's soo much easier than doing the right-click, especially if that area is out of focus in the editor.

I have no strong opinions of how such an icon would look like (like today's run with an 's' in it?), and were it should be placed (inbetween current run and runcell icons?).


Discussion:
@sibojan, I agree with reopening this one. and adding this icon to our Run toolbar.

@mariacamilaremolinagutierrez, please work on this one. Just add the *Run selection* button between *Run current cell and advance* and *Run again last file*.

I think we should also remove *Run settings* which is not so used as the others. 
Thank you guys for your support.   **Run Settings** is truly rarely used.  Looking at other popular ODE/lauagues, e.g. Rstudio, Matlab, none of them put the **Run settings** at  the most important place of toolbar. I migrated from R to python,  having been using **Run Selected** quite frequently in the past. I don't think that I am alone on this case. 
@sibojan, thanks for bringing this to our attention again :-)

Resolving patch:
diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py
--- a/spyder/plugins/editor.py
+++ b/spyder/plugins/editor.py
@@ -819,7 +819,7 @@ def get_plugin_actions(self):
                                             triggered=self.run_selection,
                                             context=Qt.WidgetShortcut)
         self.register_shortcut(run_selected_action, context="Editor",
-                               name="Run selection")
+                               name="Run selection", add_sc_to_tip=True)
 
         run_cell_action = create_action(self,
                             _("Run cell"),
@@ -1051,8 +1051,8 @@ def get_plugin_actions(self):
                             configure_action, MENU_SEPARATOR]
         self.main.run_menu_actions += run_menu_actions
         run_toolbar_actions = [run_action, run_cell_action,
-                               run_cell_advance_action, re_run_action,
-                               configure_action]
+                               run_cell_advance_action, run_selected_action,
+                               re_run_action]
         self.main.run_toolbar_actions += run_toolbar_actions
 
         # ---- Debug menu/toolbar construction ----


Test patch:
Repository: spyder-ide/spyder

Issue:
Wrong binary in Python 3 wheels
I upgraded Spyder to 3.1.2 with `sudo pip3 install --upgrade spyder` on a Linux Mint 18.1 system. It installs a `spyder3.desktop` file into `/usr/local/share/applications/` and `spyder` into `/usr/local/bin/`. The `spyder3.desktop` has the following contents:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Spyder3
    GenericName=Spyder3
    Comment=Scientific PYthon Development EnviRonment - Python3
    TryExec=spyder3
    Exec=spyder3 %F
    Categories=Development;Science;IDE;Qt;
    Icon=spyder3
    Terminal=false
    StartupNotify=true
    MimeType=text/x-python;

but there is no executable with the name `spyder3` in the path. After changing the entries `TryExec` and `Exec` to `TryExec=spyder` and `Exec=spyder %F` the `spyder3.desktop` file works again.

**What steps will reproduce the problem?**

1. Install Spyder with `pip3 install spyder`.
2. Try to start Spyder with the installed .desktop file.
3. Cannot find the executable `spyder3`.

**What is the expected output? What do you see instead?**

Spyder should start, but does not start due to wrong `Exec` entries in the .desktop file.

## Versions and main components

* Spyder Version: 3.1.2 (but also 3.1.1)
* Python Version: 3.5.2
* Pip Version: 9.0.1
* Operating system: Linux Mint 18.1


## Dependencies

jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.1 (OK)
nbconvert >=4.0  :  5.1.1 (OK)
numpy >=1.7      :  1.11.0 (OK)
pandas >=0.13.1  :  0.17.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  5.0.1 (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    :  0.7.6.1 (OK)


Discussion:
I'm surprised nobody has noticed this error before. We'll fix it in 3.1.3 :-)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -293,7 +293,8 @@ def run(self):
 
     setup_args['entry_points'] = {
         'gui_scripts': [
-            'spyder = spyder.app.start:main'
+            '{} = spyder.app.start:main'.format(
+                'spyder3' if PY3 else 'spyder')
         ]
     }
 


Test patch:
diff --git a/continuous_integration/travis/run_test.sh b/continuous_integration/travis/run_test.sh
--- a/continuous_integration/travis/run_test.sh
+++ b/continuous_integration/travis/run_test.sh
@@ -30,7 +30,11 @@ fi
 
 
 # Testing that the app starts and runs
-spyder
+if [[ "$USE_CONDA" = false && "$TRAVIS_PYTHON_VERSION" != "2.7" ]] ; then
+    spyder3
+else
+    spyder
+fi
 if [ $? -ne 0 ]; then
     exit 1
 fi
Repository: spyder-ide/spyder

Issue:
Crash in "New window" when opening new file.
## Description of your problem

**What steps will reproduce the problem?**

1. Open Spyder. On the tab of the current file open in Editor, I right-click and select "New window". A new window with Editor and the current file opens correctly.
2. In the new window I click "Open file" icon. In the "Open file" window I select a second file to open, click on it (turns blue) and then click "Open" button. 
3. After pressing "Open" Spyder crashes with message:
27558 Segmentation fault      (core dumped) spyder3

**What is the expected output? What do you see instead?**
I expect Spyder to open the new file in the Editor (in both windows open). Instead, Spyder crashes.

**Please provide any additional information below**

When writing this issue it took me long time to execute each step and then Spyder didn't crash. Then I repeated following the steps without waiting and crashes again. Also, the first time I noticed the issue Spyder hanged for long time before crashing.

I use a virtual environment with Python 3.5.3 on Ubuntu 16.04. I install PyQt5 v5.7.1 from pip. This comes with a local copy of Qt (v5.7.1) so it doesn't mess with the Ubuntu Qt. I compile Spyder 3.1.2 from source in the virtual environment with all necessary dependencies (see below).
Probably unrelated, but I also use nvidia driver which has an issue reported in #3226. I fix it manually according to the post, using PyOpenGL.

## Versions and main components

* Spyder Version: 3.1.2
* Python Version: 3.5.3
* Operating system: Ubuntu LTS 16.04


## 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 :  2.0.0 (OK)
nbconvert >=4.0  :  5.1.1 (OK)
numpy >=1.7      :  1.12.0 (OK)
pandas >=0.13.1  :  0.19.2 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  5.0.1 (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.10.3 (OK)
sphinx >=0.6.6   :  1.5.2 (OK)
sympy >=0.7.3    :  1.0 (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
@@ -1945,7 +1945,7 @@ def get_focus_widget_properties(self):
         """Get properties of focus widget
         Returns tuple (widget, properties) where properties is a tuple of
         booleans: (is_console, not_readonly, readwrite_editor)"""
-        widget = self.focusWidget()
+        widget = QApplication.focusWidget()
         from spyder.widgets.shell import ShellBaseWidget
         from spyder.widgets.editor import TextEditBaseWidget
 


Test patch:
Repository: spyder-ide/spyder

Issue:
UnboundLocalError: local variable 'img_path' referenced before assignment
## Description of your problem

The Ubuntu Error Tracker has been receiving reports about a problem regarding spyder. This problem was most recently seen with package version 3.0.2+dfsg1-2, the problem page at https://errors.ubuntu.com/problem/f4a67211f66fb239047b33781abfae6849af207a contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
If you do not have access to the Ubuntu Error Tracker you can request it at http://forms.canonical.com/reports/.

```python
Traceback (most recent call last):
  File "/usr/bin/spyder3", line 3, in <module>
    start.main()
  File "/usr/lib/python3/dist-packages/spyder/app/start.py", line 103, in main
    from spyder.app import mainwindow
  File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 120, in <module>
    SPLASH = QSplashScreen(QPixmap(get_image_path('splash.svg'), 'svg'))
  File "/usr/lib/python3/dist-packages/spyder/config/base.py", line 212, in get_image_path
    return osp.abspath(osp.join(img_path, default))
UnboundLocalError: local variable 'img_path' referenced before assignment
```

The relevant code (taken from version 3.1.2+dfsg1-1):

```python
def get_image_path(name, default="not_found.png"):
    """Return image absolute path"""
    for img_path in IMG_PATH:
        full_path = osp.join(img_path, name)
        if osp.isfile(full_path):
            return osp.abspath(full_path)
    if default is not None:
        return osp.abspath(osp.join(img_path, default))
```

The problem: When `IMG_PATH` is empty and default is defined, `img_path` is not defined and python will crash.

## Versions and main components

* Spyder Version: 3.0.2+dfsg1-2
* Python Version: 3.5.1-4
* Operating system: Ubuntu 17.04 (zesty)



Discussion:
We can fix it in Spyder 3.1.3 and you can backport the fix to the Ubuntu packages. Is that fine for you?
Yes, that's fine.
@dalthviz, please work on this one.

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -120,7 +120,7 @@
 # Create splash screen out of MainWindow to reduce perceived startup time. 
 #==============================================================================
 from spyder.config.base import _, get_image_path, DEV, PYTEST
-SPLASH = QSplashScreen(QPixmap(get_image_path('splash.svg'), 'svg'))
+SPLASH = QSplashScreen(QPixmap(get_image_path('splash.svg')))
 SPLASH_FONT = SPLASH.font()
 SPLASH_FONT.setPixelSize(10)
 SPLASH.setFont(SPLASH_FONT)
diff --git a/spyder/config/base.py b/spyder/config/base.py
--- a/spyder/config/base.py
+++ b/spyder/config/base.py
@@ -214,6 +214,7 @@ def get_image_path(name, default="not_found.png"):
         if osp.isfile(full_path):
             return osp.abspath(full_path)
     if default is not None:
+        img_path = osp.join(get_module_path('spyder'), 'images')
         return osp.abspath(osp.join(img_path, default))
 
 


Test patch:
Repository: spyder-ide/spyder

Issue:
language reset to japanese on reboot
## Description
just updated to current master, running spyder via `bootstrap.py`.  Language gets set to Japanese on every restart of spyder.

**What steps will reproduce the problem?**

1. Open spyder
2. open preferences > general > advanced 
3. set language to English, apply settings, close & re-open spyder
4. open preferences > general > advanced 
5. language will be set to 日本語

**What is the expected output? What do you see instead?**

interface language setting should persist across reboots.  

**additional info**

Note that after setting it to English and rebooting, it loads an English interface, but if I change **any other setting** and click "OK" or "Apply" then it will prompt about needing to reboot in order to change the interface language.

## Version and main components

* Spyder Version: 4.0.0.dev0 65bc403
* Python Version: 2.7.12
* Qt Versions: 4.8.7, PyQt4 (API v2) 4.11.4 on Linux

## Dependencies
```
pyflakes >=0.5.0 :  1.1.0 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
pandas >=0.13.1  :  0.18.0+104.g1c8816f (OK)
numpy >=1.7      :  1.12.0.dev0+2af06c8 (OK)
sphinx >=0.6.6   :  1.5a0 (OK)
rope >=0.9.4     :  0.10.3 (OK)
jedi =0.9.0      :  0.9.0 (OK)
psutil >=0.3     :  3.4.2 (OK)
matplotlib >=1.0 :  1.5.1+1643.g0423430 (OK)
sympy >=0.7.3    :  None (NOK)
pylint >=0.25    :  1.6.5 (OK)

```



Discussion:
@rlaverde, please take a look at this one.

Resolving patch:
diff --git a/spyder/config/user.py b/spyder/config/user.py
--- a/spyder/config/user.py
+++ b/spyder/config/user.py
@@ -390,6 +390,13 @@ def get(self, section, option, default=NoDefault):
             if PY2:
                 try:
                     value = value.decode('utf-8')
+                    try:
+                        # Some str config values expect to be eval after decoding
+                        new_value = ast.literal_eval(value)
+                        if is_text_string(new_value):
+                            value = new_value
+                    except (SyntaxError, ValueError):
+                        pass
                 except (UnicodeEncodeError, UnicodeDecodeError):
                     pass
         else:


Test patch:
Repository: spyder-ide/spyder

Issue:
Vertical line still in wrong place
## Description

#4153 is still not fixed.  The line does in fact move now, but it still falls in the wrong place (it is always 2 characters early).  Here's another screenshot, with vertical line setting as `79`:

![screenshot_2017-02-17_13-59-10](https://cloud.githubusercontent.com/assets/1810515/23084927/ad60a762-f519-11e6-9a60-f74d1a6057c9.png)

**What is the expected output? What do you see instead?**

Line should appear after the 79th character.  Instead, it appears after the 77th character.

## Version and main components

* Spyder Version: 4.0.0.dev0 2487cdd
* Python Version: 2.7.12
* Qt Versions: 4.8.7, PyQt4 (API v2) 4.11.4 on Linux

## Dependencies
```
pyflakes >=0.5.0 :  1.1.0 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
pandas >=0.13.1  :  0.18.0+104.g1c8816f (OK)
numpy >=1.7      :  1.12.0.dev0+2af06c8 (OK)
sphinx >=0.6.6   :  1.5a0 (OK)
rope >=0.9.4     :  0.10.3 (OK)
jedi =0.9.0      :  0.9.0 (OK)
psutil >=0.3     :  3.4.2 (OK)
matplotlib >=1.0 :  1.5.1+1643.g0423430 (OK)
sympy >=0.7.3    :  None (NOK)
pylint >=0.25    :  1.5.5 (OK)

```



Discussion:

Resolving patch:
diff --git a/spyder/widgets/panels/edgeline.py b/spyder/widgets/panels/edgeline.py
--- a/spyder/widgets/panels/edgeline.py
+++ b/spyder/widgets/panels/edgeline.py
@@ -13,6 +13,7 @@
 from qtpy.QtGui import QPainter, QColor
 
 from spyder.py3compat import is_text_string
+from spyder.api.panel import Panel
 
 class EdgeLine(QWidget):
     """Source code editor's edge line (default: 79 columns, PEP8)"""
@@ -74,6 +75,6 @@ def set_geometry(self, cr):
         offset = self.editor.contentOffset()
         x = self.editor.blockBoundingGeometry(self.editor.firstVisibleBlock()) \
             .translated(offset.x(), offset.y()).left() \
-            +self.editor.linenumberarea.get_width() \
+            +self.editor.panels.margin_size(Panel.Position.LEFT) \
             +self.editor.fontMetrics().width('9'*min(self.columns))+5
         self.setGeometry(QRect(x, cr.top(), width, cr.bottom()))


Test patch:
Repository: spyder-ide/spyder

Issue:
Add a message to the Python console about its removal in Spyder 3.2
@dalthviz, the message should be added before the first prompt (i.e. `>>>`) and should say

> NOTE: The Python console is going to be removed in Spyder 3.2. Please start to migrate your work to the IPython console instead.


Discussion:

Resolving patch:
diff --git a/spyder/plugins/externalconsole.py b/spyder/plugins/externalconsole.py
--- a/spyder/plugins/externalconsole.py
+++ b/spyder/plugins/externalconsole.py
@@ -715,6 +715,11 @@ def process_started(self, shell_id):
             self.help.set_shell(shell.shell)
         if self.variableexplorer is not None:
             self.variableexplorer.add_shellwidget(shell)
+        shell.shell.write("NOTE: The Python console is going to "
+                          "be REMOVED in Spyder 3.2. Please start "
+                          "to migrate your work to the "
+                          "IPython console instead.\n\n", prompt=True)
+        shell.shell.new_prompt("")
 
     def process_finished(self, shell_id):
         index = self.get_shell_index_from_id(shell_id)


Test patch:
Repository: spyder-ide/spyder

Issue:
IPython console fails to start (Ipython >=6.x)
## Description of your problem

**What steps will reproduce the problem?**

1. install latest IPython (>=6.x)
2. install spyder (git master)
3. run spyder3

**What is the expected output? What do you see instead?**

The Ipython console should start but instead it fails  with an import error for a missing module:

    ipython.core.utils.quick_guide

which is no more available in latest IPython.

**Please provide any additional information below**

just commenting the offending [line](https://github.com/spyder-ide/spyder/blob/3ea3f8fe6bcbfdec44db708c7895952c9e449205/spyder/widgets/ipythonconsole/shell.py#L91)  gives a working ipython console.


## Versions and main components

* Spyder Version: git master
* Python Version: 3.6
* Qt Version: 5.8
* PyQt Version: 5.7
* 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:

Computer Used for testing not available at the moment of writing, I'll edit the issue once avaialable 



Discussion:
Thanks for reporting. We'll fix this bug in Spyder 3.1.4.
@andfoy, you should surround the line mentioned mentioned by @epifanio with a try/except ImportError. The except part must make `quick_guide` an empty string.

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
@@ -89,7 +89,10 @@ def set_cwd(self, dirname):
     def long_banner(self):
         """Banner for IPython widgets with pylab message"""
         # Default banner
-        from IPython.core.usage import quick_guide
+        try:
+            from IPython.core.usage import quick_guide
+        except Exception:
+            quick_guide = ''
         banner_parts = [
             'Python %s\n' % self.interpreter_versions['python_version'],
             'Type "copyright", "credits" or "license" for more information.\n\n',


Test patch: