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

Issue:
Attempting to interrupt the kernel while autocomplete is thinking crashes the runtime
Backstory: we've added some custom completers, some of which do things that amount to making a network request (say to find out the potential arguments to a function). Sometimes, this can be slow, and users are tempted to interrupt their kernel. Doing so then crashes the kernel.

Here's a really goofy repro:

```
def bad_completer(*args, **kwargs):
    import time
    time.sleep(10)
    return ['houses']

get_ipython().set_hook('complete_command', bad_completer, re_key='%%file')

%%file <TAB>
```

and then interrupt while you're waiting.

A naive fix would be to simply catch any exception [here](https://github.com/ipython/ipython/blob/268a37740656a2cfb033e6803e2459fdf4ece516/IPython/core/completer.py#L1703), but I'm not sure if that should happen in a more central place. 

In particular, if a user does interrupt a completer, do we want to continue with the next one, or cancel completion completely?


Discussion:
Ouch, thanks, we should definitively not crash. 

I'm slowly thinking on how we can make a better completer, in particular now that master is Python 3 only I have the vague plan on trying to make everything generator/coroutine. I also want to implement a kind of timeout for completer. If you have any ideas about that that they are welcome. 

A very similar issue arises on the code path for non-custom completes (see [here](https://github.com/ipython/ipykernel/issues/261)).

Resolving patch:
diff --git a/IPython/core/completer.py b/IPython/core/completer.py
--- a/IPython/core/completer.py
+++ b/IPython/core/completer.py
@@ -1769,11 +1769,16 @@ def completions(self, text: str, offset: int)->Iterator[Completion]:
                       category=ProvisionalCompleterWarning, stacklevel=2)
 
         seen = set()
-        for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
-            if c and (c in seen):
-                continue
-            yield c
-            seen.add(c)
+        try:
+            for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
+                if c and (c in seen):
+                    continue
+                yield c
+                seen.add(c)
+        except KeyboardInterrupt:
+            """if completions take too long and users send keyboard interrupt,
+            do not crash and return ASAP. """
+            pass
 
     def _completions(self, full_text: str, offset: int, *, _timeout)->Iterator[Completion]:
         """


Test patch:
Repository: ipython/ipython

Issue:
Index error on linux.
Someone left a comment on a commit instead of opening an issue: 

https://github.com/ipython/ipython/commit/920ce1fb178f98506e637dc7513c891efb1fb79a#commitcomment-24345250

```
This commit seems to be the cause of ipython crashing on linux (+conda):

    elif p_venv[1] == ':':
IndexError: string index out of range
```


Discussion:

Resolving patch:
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -718,7 +718,7 @@ def init_virtualenv(self):
         # In Cygwin paths like "c:\..." and '\cygdrive\c\...' are possible
         if p_venv.startswith('\\cygdrive'):
             p_venv = p_venv[11:]
-        elif p_venv[1] == ':':
+        elif len(p_venv) >= 2 and p_venv[1] == ':':
             p_venv = p_venv[2:]
 
         if any(p_venv in p for p in paths):


Test patch:
Repository: ipython/ipython

Issue:
ExecutionInfo _repr_'s missing selfs
```
class ExecutionInfo(object):
    """The arguments used for a call to :meth:`InteractiveShell.run_cell`

    Stores information about what is going to happen.
    """
    raw_cell = None
    store_history = False
    silent = False
    shell_futures = True

    def __init__(self, raw_cell, store_history, silent, shell_futures):
        self.raw_cell = raw_cell
        self.store_history = store_history
        self.silent = silent
        self.shell_futures = shell_futures

    def __repr__(self):
        name = self.__class__.__qualname__
        raw_cell = ((self.raw_cell[:50] + '..')
                    if len(self.raw_cell) > 50 else self.raw_cell)
        return '<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s result=%s>' %\
               (name, id(self), raw_cell, store_history, silent, shell_futures, repr(self.result))
```

`(name, id(self), raw_cell, store_history, silent, shell_futures, repr(self.result))` <- selfs are missing.


Discussion:

Resolving patch:
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -193,8 +193,8 @@ def __repr__(self):
         name = self.__class__.__qualname__
         raw_cell = ((self.raw_cell[:50] + '..')
                     if len(self.raw_cell) > 50 else self.raw_cell)
-        return '<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s result=%s>' %\
-               (name, id(self), raw_cell, store_history, silent, shell_futures, repr(self.result))
+        return '<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s>' %\
+               (name, id(self), raw_cell, self.store_history, self.silent, self.shell_futures)
 
 
 class ExecutionResult(object):


Test patch:
Repository: ipython/ipython

Issue:
Use the Sphinx option which causes an error if any warning occurs
see @takluyver 's comment in #10895 


Discussion:
@olesyabar @syutbai @douglatornell are you interested?

Resolving patch:
diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py
--- a/IPython/core/debugger.py
+++ b/IPython/core/debugger.py
@@ -32,6 +32,7 @@
 import linecache
 import sys
 import warnings
+import re
 
 from IPython import get_ipython
 from IPython.utils import PyColorize
@@ -175,6 +176,13 @@ def __call__(self):
         self.debugger.set_trace(sys._getframe().f_back)
 
 
+RGX_EXTRA_INDENT = re.compile('(?<=\n)\s+')
+
+
+def strip_indentation(multiline_string):
+    return RGX_EXTRA_INDENT.sub('', multiline_string)
+
+
 def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
     """Make new_fn have old_fn's doc string. This is particularly useful
     for the ``do_...`` commands that hook into the help system.
@@ -183,7 +191,7 @@ def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
     def wrapper(*args, **kw):
         return new_fn(*args, **kw)
     if old_fn.__doc__:
-        wrapper.__doc__ = old_fn.__doc__ + additional_text
+        wrapper.__doc__ = strip_indentation(old_fn.__doc__) + additional_text
     return wrapper
 
 


Test patch:
Repository: ipython/ipython

Issue:
Make prompt_toolkit history search configurable
We currently hard-code it on, but people may want to disable it.

https://github.com/ipython/ipython/blob/8008eda4a856dd2e8c6dcae21d651d36ce52c683/IPython/terminal/interactiveshell.py#L245



Discussion:
I'd like to volunteer for this issue
👏 Thanks!

Resolving patch:
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -57,8 +57,6 @@ class _NoStyle(Style): pass
             Token.OutPromptNum: '#bb0000 bold',
 }
 
-
-
 def get_default_editor():
     try:
         return os.environ['EDITOR']
@@ -208,6 +206,10 @@ def _displayhook_class_default(self):
              "may be changed or removed in later releases."
     ).tag(config=True)
 
+    enable_history_search = Bool(True,
+        help="Allows to enable/disable the prompt toolkit history search"
+    ).tag(config=True)
+
     @observe('term_title')
     def init_term_title(self, change=None):
         # Enable or disable the terminal title.
@@ -271,7 +273,7 @@ def patch_stdout(**kwargs):
                             history=history,
                             completer=IPythonPTCompleter(shell=self,
                                                     patch_stdout=patch_stdout),
-                            enable_history_search=True,
+                            enable_history_search=self.enable_history_search,
                             style=self.style,
                             mouse_support=self.mouse_support,
                             **self._layout_options()


Test patch:
Repository: ipython/ipython

Issue:
Audit our warnings
Our warnings should likely be audited to check the following (mostly for deprecation warnings):

Warnings messages should try to mention: 
- Since which version something is deprecated.
- Whether it currently has an effect (or not), and in both case by what it could (should?) be replaced.
- a `stacklevel` value (except maybe at import time, in order to appear at in the right stackframe)

That should be easy for someone to get into the code. 



Discussion:
Note, on unix system, the following might be useful:

```
grep -A3 'warn(' **.py |grep -v stacklevel
```

@Carreau I would like to take a stab at the issue.

Hi @souravsingh, sure, please go ahead and feel free to ask any questions.

See https://github.com/ipython/ipython/pull/9980 for an example.

You can do things in 1 or many PR as you like. 

Thanks ! We appreciate that !

@souravsingh are you still working on this issue? @Carreau is this issue still relevant?
> @Carreau is this issue still relevant?

Yes, And I believe this will probably stay relevant ad vitam æternam as we are regularly adding/modifying warnings. We should probably just have every now and then someone that add a "Check on yy/mm/dd" on this issue and revisit it every few month every year. 
@jzf2101 I had forgotten about the issue. I am now working on sending a PR.
@souravsingh you're still interested?
Yes. I am. I will send a patch quickly.
@souravsingh I don't see a PR referencing this issue?

Resolving patch:
diff --git a/IPython/consoleapp.py b/IPython/consoleapp.py
--- a/IPython/consoleapp.py
+++ b/IPython/consoleapp.py
@@ -6,7 +6,7 @@
 
 from warnings import warn
 
-warn("The `IPython.consoleapp` package has been deprecated. "
-     "You should import from jupyter_client.consoleapp instead.")
+warn("The `IPython.consoleapp` package has been deprecated since IPython 4.0."
+     "You should import from jupyter_client.consoleapp instead.", stacklevel=2)
 
 from jupyter_client.consoleapp import *


Test patch:
Repository: ipython/ipython

Issue:
Cleanup extra logic that handle python <=3.3
https://github.com/ipython/ipython/pull/10833 dis most of that but there seem to be some logic still handling python 3.3

https://github.com/ipython/ipython/blob/dda523895e5a9c4185de763a25f038dc6fff76b8/IPython/core/extensions.py#L17-L21

https://github.com/ipython/ipython/blob/dda523895e5a9c4185de763a25f038dc6fff76b8/IPython/utils/openpy.py#L117-L121

https://github.com/ipython/ipython/blob/dda523895e5a9c4185de763a25f038dc6fff76b8/IPython/utils/text.py#L512-L519

(3.4.2+)

https://github.com/ipython/ipython/blob/dda523895e5a9c4185de763a25f038dc6fff76b8/IPython/core/magics/execution.py#L145-L149

There are possibly other places, this should be relatively easy to fix for a new contributor.

Each of these removal can be a separate PR.


Discussion:
I would try to clean them up with separate PRs for each fix.

Resolving patch:
diff --git a/IPython/core/extensions.py b/IPython/core/extensions.py
--- a/IPython/core/extensions.py
+++ b/IPython/core/extensions.py
@@ -7,18 +7,13 @@
 import os
 import os.path
 import sys
-from importlib import import_module
+from importlib import import_module, reload
 
 from traitlets.config.configurable import Configurable
 from IPython.utils.path import ensure_dir_exists, compress_user
 from IPython.utils.decorators import undoc
 from traitlets import Instance
 
-try:
-    from importlib import reload
-except ImportError :
-    ## deprecated since 3.4
-    from imp import reload
 
 #-----------------------------------------------------------------------------
 # Main class


Test patch:
Repository: ipython/ipython

Issue:
pastebin magic does not work: github requires authentication to create gists
Github now [requires authentication](https://developer.github.com/v3/gists/#authentication) to create gists:

> You can read public gists anonymously, but you must be signed into GitHub to create gists.

`%pastebin` does not work anymore and returns 401:

    HTTPError: HTTP Error 401: Unauthorized



Discussion:
Oh, that's frustrating. I'm not sure we want to deal with OAuth inside IPython. Maybe it should use another service?

Resolving patch:
diff --git a/IPython/core/magics/code.py b/IPython/core/magics/code.py
--- a/IPython/core/magics/code.py
+++ b/IPython/core/magics/code.py
@@ -20,6 +20,8 @@
 import sys
 import ast
 from itertools import chain
+from urllib.request import urlopen
+from urllib.parse import urlencode
 
 # Our own packages
 from IPython.core.error import TryNext, StdinNotImplementedError, UsageError
@@ -244,7 +246,7 @@ def save(self, parameter_s=''):
 
     @line_magic
     def pastebin(self, parameter_s=''):
-        """Upload code to Github's Gist paste bin, returning the URL.
+        """Upload code to dpaste's paste bin, returning the URL.
 
         Usage:\\
           %pastebin [-d "Custom description"] 1-7
@@ -265,25 +267,14 @@ def pastebin(self, parameter_s=''):
             print(e.args[0])
             return
 
-        # Deferred import
-        try:
-            from urllib.request import urlopen # Py 3
-        except ImportError:
-            from urllib2 import urlopen
-        import json
-        post_data = json.dumps({
-          "description": opts.get('d', "Pasted from IPython"),
-          "public": True,
-          "files": {
-            "file1.py": {
-              "content": code
-            }
-          }
+        post_data = urlencode({
+          "title": opts.get('d', "Pasted from IPython"),
+          "syntax": "python3",
+          "content": code
         }).encode('utf-8')
 
-        response = urlopen("https://api.github.com/gists", post_data)
-        response_data = json.loads(response.read().decode('utf-8'))
-        return response_data['html_url']
+        response = urlopen("http://dpaste.com/api/v2/", post_data)
+        return response.headers.get('Location')
 
     @line_magic
     def loadpy(self, arg_s):


Test patch:
Repository: ipython/ipython

Issue:
Think of adding a project_URL for 7.0
see for example : 
https://github.com/jupyter/nbconvert/pull/869/commits/c66d65262567fa0e9d9834f3524a0056d2a38f9e


Discussion:

Resolving patch:
diff --git a/setupbase.py b/setupbase.py
--- a/setupbase.py
+++ b/setupbase.py
@@ -36,10 +36,6 @@
 pjoin = os.path.join
 repo_root = os.path.dirname(os.path.abspath(__file__))
 
-def oscmd(s):
-    print(">", s)
-    os.system(s)
-
 def execfile(fname, globs, locs=None):
     locs = locs or globs
     exec(compile(open(fname).read(), fname, "exec"), globs, locs)
@@ -78,6 +74,12 @@ def file_doesnt_endwith(test,endings):
       keywords         = keywords,
       classifiers      = classifiers,
       cmdclass         = {'install_data': install_data_ext},
+      project_urls={
+          'Documentation': 'https://ipython.readthedocs.io/',
+          'Funding'      : 'https://numfocus.org/',
+          'Source'       : 'https://github.com/ipython/ipython',
+          'Tracker'      : 'https://github.com/ipython/ipython/issues',
+      }
       )
 
 


Test patch:
Repository: ipython/ipython

Issue:
Script (e.g. Bash) magics doesn't have an error on status code
I ran into a use-case where I wanted to call a small bash script magic in a notebook, but couldn't halt execution easily based on exit status.

======= Cell 1 =======
```
%%bash
not_a_valid_command
```

======= Cell 2 =======
```
print("I don't want to run this if the bash command didn't return status code 0")
```

It seems like the [script magics](https://ipython.readthedocs.io/en/stable/interactive/magics.html) and the [code](https://github.com/ipython/ipython/blob/ec3d1a11bf26a0962cb2cf55ba263b12ac023183/IPython/core/magics/script.py#L63) don't have any options to inform the subprocess to error on non-zero status code. This would be nice to be configurable and/or defaulted.


Discussion:
I've been having a lot of feedback from other users at my company who get frustrated that this isn't the default behavior (both for `%%script` and `!` patterns). For example `!pip install -U package-that-does-not-exist` will not halt execution, but this is a common pattern that cannot assume success to continue execution.

How disruptive would it be if we changed the default behavior to raise an error for nonzero exit codes by default?
@Carreau thoughts on this topic?
Thanks for pinging me. 
I think that make sens for consistency. It would be relatively easy to add a configuration option to change the behavior. 

Would that be ok only for the next major version ? 

Note that it should be relatively easy to backport as a custom package/extension for IPYthon, where you can just overwrite magics, if you want to have it on earlier versions. 
Actually it seem an option was added by @mpacer as part of 5c4e497df0 (#11199) unreleased yet. 

So it's just a question of pushing this forward. I have no objection of making this the default.
Ok let me see if I can make a PR to change the default behavior to make use of this for the 7.0 milestone.

Resolving patch:
diff --git a/IPython/core/magics/script.py b/IPython/core/magics/script.py
--- a/IPython/core/magics/script.py
+++ b/IPython/core/magics/script.py
@@ -55,7 +55,7 @@ def script_args(f):
             """
         ),
         magic_arguments.argument(
-            '--raise-error', action="store_true",
+            '--no-raise-error', action="store_false", dest='raise_error',
             help="""Whether you should raise an error message in addition to 
             a stream on stderr if you get a nonzero exit code.
             """


Test patch:
Repository: ipython/ipython

Issue:
HTML vs Iframe
I was again the witness of people miss-using HTML to display IFrames, and having issues. 

Could we detect in  HTML the usage of `<iframe>....</iframe>` and warn user that there is an iframe object ? 



Discussion:
What issues does that cause?

> What issues does that cause?

Mostly people having issues getting the html right (width, height), url escaping, and remove the frameborder. The exact reason why we have an IFrame object. 

could you say a bit more on the issue? maybe produce an example of when this comes up?
The suggestion is to warn when someone is doing this:

```python
from IPython.display import HTML
HTML('<iframe src="..."></iframe>')
```

Instead of this:

```python
from IPython.display import IFrame
IFrame('...')
```

I'm still not convinced that it's worth it, though. A warning is going to be annoying if you do need to put an iframe in HTML, or if the display object is being made by code someone else wrote which you don't want to go and change.
Hey! I would like to help with this issue.
This looks like a good first issue. I'll work on this for hacktoberfest.

Resolving patch:
diff --git a/IPython/core/display.py b/IPython/core/display.py
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -666,6 +666,11 @@ def _repr_pretty_(self, pp, cycle):
 
 class HTML(TextDisplayObject):
 
+    def __init__(self, data=None, url=None, filename=None, metadata=None):
+        if data and "<iframe " in data and "</iframe>" in data:
+            warnings.warn("Consider using IPython.display.IFrame instead")
+        super(HTML, self).__init__(data=data, url=url, filename=filename, metadata=metadata)
+
     def _repr_html_(self):
         return self._data_and_metadata()
 


Test patch:
diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py
--- a/IPython/core/tests/test_display.py
+++ b/IPython/core/tests/test_display.py
@@ -195,6 +195,14 @@ def test_displayobject_repr():
     j._show_mem_addr = False
     nt.assert_equal(repr(j), '<IPython.core.display.Javascript object>')
 
+@mock.patch('warnings.warn')
+def test_encourage_iframe_over_html(m_warn):
+    display.HTML('<br />')
+    m_warn.assert_not_called()
+
+    display.HTML('<iframe src="http://a.com"></iframe>')
+    m_warn.assert_called_with('Consider using IPython.display.IFrame instead')
+
 def test_progress():
     p = display.ProgressBar(10)
     nt.assert_in('0/10',repr(p))
Repository: ipython/ipython

Issue:
_repr_svg_ needs better documentation
`_repr_svg_` has additional return options as mentioned by @takluyver here: https://github.com/igraph/python-igraph/issues/145#issuecomment-344283193

I couldn't find the fact that `_repr_svg_` could return a tuple mentioned anywhere. Specifically, this could be mentioned here:

* http://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html
* http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.formatters.html

Perhaps there are other `_repr_` functions that are also under-documented.


Discussion:
I think all the `_repr_*_` functions can now return a data, metadata tuple. I only became aware of it recently, but I'm not sure when it started.

Here's another place this could be documented - I think narrative docs may be better for this than API docs.
http://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display


Can we make this a `good first issue` @minrk suggested this issue
marked it as "good first issue" @jzf2101 
Can I work on this?
Yes! Do you follow the discussion above about what needs doing?
does this issue need any more work? 
I'll do this for hacktoberfest.

Resolving patch:
diff --git a/IPython/core/display.py b/IPython/core/display.py
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -238,16 +238,22 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
     want to use. Here is a list of the names of the special methods and the
     values they must return:
 
-      - `_repr_html_`: return raw HTML as a string
-      - `_repr_json_`: return a JSONable dict
-      - `_repr_jpeg_`: return raw JPEG data
-      - `_repr_png_`: return raw PNG data
-      - `_repr_svg_`: return raw SVG data as a string
-      - `_repr_latex_`: return LaTeX commands in a string surrounded by "$".
+      - `_repr_html_`: return raw HTML as a string, or a tuple (see below).
+      - `_repr_json_`: return a JSONable dict, or a tuple (see below).
+      - `_repr_jpeg_`: return raw JPEG data, or a tuple (see below).
+      - `_repr_png_`: return raw PNG data, or a tuple (see below).
+      - `_repr_svg_`: return raw SVG data as a string, or a tuple (see below).
+      - `_repr_latex_`: return LaTeX commands in a string surrounded by "$",
+                        or a tuple (see below).
       - `_repr_mimebundle_`: return a full mimebundle containing the mapping
                              from all mimetypes to data.
                              Use this for any mime-type not listed above.
 
+    The above functions may also return the object's metadata alonside the
+    data.  If the metadata is available, the functions will return a tuple
+    containing the data and metadata, in that order.  If there is no metadata
+    available, then the functions will return the data only.
+
     When you are directly writing your own classes, you can adapt them for
     display in IPython by following the above approach. But in practice, you
     often need to work with existing classes that you can't easily modify.


Test patch: