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

Issue:
non-python kernels run python code with qtconsole
When launching the qtconsole with a non-python kernel it crashes immediately since the frontend [requests that the following code is run by the kernel](https://github.com/ipython/ipython/blob/master/IPython/qt/console/ipython_widget.py#L276):

```
try:
    _usage
except:
    from IPython.core import usage as _usage
    get_ipython().register_magic_function(_usage.page_guiref, 'line', 'guiref')
    del _usage
```

obviously only python kernels understand and can execute this.

Either we
- check the language of the kernel first (with a `kernel_info_request` message).
- find another way to register the magic functions for python kernels.



Discussion:
I think following a kernel_info request is a good idea.


Resolving patch:
diff --git a/IPython/qt/console/ipython_widget.py b/IPython/qt/console/ipython_widget.py
--- a/IPython/qt/console/ipython_widget.py
+++ b/IPython/qt/console/ipython_widget.py
@@ -135,6 +135,8 @@ def __init__(self, *args, **kw):
         else:
             self.set_default_style()
 
+        self._guiref_loaded = False
+
     #---------------------------------------------------------------------------
     # 'BaseFrontendMixin' abstract interface
     #---------------------------------------------------------------------------
@@ -258,10 +260,21 @@ def _handle_display_data(self, msg):
             # This newline seems to be needed for text and html output.
             self._append_plain_text(u'\n', True)
 
+    def _handle_kernel_info_reply(self, rep):
+        """ Handle kernel info replies.
+        """
+        if not self._guiref_loaded:
+            if rep['content']['language'] == 'python':
+                self._load_guiref_magic()
+            self._guiref_loaded = True
+
     def _started_channels(self):
         """Reimplemented to make a history request and load %guiref."""
         super(IPythonWidget, self)._started_channels()
-        self._load_guiref_magic()
+
+        # The reply will trigger %guiref load provided language=='python'
+        self.kernel_client.kernel_info()
+
         self.kernel_client.shell_channel.history(hist_access_type='tail',
                                                   n=1000)
     


Test patch:
Repository: ipython/ipython

Issue:
ipcluster bug in clean_logs flag
Setting clean_logs=True when using the IPClusterEngines application doesn't remove the log files.  The offending line is at parallel/apps/ipclusterapp.py line 404 in IPClusterEngines.start_logging() which looks like this:

```
if re.match(r'ip(engine|controller)z-\d+\.(log|err|out)',f):
```

The 'z' after controller) should be removed.



Discussion:

Resolving patch:
diff --git a/IPython/parallel/apps/ipclusterapp.py b/IPython/parallel/apps/ipclusterapp.py
--- a/IPython/parallel/apps/ipclusterapp.py
+++ b/IPython/parallel/apps/ipclusterapp.py
@@ -401,10 +401,8 @@ def start_logging(self):
         if self.clean_logs:
             log_dir = self.profile_dir.log_dir
             for f in os.listdir(log_dir):
-                if re.match(r'ip(engine|controller)z-\d+\.(log|err|out)',f):
+                if re.match(r'ip(engine|controller)-.+\.(log|err|out)',f):
                     os.remove(os.path.join(log_dir, f))
-        # This will remove old log files for ipcluster itself
-        # super(IPBaseParallelApplication, self).start_logging()
 
     def start(self):
         """Start the app for the engines subcommand."""


Test patch:
Repository: ipython/ipython

Issue:
parallel.Client() not using profile that notebook was run with?
I just updated some code that was using 0.13.1 to 1.1, and I noticed that even though I started the notebooks with a profile, when I did `rc = parallel.Client()` it looked in my default directory for the json connection files not the profile used to start the notebook. I had to specifically pass a profile keyword. Feature or bug?



Discussion:
I consider this to be a feature.

This is absolutely a bug. The logic is correct in parallel.Client, but there is a change in how the kernel is started, such that the profile name is always 'default', even when a different profile is loaded (by profile_dir path, not name).

I phrased my statement poorly. Can the client code even come up with a reasonable answer to what profile started the parallel cluster? This in general is different from the profile the main kernel is run under. 


Resolving patch:
diff --git a/IPython/core/application.py b/IPython/core/application.py
--- a/IPython/core/application.py
+++ b/IPython/core/application.py
@@ -322,6 +322,10 @@ def init_profile_dir(self):
                     self.exit(1)
             else:
                 self.log.info("Using existing profile dir: %r"%location)
+            # if profile_dir is specified explicitly, set profile name
+            dir_name = os.path.basename(p.location)
+            if dir_name.startswith('profile_'):
+                self.profile = dir_name[8:]
 
         self.profile_dir = p
         self.config_file_paths.append(p.location)


Test patch:
Repository: ipython/ipython

Issue:
greedy completer bug in terminal console
i'm back from finishing my thesis and i'm awed by the massive progress over the last few months. i'm particularly fond of the terminal 2-process frontend, which is super-useful to me. alas the greedy completer is not working properly in this mode. if i start a console session with greedy on, and then run

``` python
x = [0, 1, 2]
x[0].im<TAB>
```

it will autocomplete `imag`, but the next line will be

``` python
x[0]x[0].imag
```

which is obviously not right. this problem (rightfully) does not occur in the 1-process terminal or the qtconsole mode.

i remember this being an issue before in previous versions of ipython, but with the new structure i cannot see yet where this bug arises and how to solve it. best to ask an expert...



Discussion:

Resolving patch:
diff --git a/IPython/terminal/console/completer.py b/IPython/terminal/console/completer.py
--- a/IPython/terminal/console/completer.py
+++ b/IPython/terminal/console/completer.py
@@ -8,9 +8,10 @@
     from Queue import Empty  # Py 2
 
 from IPython.config import Configurable
+from IPython.core.completer import IPCompleter
 from IPython.utils.traitlets import Float
 
-class ZMQCompleter(Configurable):
+class ZMQCompleter(IPCompleter):
     """Client-side completion machinery.
 
     How it works: self.complete will be called multiple times, with


Test patch:
Repository: ipython/ipython

Issue:
stdout/stderr should be flushed printing exception output... 
![screen shot 2013-07-19 at 3 49 18 pm](https://f.cloud.github.com/assets/15093/829042/8fab0872-f0c5-11e2-95f7-b373e1e2eff6.png)



Discussion:
This is a good idea, and easy - the flush would just go in the top of `InteractiveShell.showtraceback`.


Resolving patch:
diff --git a/IPython/kernel/zmq/zmqshell.py b/IPython/kernel/zmq/zmqshell.py
--- a/IPython/kernel/zmq/zmqshell.py
+++ b/IPython/kernel/zmq/zmqshell.py
@@ -501,6 +501,9 @@ def ask_exit(self):
         self.payload_manager.write_payload(payload)
 
     def _showtraceback(self, etype, evalue, stb):
+        # try to preserve ordering of tracebacks and print statements
+        sys.stdout.flush()
+        sys.stderr.flush()
 
         exc_content = {
             u'traceback' : stb,


Test patch:
Repository: ipython/ipython

Issue:
display.FileLinks should work in the exported html verion of a notebook
It would be nice to have the output of FileLinks work in the exported html version of a notebook. 

Would this be as simple as using relative file-paths? 



Discussion:
This will be resolved in 2.0 when the `files/` prefix for serving local files is removed.

thanks for info.

It's okay to leave this open, since we haven't addressed it yet. We can close it when we actually fix the issue.


Resolving patch:
diff --git a/IPython/lib/display.py b/IPython/lib/display.py
--- a/IPython/lib/display.py
+++ b/IPython/lib/display.py
@@ -267,7 +267,7 @@ class FileLink(object):
 
     def __init__(self,
                  path,
-                 url_prefix='files/',
+                 url_prefix='',
                  result_html_prefix='',
                  result_html_suffix='<br>'):
         """
@@ -328,7 +328,7 @@ class FileLinks(FileLink):
     """
     def __init__(self,
                  path,
-                 url_prefix='files/',
+                 url_prefix='',
                  included_suffixes=None,
                  result_html_prefix='',
                  result_html_suffix='<br>',


Test patch:
diff --git a/IPython/lib/tests/test_display.py b/IPython/lib/tests/test_display.py
--- a/IPython/lib/tests/test_display.py
+++ b/IPython/lib/tests/test_display.py
@@ -47,7 +47,7 @@ def test_existing_path_FileLink():
     tf = NamedTemporaryFile()
     fl = display.FileLink(tf.name)
     actual = fl._repr_html_()
-    expected = "<a href='files/%s' target='_blank'>%s</a><br>" % (tf.name,tf.name)
+    expected = "<a href='%s' target='_blank'>%s</a><br>" % (tf.name,tf.name)
     nt.assert_equal(actual,expected)
 
 def test_existing_path_FileLink_repr():
@@ -93,9 +93,9 @@ def test_existing_path_FileLinks():
     # the links should always have forward slashes, even on windows, so replace
     # backslashes with forward slashes here
     expected = ["%s/<br>" % td,
-                "&nbsp;&nbsp;<a href='files/%s' target='_blank'>%s</a><br>" %\
+                "&nbsp;&nbsp;<a href='%s' target='_blank'>%s</a><br>" %\
                  (tf2.name.replace("\\","/"),split(tf2.name)[1]),
-                "&nbsp;&nbsp;<a href='files/%s' target='_blank'>%s</a><br>" %\
+                "&nbsp;&nbsp;<a href='%s' target='_blank'>%s</a><br>" %\
                  (tf1.name.replace("\\","/"),split(tf1.name)[1])]
     expected.sort()
     # We compare the sorted list of links here as that's more reliable
Repository: ipython/ipython

Issue:
overwrite? prompt gets EOFError in 2 process
#4582 fixes part of the problem with 2 process history saving, but if a file by that name already exists, we get an EOFError instead of a prompt for some reason, before the client is even able to respond.

If someone (@minrk or @takluyver) give me a way forward, I can add this as part of #4582, or just make a PR to my repo against _that_ branch.



Discussion:

Resolving patch:
diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py
--- a/IPython/utils/py3compat.py
+++ b/IPython/utils/py3compat.py
@@ -74,7 +74,11 @@ def safe_unicode(e):
 if sys.version_info[0] >= 3:
     PY3 = True
     
-    input = input
+    # keep reference to builtin_mod because the kernel overrides that value
+    # to forward requests to a frontend.
+    def input(prompt=''):
+        return builtin_mod.input(prompt)
+    
     builtin_mod_name = "builtins"
     import builtins as builtin_mod
     
@@ -131,7 +135,11 @@ def u_format(s):
 else:
     PY3 = False
     
-    input = raw_input
+    # keep reference to builtin_mod because the kernel overrides that value
+    # to forward requests to a frontend.
+    def input(prompt=''):
+        return builtin_mod.raw_input(prompt)
+    
     builtin_mod_name = "__builtin__"
     import __builtin__ as builtin_mod
     


Test patch:
Repository: ipython/ipython

Issue:
ipython parallel: scp failure.
Instead of throwing:

```
Command '['scp', u'/home/vash/.config/ipython/profile_ssh/security/ipcontroller-client.json',     u'vash@host:.config/ipython/profile_ssh/security/ipcontroller-client.json']'
```

Should try:

```
ssh user@host mkdir -p -- ".config/ipython/profile_ssh/security"
```



Discussion:
indeed it should. Can I ask what the `--` is for?

It's the limit between options/arguments and arguments list. After a double dash, ssh (and others commands) will not consider the arguments as possible options.

If you have the directory `-foo` on the current directory, and you  want to display this directory you need to make:

```
ls -- -foo
```

I knew it prevented option parsing, I hadn't thought of directory names being problematic there.  Thanks, I should have a PR for you before too long.


Resolving patch:
diff --git a/IPython/parallel/apps/launcher.py b/IPython/parallel/apps/launcher.py
--- a/IPython/parallel/apps/launcher.py
+++ b/IPython/parallel/apps/launcher.py
@@ -600,6 +600,11 @@ def _send_file(self, local, remote):
                 time.sleep(1)
             else:
                 break
+        remote_dir = os.path.dirname(remote)
+        self.log.info("ensuring remote %s:%s/ exists", self.location, remote_dir)
+        check_output(self.ssh_cmd + self.ssh_args + \
+            [self.location, 'mkdir', '-p', '--', remote_dir]
+        )
         self.log.info("sending %s to %s", local, remote)
         check_output(self.scp_cmd + [local, remote])
     
@@ -623,6 +628,9 @@ def _fetch_file(self, remote, local):
                 time.sleep(1)
             elif check == u'yes':
                 break
+        local_dir = os.path.dirname(local)
+        if not os.path.exists(local_dir):
+            os.makedirs(local_dir, 775)
         check_output(self.scp_cmd + [full_remote, local])
     
     def fetch_files(self):


Test patch:
Repository: ipython/ipython

Issue:
Message spec changes related to `clear_output`
This is a reminder for @minrk to:
- Increment the minor version of the message spec to reflect the changes to `clear_output`.
- Add handling in the JS code to gracefully handle the old `clear_output` messages.



Discussion:

Resolving patch:
diff --git a/IPython/core/release.py b/IPython/core/release.py
--- a/IPython/core/release.py
+++ b/IPython/core/release.py
@@ -39,7 +39,7 @@
 version_info = (_version_major, _version_minor, _version_patch, _version_extra)
 
 # Change this when incrementing the kernel protocol version
-kernel_protocol_version_info = (4, 0)
+kernel_protocol_version_info = (4, 1)
 
 description = "IPython: Productive Interactive Computing"
 


Test patch:
Repository: ipython/ipython

Issue:
node != nodejs within Debian packages
As part of resolving https://github.com/ipython/nbviewer/issues/196, (and https://github.com/ipython/nbviewer/pull/194), @ahmadia and I ended up finding out that Debian based Linux Distributions build the `node` binary as `nodejs`.

IPython nbconvert defaults to using `node`, which is actually `ax25-node` on Debian based systems. [See relevant posting on the Debian mailing list for more](https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html).

This won't affect users of nvm (who provide `node`) or those who build from source. This will affect certain strains of Ubuntu (Saucy Salamander was what I used to test).



Discussion:
`ax25-node` will typically produce no outputs:

```
root@qa01:/usr/share/nbviewer# echo 'hi' | node venv/src/ipython/IPython/nbconvert/filters/marked.js
root@qa01:/usr/share/nbviewer# echo 'hi' | nodejs venv/src/ipython/IPython/nbconvert/filters/marked.js
<p>hi</p>
```

Awesome.

Can we ignore the node case, and just prefer nodejs and fallback on node? I do not want to handle the case of a system that has `node` that is not `nodejs`, that is just not worth our time.

> Can we ignore the node case, and just prefer nodejs and fallback on node? I do not want to handle the case of a system that has node that is not nodejs, that is just not worth our time.

+1

Relevant code is at bottom of IPython/nbconvert/filters/markdown.py

PR or do you want to handle this yourself?


Resolving patch:
diff --git a/IPython/nbconvert/filters/markdown.py b/IPython/nbconvert/filters/markdown.py
--- a/IPython/nbconvert/filters/markdown.py
+++ b/IPython/nbconvert/filters/markdown.py
@@ -67,7 +67,7 @@ def markdown2html_pandoc(source):
 
 def markdown2html_marked(source, encoding='utf-8'):
     """Convert a markdown string to HTML via marked"""
-    command = ['node', marked]
+    command = [node_cmd, marked]
     try:
         p = subprocess.Popen(command,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE
@@ -99,9 +99,18 @@ def markdown2rst(source):
     """
     return pandoc(source, 'markdown', 'rst')
 
+# prefer md2html via marked if node.js is available
+# node is called nodejs on debian, so try that first
+node_cmd = 'nodejs'
 try:
-    find_cmd('node')
+    find_cmd(node_cmd)
 except FindCmdError:
-    markdown2html = markdown2html_pandoc
+    node_cmd = 'node'
+    try:
+        find_cmd(node_cmd)
+    except FindCmdError:
+        markdown2html = markdown2html_pandoc
+    else:
+        markdown2html = markdown2html_marked
 else:
     markdown2html = markdown2html_marked


Test patch:
Repository: ipython/ipython

Issue:
AttributeError: 'module' object has no attribute '_outputfile'
```
    io.stdout = io.stderr = io.IOStream(self.readline._outputfile)
AttributeError: 'module' object has no attribute '_outputfile'
```

After installing the latest from dev I get the above resultant error when trying to start the ipython interpreter from the command line. 

Removing the dev build and installing version 1.2 from pip allows me to run the interpreter but notebook exhibits issues. Notebook won't respect interrupts in the window from which it was started. And any notebook that is opened won't run a cell.

Reinstalling the dev build brings back notebook functionality but breaks the command line interpreter.



Discussion:

Resolving patch:
diff --git a/IPython/utils/rlineimpl.py b/IPython/utils/rlineimpl.py
--- a/IPython/utils/rlineimpl.py
+++ b/IPython/utils/rlineimpl.py
@@ -13,8 +13,6 @@
 import warnings
 
 _rlmod_names = ['gnureadline', 'readline']
-if sys.platform == 'win32' or sys.platform == 'cli':
-    _rlmod_names.append('pyreadline')
 
 have_readline = False
 for _rlmod_name in _rlmod_names:
@@ -29,7 +27,7 @@
         have_readline = True
         break
 
-if _rlmod_name == 'pyreadline':
+if sys.platform == 'win32' or sys.platform == 'cli':
     try:
         _outputfile=_rl.GetOutputFile()
     except AttributeError:


Test patch:
Repository: ipython/ipython

Issue:
Audit nbconvert HTML output
The HTML output of nbconvert should exactly match that of the live notebook. We need to do a careful diff of these two to make sure the tags and attributes match.



Discussion:

Resolving patch:
diff --git a/IPython/nbconvert/filters/highlight.py b/IPython/nbconvert/filters/highlight.py
--- a/IPython/nbconvert/filters/highlight.py
+++ b/IPython/nbconvert/filters/highlight.py
@@ -56,7 +56,7 @@ def __call__(self, source, language=None, metadata=None):
         if not language:
             language=self.default_language
 
-        return _pygments_highlight(source, HtmlFormatter(), language, metadata)
+        return _pygments_highlight(source if len(source) > 0 else ' ', HtmlFormatter(), language, metadata)
 
 
 class Highlight2Latex(NbConvertBase):


Test patch:
diff --git a/IPython/nbconvert/tests/README.md b/IPython/nbconvert/tests/README.md
new file mode 100644
--- /dev/null
+++ b/IPython/nbconvert/tests/README.md
@@ -0,0 +1 @@
+To compare nbconvert html output to the notebook's native html see https://gist.github.com/9241376.git.
Repository: ipython/ipython

Issue:
Add JavaScript to nbconvert HTML display priority
Right now JavaScript output does not show up in HTML output in nbconvert. We need to add this to the display priority in nbconvert for all HTML output types.



Discussion:

Resolving patch:
diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py
--- a/IPython/nbconvert/exporters/html.py
+++ b/IPython/nbconvert/exporters/html.py
@@ -45,6 +45,9 @@ def _template_file_default(self):
     @property
     def default_config(self):
         c = Config({
+            'NbConvertBase': {
+                'display_data_priority' : ['javascript', 'html', 'application/pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text']
+                },
             'CSSHTMLHeaderPreprocessor':{
                 'enabled':True
                 },


Test patch:
Repository: ipython/ipython

Issue:
TypeError in bootstrap-tour.min.js
Two minor issues:
1. When pressing `cursor left` in edit mode on current master I get:

```
TypeError: c is undefined
...ame+"_"+a,this._options.storage.removeItem(b),this._options.afterRemoveState(b))...
```

in `http://127.0.0.1:8889/static/components/bootstrap-tour/build/js/bootstrap-tour.min.js`
1. Also, `bootstrap-tour.min.css` isn't copied during installation (the .js file is).



Discussion:

Resolving patch:
diff --git a/setupbase.py b/setupbase.py
--- a/setupbase.py
+++ b/setupbase.py
@@ -149,6 +149,7 @@ def find_package_data():
     static_data.extend([
         pjoin(components, "backbone", "backbone-min.js"),
         pjoin(components, "bootstrap", "bootstrap", "js", "bootstrap.min.js"),
+        pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
         pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
         pjoin(components, "font-awesome", "font", "*.*"),
         pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),


Test patch:
Repository: ipython/ipython

Issue:
Unexpected and new conflict between PyFileConfigLoader and IPythonQtConsoleApp
Up to IPython 1.2.1, I was able to add coloring to embedded, in-process Qt consoles essentially by adding the following patch to `examples/inprocess/embedded_qtconsole.py`:

```
    from IPython.config.loader import PyFileConfigLoader
    from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
    config = PyFileConfigLoader("/path/to/ipython_qtconsole_config.py").load_config()
    IPythonQtConsoleApp.instance(config=config).init_colors(control)
```

(after instantiating the `control` widget).

When I tried the same with 2.0.0b1, the instantiation of `IPythonQtConsoleApp` failed with the following exception:

```
IPython.config.configurable.MultipleInstanceError: Multiple incompatible subclass instances of IPythonQtConsoleApp are being created.
```

Interestingly, not loading `config` (i.e., removing the 3rd line and `config=config` in the 4th line) gets rid of the error (although it gets rid of the ability of loading a config file too...).



Discussion:
This is probably a bug (inappropriate use of `instance` somewhere in Loader, I expect), but there's no reason that you would need to instantiate PyFileConfigLoader yourself:

``` python
app = IPythonQtConsoleApp.instance()
app.load_config_file("/path/to/config.py")
```


Resolving patch:
diff --git a/IPython/config/configurable.py b/IPython/config/configurable.py
--- a/IPython/config/configurable.py
+++ b/IPython/config/configurable.py
@@ -26,6 +26,7 @@
 # Imports
 #-----------------------------------------------------------------------------
 
+import logging
 from copy import deepcopy
 
 from .loader import Config, LazyConfigValue
@@ -381,6 +382,9 @@ class LoggingConfigurable(Configurable):
     log = Instance('logging.Logger')
     def _log_default(self):
         from IPython.config.application import Application
-        return Application.instance().log
+        if Application.initialized():
+            return Application.instance().log
+        else:
+            return logging.getLogger()
 
 
diff --git a/IPython/config/loader.py b/IPython/config/loader.py
--- a/IPython/config/loader.py
+++ b/IPython/config/loader.py
@@ -25,6 +25,7 @@
 
 import argparse
 import copy
+import logging
 import os
 import re
 import sys
@@ -308,7 +309,10 @@ class ConfigLoader(object):
 
     def _log_default(self):
         from IPython.config.application import Application
-        return Application.instance().log
+        if Application.initialized():
+            return Application.instance().log
+        else:
+            return logging.getLogger()
 
     def __init__(self, log=None):
         """A base class for config loaders.


Test patch: