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

Issue:
Load external kernel json files from anywhere in the file system
Right now is only possible to connect to a external kernel if the .json connection file is placed in jupyter runtime-dir path. 


Discussion:

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -1377,7 +1377,10 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
                                   password):
         # Verifying if the connection file exists
         try:
-            connection_file = find_connection_file(osp.basename(connection_file))
+            cf_path = osp.dirname(connection_file)
+            cf_filename = osp.basename(connection_file)
+            connection_file = find_connection_file(filename=cf_filename, 
+                                                   path=cf_path)
         except (IOError, UnboundLocalError):
             QMessageBox.critical(self, _('IPython'),
                                  _("Unable to connect to "


Test patch:
Repository: spyder-ide/spyder

Issue:
Spyder fails to create kernel.json files if jupyter_runtime_dir is not writable
This error was reported here:

http://stackoverflow.com/q/40643760/438386

----

~~Solution: If `jupyter_runtime_dir` is not writable we need to switch to `TEMPDIR` (defined in `utils/programs`) to save and load kernel.json files.~~

@mariacamilaremolinagutierrez, I'm assigning this one to you because you also have issue #3630.


Discussion:
Scratch my previous solution! Using a different directory other than `jupyter_runtime_dir` would impose a great burden on us.

So what we need to do is:
1. Prevent Spyder from crashing when `jupyter_runtime_dir` is not writable.
2. Show an error message in our IPython consoles warning users that they need to make `jupyter_runtime_dir` writable in order for Spyder to create consoles for them.

---

@mariacamilaremolinagutierrez, about showing errors please see the method called `create_new_client` in `plugins/ipythonconsole.py`


Resolving patch:
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -861,15 +861,23 @@ def create_new_client(self, give_focus=True):
         """Create a new client"""
         self.master_clients += 1
         name = "%d/A" % self.master_clients
+        cf = self._new_connection_file()
         client = ClientWidget(self, name=name,
                               history_filename='history.py',
                               config_options=self.config_options(),
                               additional_options=self.additional_options(),
                               interpreter_versions=self.interpreter_versions(),
-                              connection_file=self._new_connection_file(),
+                              connection_file=cf,
                               menu_actions=self.menu_actions)
         self.add_tab(client, name=client.get_name())
 
+        if cf is None:
+            error_msg = _("The directory {} is not writable and it is "
+                          "required to create IPython consoles. Please make "
+                          "it writable.").format(jupyter_runtime_dir())
+            client.show_kernel_error(error_msg)
+            return
+
         # Check if ipykernel is present in the external interpreter.
         # Else we won't be able to create a client
         if not CONF.get('main_interpreter', 'default'):
@@ -1359,7 +1367,10 @@ def _new_connection_file(self):
         """
         # Check if jupyter_runtime_dir exists (Spyder addition)
         if not osp.isdir(jupyter_runtime_dir()):
-            os.makedirs(jupyter_runtime_dir())
+            try:
+                os.makedirs(jupyter_runtime_dir())
+            except PermissionError:
+                return None
         cf = ''
         while not cf:
             ident = str(uuid.uuid4()).split('-')[-1]


Test patch:
Repository: spyder-ide/spyder

Issue:
Menu view/toolbar has empty contents
on my installs with spyder 3.0.1 and 3.0.2 the menuoption for toolbars is not showing.

the installs are fresh anaconda installs on windows 64-bit, and then an upgrade of spyder.
I think it worked with the 3.0.0, since I did change the toolbars on one computer,
but that is no longer possible.

did not directly find this mentioned anywhere - if it is a duplicate just close.



Discussion:
This is right. I don't know what happened with that menu.

@dalthviz, please solve this one.

Resolving patch:
diff --git a/spyder/utils/qthelpers.py b/spyder/utils/qthelpers.py
--- a/spyder/utils/qthelpers.py
+++ b/spyder/utils/qthelpers.py
@@ -303,9 +303,10 @@ def add_actions(target, actions, insert_before=None):
                 target.addMenu(action)
             else:
                 target.insertMenu(insert_before, action)
-        elif isinstance(action, SpyderAction):
-            if isinstance(target, QMenu) or not isinstance(target, QToolBar):
-                action = action.no_icon_action
+        elif isinstance(action, QAction):
+            if isinstance(action, SpyderAction):
+                if isinstance(target, QMenu) or not isinstance(target, QToolBar):
+                    action = action.no_icon_action
             if insert_before is None:
                 target.addAction(action)
             else:


Test patch:
Repository: spyder-ide/spyder

Issue:
Bad window size in spyder.ini prevents Spyder from showing
## Description of your problem

**What steps will reproduce the problem?**

1. enable dual monitors. move spyder to the right monitor. exit spyder.
2. disable the right monitor. (or connect over remote desktop)
3. load spyder.
- _alternatively, just edit your .spyder-py3/spyder.ini and `set window/position = (4134, 197)`_

**What is the expected output? What do you see instead?**
I expect to see spyder, but the window cannot be seen anywhere on the screen.

## Poor fix:
`I could spyder --reset`, but that loses lots of settings I spent a long time to set up.

## Best FIX (a developer should do this):
The last used window position is stored in my user folder /.spyder-py3/spyder.ini
Set the window position to a sane x,y pair like (100,100):
`window/position = (100, 100)`
It would be great if spyder could detect the width of the desktop, and if the window position X is greater than this width it decreases the number to compensate.

## Versions and main components

* Spyder Version: 3.0.2
* Python Version: 3.5.2
* Operating system: Windows 10



Discussion:
Thanks for reporting. We'll fix this for Spyder 3.1.

@dalthviz, please work on this one.
Hi @swharden as you are using Windows, for now, you can try to use the snapping shortcuts of Windows to work around the problem. Having Spyder as your current window use `Windows Key + left arrow` or `Windows Key + right arrow`. This will help you to find the main window of Spyder.

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -1319,6 +1319,17 @@ def load_window_settings(self, prefix, default=False, section='main'):
         else:
             hexstate = get_func(section, prefix+'state', None)
         pos = get_func(section, prefix+'position')
+        
+        # It's necessary to verify if the window/position value is valid 
+        # with the current screen. See issue 3748
+        width = pos[0]
+        height = pos[1]
+        screen_shape = QApplication.desktop().geometry()
+        current_width = screen_shape.width()
+        current_height = screen_shape.height()
+        if current_width < width or current_height < height:
+            pos = CONF.get_default(section, prefix+'position')
+        
         is_maximized =  get_func(section, prefix+'is_maximized')
         is_fullscreen = get_func(section, prefix+'is_fullscreen')
         return hexstate, window_size, prefs_dialog_size, pos, is_maximized, \


Test patch:
Repository: spyder-ide/spyder

Issue:
Problems with default extension in save_as
## Description of your problem

**What steps will reproduce the problem?**

1. Create a new file in editor
2. Try to save as the file

**What is the expected output? What do you see instead?**

It's expected that after of this PR #3580 extension by default be `*.py` instead of `*.6pl`

**Please provide any additional information below**

This had just been reported as repaired in #3625 by @ccordoba12 
> `it'll be part of Spyder 3.0.2 :-)`

## Versions and main components

* Spyder Version: 3.1.0
* Python Version: 3.5.2
* Operating system: LInux/Win

## Dependencies
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  None (NOK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.2 (OK)
pandas >=0.13.1  :  0.19.0 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  4.3.1 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.4.8 (OK)
sympy >=0.7.3    :  None (NOK)




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
@@ -116,8 +116,9 @@ def get_filter(filetypes, ext):
 def get_edit_filetypes():
     """Get all file types supported by the Editor"""
     pygments_exts = _get_pygments_extensions()
-    other_exts = ['.ipynb', '.md']
-    all_exts = tuple(pygments_exts + other_exts)
+    favorite_exts = ['.py', '.R', '.jl', '.ipynb', '.md', '.pyw', '.pyx', '.C', '.CPP']
+    other_exts = [ext for ext in pygments_exts if ext not in favorite_exts]
+    all_exts = tuple(favorite_exts + other_exts)
     text_filetypes = (_("Supported text files"), all_exts)
     return [text_filetypes] + EDIT_FILETYPES
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Replace contents of Find widget with current selection
After PR #3703, now it's not possible to replace the contents of the widget with the current selection in the Editor.

@dalthviz, please fix this behavior.


Discussion:

Resolving patch:
diff --git a/spyder/widgets/findreplace.py b/spyder/widgets/findreplace.py
--- a/spyder/widgets/findreplace.py
+++ b/spyder/widgets/findreplace.py
@@ -202,10 +202,11 @@ def show(self):
         self.visibility_changed.emit(True)
         if self.editor is not None:
             text = self.editor.get_selected_text()
-
+            highlighted = True
             # If no text is highlighted for search, use whatever word is under
             # the cursor
             if not text:
+                highlighted = False
                 try:
                     cursor = self.editor.textCursor()
                     cursor.select(QTextCursor.WordUnderCursor)
@@ -215,7 +216,7 @@ def show(self):
                     pass
 
             # Now that text value is sorted out, use it for the search
-            if text and not self.search_text.currentText():
+            if text and not self.search_text.currentText() or highlighted:
                 self.search_text.setEditText(text)
                 self.search_text.lineEdit().selectAll()
                 self.refresh()


Test patch:
Repository: spyder-ide/spyder

Issue:
Fast switch between files gives error for unicode files
## Fast switch between files Error
when have unicode in opened file name, and then
push “Fast switch between files (Ctrl+P)” on toolbar, Internal Console show:

>>> WARNING:traitlets:kernel restarted
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spyder/plugins/editor.py", line 1700, in call_file_switcher
    self.get_current_editorstack().open_fileswitcher_dlg()
  File "/usr/local/lib/python2.7/dist-packages/spyder/widgets/editor.py", line 590, in open_fileswitcher_dlg
    self.fileswitcher_dlg = FileSwitcher(self, self.tabs, self.data)
  File "/usr/local/lib/python2.7/dist-packages/spyder/widgets/fileswitcher.py", line 278, in __init__
    self.setup()
  File "/usr/local/lib/python2.7/dist-packages/spyder/widgets/fileswitcher.py", line 609, in setup
    self.setup_file_list(filter_text, current_path)
  File "/usr/local/lib/python2.7/dist-packages/spyder/widgets/fileswitcher.py", line 509, in setup_file_list
    text_item += "<br><i>{0:}</i>".format(short_paths[index])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-25: ordinal not in range(128)

no unicode, no error.

## Versions and main components
* Spyder Version: 3.0.2
* Python Version: 2.7.6
* Operating system: ubuntu linux

## Dependencies

Spyder 3.0.2 
Python 2.7.6 32bits, Qt 4.8.6, PyQt4 (API v2) 4.10.4 on Linux 



Discussion:
@dalthviz, please work on this one. It seems our switcher doesn't accept filenames with non-ascii characters on it.

Resolving patch:
diff --git a/spyder/widgets/fileswitcher.py b/spyder/widgets/fileswitcher.py
--- a/spyder/widgets/fileswitcher.py
+++ b/spyder/widgets/fileswitcher.py
@@ -506,7 +506,7 @@ def setup_file_list(self, filter_text, current_path):
                 if trying_for_line_number:
                     text_item += " [{0:} {1:}]".format(self.line_count[index],
                                                        _("lines"))
-                text_item += "<br><i>{0:}</i>".format(short_paths[index])
+                text_item += u"<br><i>{0:}</i>".format(short_paths[index])
                 results.append((score_value, index, text_item))
 
         # Sort the obtained scores and populate the list widget


Test patch:
Repository: spyder-ide/spyder

Issue:
Redefined hotkeys are not displayed in menu
## Description of your problem
Redefined hotkeys are not displayed in menu

**What steps will reproduce the problem?**

1. Redefine 'Transform to lowercase' ('Transform to uppercse' ) from default to say 'ctrl + [' ('ctrl + ]' ).
2. Apply new hotkeys
3. In the menu I see again default hotkeys, but functionality assigned to new hotkeys

**What is the expected output? What do you see instead?**

In menu I want to see new assignements for hotkeys

**Please provide any additional information below**

---
## Versions and main components

* Spyder Version: 3.0.2
* Python Version: python-3.6.0b4.amd64 (with WinPython distribution)
* Operating system: Win10, 1607, 14393.447


## 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.2 (OK)
pandas >=0.13.1  :  0.19.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.3.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-1 (OK)
sphinx >=0.6.6   :  1.4.8 (OK)
sympy >=0.7.3    :  1.0 (OK)




Discussion:
@malliwi88, please take a look at what's happening here.

Resolving patch:
diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py
--- a/spyder/plugins/editor.py
+++ b/spyder/plugins/editor.py
@@ -914,14 +914,18 @@ def get_plugin_actions(self):
                 triggered=self.unindent, context=Qt.WidgetShortcut)
 
         self.text_uppercase_action = create_action(self,
-                _("Toggle Uppercase"), "Ctrl+Shift+U",
+                _("Toggle Uppercase"),
                 tip=_("Change to uppercase current line or selection"),
                 triggered=self.text_uppercase, context=Qt.WidgetShortcut)
+        self.register_shortcut(self.text_uppercase_action, context="Editor",
+                               name="transform to uppercase")
 
         self.text_lowercase_action = create_action(self,
-                _("Toggle Lowercase"), "Ctrl+U",
+                _("Toggle Lowercase"),
                 tip=_("Change to lowercase current line or selection"),
                 triggered=self.text_lowercase, context=Qt.WidgetShortcut)
+        self.register_shortcut(self.text_lowercase_action, context="Editor",
+                               name="transform to lowercase")
         # ----------------------------------------------------------------------
         
         self.win_eol_action = create_action(self,


Test patch:
Repository: spyder-ide/spyder

Issue:
Interactive tour freezes Spyder on Windows
## Description of your problem

The interactive tour seems to 'hang' the spyder window when closing the tour.

**What steps will reproduce the problem?**
1. Start spyder (from master): python bootstrap.py
2. Run the interactive tour (Help --> Interactive tours --> Introduction tour)
3. Close the tour at any point.

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

Expected: you can continue working with spyder. Instead, window focus is lost, and the window totally freezes. I need to kill the python process in the process explorer.

**Please provide any additional information below**

This only happens on Windows. On Linux, it seems to work fine. Additionally, the 'interact: True' that you can provide when creating tours will not work on Windows (i.e., you can't interact with spyder during the tour), whereas this works on Linux.
## Versions and main components
- Spyder Version: master
- Python Version: 2.7 (PyQt 5.6.0) and 3.5 (PyQt 4.11.4 and 5.6.0 tested)
- Operating system: Windows 7
## Dependencies

Not relevant I think, but pasting for python 2.7: 
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  None (NOK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  None (NOK)
pandas >=0.13.1  :  None (NOK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.5.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4 (OK)
sphinx >=0.6.6   :  1.4.6 (OK)
sympy >=0.7.3    :  None (NOK)



Discussion:
Thanks for reporting. This will be fixed in 3.0.1 :-)

Oops, yes, Qt5 is making the tour behave in a weird fashion :-| 

Thanks for looking at this. To add a bit of information: it also happens with Qt4 (not only Qt5). Seems to work with PySide.

@mariacamilaremolinagutierrez, this is a very ugly bug. Please investigate how to solve it :-)


Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -946,9 +946,6 @@ def trigger(i=i, self=self):  # closure needed!
 
         self.tours_menu.addActions(self.tour_menu_actions)
 
-        if not DEV:
-            self.tours_menu = None
-
         self.help_menu_actions = [doc_action, tut_action, self.tours_menu,
                                   None, report_action, dep_action,
                                   self.check_updates_action, support_action,
diff --git a/spyder/app/tour.py b/spyder/app/tour.py
--- a/spyder/app/tour.py
+++ b/spyder/app/tour.py
@@ -917,7 +917,6 @@ def _moved(self, event):
 
     def _close_canvas(self):
         """ """
-        self._set_modal(False, [self.tips])
         self.tips.hide()
         self.canvas.fade_out(self.canvas.hide)
 


Test patch:
Repository: spyder-ide/spyder

Issue:
runfile with path containing apostrophe will not work
## Description of your problem
Running Spyder Python code with F5 causes issues

**What steps will reproduce the problem?**

1. Create a python file in a directory where path has apostrophe
2. Run Code


**What is the expected output? What do you see instead?**
Expect code to run. See this instead:

runfile('D:/Jordan/'s Files/Documents/Dropbox/Coding/Project Euler/prob19.py', wdir='D:/Jordan/'s Files/Documents/Dropbox/Coding/Project Euler')
  File "<ipython-input-1-17c71c4f374e>", line 1
    runfile('D:/Jordan/'s Files/Documents/Dropbox/Coding/Project Euler/prob19.py', wdir='D:/Jordan/'s Files/Documents/Dropbox/Coding/Project Euler')
                        ^
SyntaxError: invalid syntax

**Please provide any additional information below**
I notice that if I run my code out of a path that doesn't include apostrophe, that my code will run. Example: "C:/code" is a directory where things work.

## Versions and main components

* Spyder Version: 3.0.2
* Python Version: Python Anaconda. Python 2.7.12
* Operating system: Win 10 64 bit


## 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.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.5.0 :  1.2.3 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4 (OK)
sphinx >=0.6.6   :  1.4.1 (OK)
sympy >=0.7.3    :  1.0 (OK)



Discussion:
Thanks for reporting. we'll fix this for Spyder 3.1.

@dalthviz, please work on this one.
Sorry @dalthviz, let's assign this one to Camilo.

@camendoza94, please work on this one.

Resolving patch:
diff --git a/spyder/utils/misc.py b/spyder/utils/misc.py
--- a/spyder/utils/misc.py
+++ b/spyder/utils/misc.py
@@ -160,6 +160,7 @@ def remove_backslashes(path):
             path = path[:-1]
         # Replacing backslashes by slashes
         path = path.replace('\\', '/')
+        path = path.replace('/\'', '\\\'')
     return path
 
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Edit menu shortcuts are invisible
On Macos with the latest dev version, shortcuts for the edit menu are not visible

<img width="229" alt="screen shot 2016-11-03 at 3 39 36 pm" src="https://cloud.githubusercontent.com/assets/3627835/19982277/d679059a-a1db-11e6-9aac-7f62f5824fac.png">



Discussion:
They are disabled because you need to have something selected for Copy and Cut, and also something to make a Redo.

I don't see a problem with that :-)

No, I mean there is no shortcut! What is the shortcut for Indent? or for toggel Uppercase

I said visible, not disabled...

Ohhh, is it for all menus or just the Edit one?

Only edit :-|


Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -1117,8 +1117,8 @@ def add_ipm_action(text, path):
         # This is a workaround because we can't disable shortcuts
         # by setting context=Qt.WidgetShortcut there
         if sys.platform == 'darwin':
-            for name in ['file', 'search', 'source', 'run', 'debug',
-                         'plugins']:
+            for name in ['file', 'edit', 'search', 'source', 'run', 'debug',
+                         'projects', 'tools', 'plugins']:
                 menu_object = getattr(self, name + '_menu')
                 menu_object.aboutToShow.connect(
                     lambda name=name: self.show_shortcuts(name))


Test patch: