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

Issue:
Allow kernel specs to specify langauge specific help menu items
Right now the link in our Help menu in the notebook are hard coded to Python specific things. Other kernels should be able to customize these links in the kernelspec JSON data and we should ship these links in our own kernel specs. This will allow us to point to Python 2/3 docs separately.



Discussion:

Resolving patch:
diff --git a/IPython/kernel/zmq/ipkernel.py b/IPython/kernel/zmq/ipkernel.py
--- a/IPython/kernel/zmq/ipkernel.py
+++ b/IPython/kernel/zmq/ipkernel.py
@@ -7,7 +7,7 @@
 from IPython.core import release
 from IPython.utils.py3compat import builtin_mod, PY3
 from IPython.utils.tokenutil import token_at_cursor, line_at_cursor
-from IPython.utils.traitlets import Instance, Type, Any
+from IPython.utils.traitlets import Instance, Type, Any, List
 from IPython.utils.decorators import undoc
 
 from ..comm import CommManager
@@ -70,6 +70,37 @@ def __init__(self, **kwargs):
         comm_msg_types = [ 'comm_open', 'comm_msg', 'comm_close' ]
         for msg_type in comm_msg_types:
             self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)
+    
+    help_links = List([
+        {
+            'text': "Python",
+            'url': "http://docs.python.org/%i.%i" % sys.version_info[:2],
+        },
+        {
+            'text': "IPython",
+            'url': "http://ipython.org/documentation.html",
+        },
+        {
+            'text': "NumPy",
+            'url': "http://docs.scipy.org/doc/numpy/reference/",
+        },
+        {
+            'text': "SciPy",
+            'url': "http://docs.scipy.org/doc/scipy/reference/",
+        },
+        {
+            'text': "Matplotlib",
+            'url': "http://matplotlib.org/contents.html",
+        },
+        {
+            'text': "SymPy",
+            'url': "http://docs.sympy.org/latest/index.html",
+        },
+        {
+            'text': "pandas",
+            'url': "http://pandas.pydata.org/pandas-docs/stable/",
+        },
+    ])
 
     # Kernel info fields
     implementation = 'ipython'
diff --git a/IPython/kernel/zmq/kernelbase.py b/IPython/kernel/zmq/kernelbase.py
--- a/IPython/kernel/zmq/kernelbase.py
+++ b/IPython/kernel/zmq/kernelbase.py
@@ -63,6 +63,9 @@ def _ident_default(self):
     # This should be overridden by wrapper kernels that implement any real
     # language.
     language_info = {}
+    
+    # any links that should go in the help menu
+    help_links = List()
 
     # Private interface
     
@@ -457,6 +460,7 @@ def kernel_info(self):
             'implementation_version': self.implementation_version,
             'language_info': self.language_info,
             'banner': self.banner,
+            'help_links': self.help_links,
         }
 
     def kernel_info_request(self, stream, ident, parent):


Test patch:
Repository: ipython/ipython

Issue:
Floating widgets should be created at the point of code execution, not atop the page
I tried running the example notebook `examples/Interactive Widgets/Variable Inspector.ipynb`, and the variable inspector is created atop the page, invisible to the user. You need to scroll back up to find it.

This makes for pretty poor usabilit/discoverability.  I think we should try to fix it before 3.0, if possible at all. But I don't know how much it would require a big overhaul of the scrolling model, which I know has been already the source of lots of grief. Perhaps @jdfreder has some thoughts here?



Discussion:

Resolving patch:
diff --git a/IPython/html/widgets/__init__.py b/IPython/html/widgets/__init__.py
--- a/IPython/html/widgets/__init__.py
+++ b/IPython/html/widgets/__init__.py
@@ -2,7 +2,7 @@
 
 from .widget_bool import Checkbox, ToggleButton
 from .widget_button import Button
-from .widget_box import Box, Popup, FlexBox, HBox, VBox
+from .widget_box import Box, FlexBox, HBox, VBox
 from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider
 from .widget_image import Image
 from .widget_int import IntText, BoundedIntText, IntSlider, IntProgress, IntRangeSlider
@@ -16,7 +16,7 @@
 # Deprecated classes
 from .widget_bool import CheckboxWidget, ToggleButtonWidget
 from .widget_button import ButtonWidget
-from .widget_box import ContainerWidget, PopupWidget
+from .widget_box import ContainerWidget
 from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget
 from .widget_image import ImageWidget
 from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget
diff --git a/IPython/html/widgets/widget_box.py b/IPython/html/widgets/widget_box.py
--- a/IPython/html/widgets/widget_box.py
+++ b/IPython/html/widgets/widget_box.py
@@ -45,15 +45,6 @@ def _fire_children_displayed(self):
             child._handle_displayed()
 
 
-@register('IPython.Popup')
-class Popup(Box):
-    """Displays multiple widgets in an in page popup div."""
-    _view_name = Unicode('PopupView', sync=True)
-    
-    description = Unicode(sync=True)
-    button_text = Unicode(sync=True)
-
-
 @register('IPython.FlexBox')
 class FlexBox(Box):
     """Displays multiple widgets using the flexible box model."""
@@ -87,5 +78,3 @@ def HBox(*pargs, **kwargs):
 
 # Remove in IPython 4.0
 ContainerWidget = DeprecatedClass(Box, 'ContainerWidget')
-PopupWidget = DeprecatedClass(Popup, 'PopupWidget')
-


Test patch:
Repository: ipython/ipython

Issue:
Notebook menu File -> Download as -> PDF title should be notebook title
If you select File -> Download as -> PDF then every notebook has the title of "Notebook":

![screenshot from 2014-12-31 19 37 49](https://cloud.githubusercontent.com/assets/168568/5591357/ddb37f94-9124-11e4-9705-03d410e33f07.png)

This is very confusing when making handouts for students... they all have the title "Notebook"! The PDF should get the title of the notebook, whatever it is.



Discussion:

Resolving patch:
diff --git a/IPython/html/nbconvert/handlers.py b/IPython/html/nbconvert/handlers.py
--- a/IPython/html/nbconvert/handlers.py
+++ b/IPython/html/nbconvert/handlers.py
@@ -16,6 +16,7 @@
 from IPython.nbformat import from_dict
 
 from IPython.utils.py3compat import cast_bytes
+from IPython.utils import text
 
 def find_resource_files(output_files_dir):
     files = []
@@ -87,9 +88,18 @@ def get(self, format, path):
             raise web.HTTPError(400, "Not a notebook: %s" % path)
 
         self.set_header('Last-Modified', model['last_modified'])
-        
+
         try:
-            output, resources = exporter.from_notebook_node(model['content'])
+            output, resources = exporter.from_notebook_node(
+                model['content'],
+                resources={
+                    "metadata": {
+                        "name": name[:name.rfind('.')],
+                        "modified_date": (model['last_modified']
+                            .strftime(text.date_format))
+                    }
+                }
+            )
         except Exception as e:
             raise web.HTTPError(500, "nbconvert failed: %s" % e)
 
diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py
--- a/IPython/nbconvert/exporters/exporter.py
+++ b/IPython/nbconvert/exporters/exporter.py
@@ -241,7 +241,9 @@ def _init_resources(self, resources):
         #Make sure the metadata extension exists in resources
         if 'metadata' in resources:
             if not isinstance(resources['metadata'], ResourcesDict):
-                resources['metadata'] = ResourcesDict(resources['metadata'])
+                new_metadata = ResourcesDict()
+                new_metadata.update(resources['metadata'])
+                resources['metadata'] = new_metadata
         else:
             resources['metadata'] = ResourcesDict()
             if not resources['metadata']['name']:


Test patch:
Repository: ipython/ipython

Issue:
Markdown output in nbconvert
Markdown object rendering as `<IPython.core.display.Markdown object>`

in NBViewer and in HTML after using NBConvert

I believe the fix should be added here https://github.com/ipython/ipython/blob/482c7bd67eb06652b9a89b4bf4e034a40cf0b61c/IPython/nbconvert/templates/skeleton/display_priority.tpl

need to add case for text/markdown

and here
https://github.com/ipython/ipython/blob/master/IPython/nbconvert/templates/html/basic.tpl



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
@@ -1,16 +1,7 @@
 """HTML Exporter class"""
 
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
+# Copyright (c) IPython Development Team.
 # Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
 
 import os
 
@@ -46,7 +37,7 @@ def _template_file_default(self):
     def default_config(self):
         c = Config({
             'NbConvertBase': {
-                'display_data_priority' : ['text/javascript', 'text/html', 'application/pdf', 'image/svg+xml', 'text/latex', 'image/png', 'image/jpeg', 'text/plain']
+                'display_data_priority' : ['text/javascript', 'text/html', 'text/markdown', 'application/pdf', 'image/svg+xml', 'text/latex', 'image/png', 'image/jpeg', 'text/plain']
                 },
             'CSSHTMLHeaderPreprocessor':{
                 'enabled':True


Test patch:
Repository: ipython/ipython

Issue:
warn_format_error no longer makes it clear that there was a problem formatting the output
The recent changes to `warn_format_error` seem to have made it useless: one can no longer see the difference between a failed command and the failure to print the output.

Currently, if formatting fails, `warn_format_error` shows the exception with traceback which looks indistinguishable to a normal traceback when a command failed.

At the very least, the name `warn_format_error` no longer fits what it does.



Discussion:
Downstream bug: http://trac.sagemath.org/ticket/17419


Resolving patch:
diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py
--- a/IPython/core/formatters.py
+++ b/IPython/core/formatters.py
@@ -218,8 +218,8 @@ class FormatterWarning(UserWarning):
     """Warning class for errors in formatters"""
 
 @decorator
-def warn_format_error(method, self, *args, **kwargs):
-    """decorator for warning on failed format call"""
+def catch_format_error(method, self, *args, **kwargs):
+    """show traceback on failed format call"""
     try:
         r = method(self, *args, **kwargs)
     except NotImplementedError:
@@ -322,7 +322,7 @@ class BaseFormatter(Configurable):
     # Map (modulename, classname) pairs to the format functions.
     deferred_printers = Dict(config=True)
     
-    @warn_format_error
+    @catch_format_error
     def __call__(self, obj):
         """Compute the format for an object."""
         if self.enabled:
@@ -675,7 +675,7 @@ def _deferred_printers_default(self):
 
     #### FormatterABC interface ####
 
-    @warn_format_error
+    @catch_format_error
     def __call__(self, obj):
         """Compute the pretty representation of the object."""
         if not self.pprint:
@@ -887,7 +887,7 @@ class IPythonDisplayFormatter(BaseFormatter):
     _return_type = (type(None), bool)
     
 
-    @warn_format_error
+    @catch_format_error
     def __call__(self, obj):
         """Compute the format for an object."""
         if self.enabled:


Test patch:
Repository: ipython/ipython

Issue:
%run magic on ipynb continues after a cell has an exception
When you run an .ipynb file with the %run magic, and a cell generates an exception, the remaining cells continue to run. This can have unexpected outcomes as subsequent cells typically rely on results from the cell that generated the exception. It is also inconsistent with the behaviour of 'run all' when viewing a notebook and with the behaviour when running a .py file (probably .ipy also..).

It would be good at least to have the option to halt when an exception is thrown, but ihmo it'd probably be best to simply stop execution of the remaining cells if an exception is thrown.

I'm working on ipython 2.0.0 (the tag in the repo with that name) as I need the --script functionality (which at last check had been disabled in the head version), so apologies if this is resolved in the head version.

For the record, this is related to #4452



Discussion:
I think the right solution is to run all cells at the same time, not one by one.

Would reporting the line number of an exception be tricky in that case? If they were all run together, would the reported line number refer to the concatenation of the contents of all cells? 
The ideal would be to report something to indicate which cell, and the line number within the cell. 


Resolving patch:
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -2703,7 +2703,9 @@ def get_cells():
                     # raised in user code.  It would be nice if there were
                     # versions of run_cell that did raise, so
                     # we could catch the errors.
-                    self.run_cell(cell, silent=True, shell_futures=shell_futures)
+                    result = self.run_cell(cell, silent=True, shell_futures=shell_futures)
+                    if not result.success:
+                        break
             except:
                 self.showtraceback()
                 warn('Unknown failure executing file: <%s>' % fname)


Test patch:
Repository: ipython/ipython

Issue:
Save notebooks with terminal newline (option)
Maybe this feature already exists and I don't know it, in which case please clue me in.

It would be nice to save iPython notebooks with a newline before EOF. As whitespace isn't significant in JSON, this should remain valid JSON.

If there is some other reason that this shouldn't be standard, could we at least have an option perhaps in ~/.ipython somewhere?

Thanks.



Discussion:

Resolving patch:
diff --git a/IPython/nbformat/__init__.py b/IPython/nbformat/__init__.py
--- a/IPython/nbformat/__init__.py
+++ b/IPython/nbformat/__init__.py
@@ -158,4 +158,6 @@ def write(nb, fp, version=NO_CONVERT, **kwargs):
     s = writes(nb, version, **kwargs)
     if isinstance(s, bytes):
         s = s.decode('utf8')
-    return fp.write(s)
+    fp.write(s)
+    if not s.endswith(u'\n'):
+        fp.write(u'\n')


Test patch:
Repository: ipython/ipython

Issue:
nbformat v2 notebook with missing 'stream' key in stream outputs
@stefanv just sent me an nbformat 2 notebook which was missing the 'stream' keys in stream outputs, and failed to open in current master because of this.

@minrk , can you remember if that was ever a valid option in the notebook format? If so, we should support it. If not, we can write it off as having been saved by some broken development version of IPython. 



Discussion:
It has never been valid, but it can be fixed easily enough, so might as well handle it.


Resolving patch:
diff --git a/IPython/nbformat/v4/convert.py b/IPython/nbformat/v4/convert.py
--- a/IPython/nbformat/v4/convert.py
+++ b/IPython/nbformat/v4/convert.py
@@ -186,7 +186,7 @@ def upgrade_output(output):
     elif output['output_type'] == 'pyerr':
         output['output_type'] = 'error'
     elif output['output_type'] == 'stream':
-        output['name'] = output.pop('stream')
+        output['name'] = output.pop('stream', 'stdout')
     return output
 
 def downgrade_output(output):


Test patch:
Repository: ipython/ipython

Issue:
Latex tab completions leave extra backslash in terminal console
In `ipython console`:

```
\alp<TAB> -> \\alpha
\alpha<TAB> -> \α
```

In both cases, there's a backslash left over that shouldn't be there. It works in the notebook and the Qt console.



Discussion:
This appears to be fixed.

I can still reproduce the failure.

My mistake. Bug does not affect greedy completion, only `greedy=False`.


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
@@ -29,13 +29,18 @@ def __init__(self, shell, client, config=None):
         self.shell = shell
         self.client =  client
         self.matches = []
-        
+        # don't do any splitting client-side,
+        # rely on the kernel for that
+        self.splitter.delims = '\r\n'
+        if self.readline:
+            self.readline.set_completer_delims('\r\n')
+    
     def complete_request(self, text):
         line = readline.get_line_buffer()
         cursor_pos = readline.get_endidx()
         
         # send completion request to kernel
-        # Give the kernel up to 0.5s to respond
+        # Give the kernel up to 5s to respond
         msg_id = self.client.complete(
             code=line,
             cursor_pos=cursor_pos,
@@ -43,7 +48,8 @@ def complete_request(self, text):
         
         msg = self.client.shell_channel.get_msg(timeout=self.timeout)
         if msg['parent_header']['msg_id'] == msg_id:
-            return msg["content"]["matches"]
+            cursor_start = msg['content']['cursor_start']
+            return [ line[:cursor_start] + m for m in msg['content']['matches'] ]
         return []
     
     def rlcomplete(self, text, state):


Test patch:
Repository: ipython/ipython

Issue:
Cell magics fail to switch the language
To reproduce, create a notebook with a cell like this:

```
%%sh
a=${HOME}
echo $a
```

Select File / Print Preview.  Observe the red boxes around `$`'s.

``` html
..
<span class="n">a</span>
<span class="o">=</span>
<span class="err">$</span>
<span class="p">{</span>
<span class="n">HOME</span>
<span class="p">}</span>
..
```

I am using Python 3.4.2 and IPython 3.0.0-dev.



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
@@ -113,7 +113,7 @@ def _pygments_highlight(source, output_formatter, language='ipython', metadata=N
 
     # If the cell uses a magic extension language,
     # use the magic language instead.
-    if language == 'ipython' \
+    if language.startswith('ipython') \
         and metadata \
         and 'magics_language' in metadata:
 


Test patch:
Repository: ipython/ipython

Issue:
description keyword for interactive widget 
When I use the keyword description with interact

``` python
from IPython.html import widgets
def simpleFunction(a):
    print a

i = interact(simpleFunction, 
                  a=widgets.FloatSliderWidget(values=(0,10), description='A label for my widget'))
```

I get this error

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: simpleFunction() got an unexpected keyword argument 'A label for my widget'
```



Discussion:

Resolving patch:
diff --git a/IPython/html/widgets/interaction.py b/IPython/html/widgets/interaction.py
--- a/IPython/html/widgets/interaction.py
+++ b/IPython/html/widgets/interaction.py
@@ -155,6 +155,7 @@ def _widgets_from_abbreviations(seq):
         widget = _widget_from_abbrev(abbrev, default)
         if not widget.description:
             widget.description = name
+        widget._kwarg = name
         result.append(widget)
     return result
 
@@ -194,7 +195,7 @@ def call_f(name=None, old=None, new=None):
         container.kwargs = {}
         for widget in kwargs_widgets:
             value = widget.value
-            container.kwargs[widget.description] = value
+            container.kwargs[widget._kwarg] = value
         if co:
             clear_output(wait=True)
         if manual:


Test patch:
diff --git a/IPython/html/widgets/tests/test_interaction.py b/IPython/html/widgets/tests/test_interaction.py
--- a/IPython/html/widgets/tests/test_interaction.py
+++ b/IPython/html/widgets/tests/test_interaction.py
@@ -489,13 +489,20 @@ def test_default_description():
     )
 
 def test_custom_description():
-    c = interactive(f, b=widgets.Text(value='text', description='foo'))
+    d = {}
+    def record_kwargs(**kwargs):
+        d.clear()
+        d.update(kwargs)
+    
+    c = interactive(record_kwargs, b=widgets.Text(value='text', description='foo'))
     w = c.children[0]
     check_widget(w,
         cls=widgets.Text,
         value='text',
         description='foo',
     )
+    w.value = 'different text'
+    nt.assert_equal(d, {'b': 'different text'})
 
 def test_interact_manual_button():
     c = interactive(f, __manual=True)
Repository: ipython/ipython

Issue:
Displaying a widget using displayhook produces misaligned Out[N] prompt
![screenshot from 2015-01-22 16 56 44](https://cloud.githubusercontent.com/assets/327925/5867960/bd98d2d8-a257-11e4-8599-e0e331664f9b.png)

This doesn't look right. @jdfreder, can you investigate?



Discussion:
The out prompt is in the right place, but it shouldn't be drawn since there isn't actually any output.


Resolving patch:
diff --git a/IPython/kernel/zmq/displayhook.py b/IPython/kernel/zmq/displayhook.py
--- a/IPython/kernel/zmq/displayhook.py
+++ b/IPython/kernel/zmq/displayhook.py
@@ -68,6 +68,7 @@ def finish_displayhook(self):
         """Finish up all displayhook activities."""
         sys.stdout.flush()
         sys.stderr.flush()
-        self.session.send(self.pub_socket, self.msg, ident=self.topic)
+        if self.msg['content']['data']:
+            self.session.send(self.pub_socket, self.msg, ident=self.topic)
         self.msg = None
 


Test patch:
Repository: ipython/ipython

Issue:
IPython should specify pygments entry points for its lexers
IPython implements a few pygments lexers - IPyLexer, IPythonTracebackLexer, etc., but does not install pygments entry points, so these lexers cannot be used with the pygmentize command.

Having them available to pygmentize will be helpful because pygmentize has some features that are not available from from nbconvert.



Discussion:

Resolving patch:
diff --git a/IPython/nbconvert/utils/lexers.py b/IPython/nbconvert/utils/lexers.py
--- a/IPython/nbconvert/utils/lexers.py
+++ b/IPython/nbconvert/utils/lexers.py
@@ -87,7 +87,7 @@ def build_ipy_lexer(python3):
     tokens = PyLexer.tokens.copy()
     tokens['root'] = ipython_tokens + tokens['root']
 
-    attrs = {'name': name, 'aliases': aliases,
+    attrs = {'name': name, 'aliases': aliases, 'filenames': [],
              '__doc__': doc, 'tokens': tokens}
 
     return type(name, (PyLexer,), attrs)
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -286,7 +286,14 @@ def run(self):
     setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(get_bdist_wheel())
     
     setuptools_extra_args['zip_safe'] = False
-    setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()}
+    setuptools_extra_args['entry_points'] = {
+        'console_scripts': find_entry_points(),
+        'pygments.lexers': [
+            'ipythonconsole = IPython.nbconvert.utils.lexers:IPythonConsoleLexer',
+            'ipython = IPython.nbconvert.utils.lexers:IPythonLexer',
+            'ipython3 = IPython.nbconvert.utils.lexers:IPython3Lexer',
+        ],
+    }
     setup_args['extras_require'] = extras_require
     requires = setup_args['install_requires'] = install_requires
 


Test patch: