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

Issue:
Where is the installed `ipython` script?
According to the docstring of `ipython.py`, "the actual ipython script to be installed with 'python setup.py install' is in './scripts' directory."  But the only thing in `scripts` is `ipython_win_post_install.py`, which isn't it.  



Discussion:
Try ipython_src_dir/ipython/scripts :)

On Mon, Jan 28, 2013 at 12:31 AM, Aaron Meurer notifications@github.comwrote:

> According to the docstring of ipython.py, "the actual ipython script to
> be installed with 'python setup.py install' is in './scripts' directory."
> But the only thing in scripts is ipython_win_post_install.py, which isn't
> it.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/2858.


Resolving patch:
diff --git a/ipython.py b/ipython.py
--- a/ipython.py
+++ b/ipython.py
@@ -3,9 +3,11 @@
 """IPython -- An enhanced Interactive Python
 
 The actual ipython script to be installed with 'python setup.py install' is
-in './scripts' directory. This file is here (ipython source root directory)
-to facilitate non-root 'zero-installation' (just copy the source tree
-somewhere and run ipython.py) and development. """
+generated by setuptool via the `console_scripts` mechanism.  This file is here
+(ipython source root directory) to facilitate non-root 'zero-installation'
+(just copy the source tree somewhere and run ipython.py) and development.
+
+"""
 
 if __name__ != "__main__":
     raise RuntimeError('You are trying to import the ipython.py executable. '
@@ -20,4 +22,3 @@
 execfile(os.path.join(
     this_dir, 'IPython', 'scripts', 'ipython'
 ))
-


Test patch:
Repository: ipython/ipython

Issue:
OSX wxPython (osx_cocoa, 64bit) command "%gui wx" blocks the interpreter
On mac os x trying to use ipython with wxPython in interactive mode as soon as I type the command

```
%gui wx
```

completely block the python interpreter and the only way to stop it is to kill it.

If I try to use an old version of wxpython (wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg)
I should start ipython in 32 bit mode and it works.

The versions used in the blocking mode are:
- OSX 10.7.5
- python 2.7.2 (and even 2.7.3) binary version from python.org
- ipython 0.13.1 (pip install and local install from sources)
- wxPython 2.9.4.0 (locally compiled and binary version from wxpython.org)

Here the console example

```
$ ipython
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: gui wx
Out[1]: <wx._core.App; proxy of <Swig Object of type 'wxPyApp *' at 0x102936fd0> >

In [2]: **[here completely blocked]**
```



Discussion:
I've been seeing the same thing (Activity Monitor shows 100% CPU usage by Python once %gui wx is issued). Versions on my Mac are slightly different:
- OSX 10.8.2
- Python 2.7.3 binary version from MacPorts
- ipython 0.13.1 binary from MacPorts
- wxPython 2.9.4.0 osx-cocoa (classic) binary from MacPorts

Seems to be a wxWidgets bug/limitation. On OSX/Cocoa `evtloop.Pending()` always returns True, regardless of there being any pending events, causing an infinite loop here[1].

The simplest solution is to use `inputhook_wx2` as the default input hook implementation.

[1] https://github.com/ipython/ipython/blob/master/IPython/lib/inputhookwx.py#L129

Thanks  lessandro,

I tried on my mac and it seems to solve the problem.

Carlo.


Resolving patch:
diff --git a/IPython/lib/inputhookwx.py b/IPython/lib/inputhookwx.py
--- a/IPython/lib/inputhookwx.py
+++ b/IPython/lib/inputhookwx.py
@@ -17,6 +17,7 @@
 # Imports
 #-----------------------------------------------------------------------------
 
+import sys
 import signal
 import time
 from timeit import default_timer as clock
@@ -159,5 +160,11 @@ def inputhook_wx3():
         pass
     return 0
 
-# This is our default implementation
-inputhook_wx = inputhook_wx3
+if sys.platform == 'darwin':
+    # On OSX, evtloop.Pending() always returns True, regardless of there being
+    # any events pending. As such we can't use implementations 1 or 3 of the
+    # inputhook as those depend on a pending/dispatch loop.
+    inputhook_wx = inputhook_wx2
+else:
+    # This is our default implementation
+    inputhook_wx = inputhook_wx3


Test patch:
Repository: ipython/ipython

Issue:
BUG: kernel dies if user sets sys.stderr or sys.stdout to a file object
If the user redirects the streams to a file for example,
the kernel would raise an exception because file
objects do not have `set_parent` defined, unlike ipython's
OutStream.

steps to reproduce:

``` ipython
In [2]: sys.stderr=open("/tmp/o","wb")
```



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
@@ -364,8 +364,14 @@ def execute_request(self, stream, ident, parent):
         shell.displayhook.set_parent(parent)
         shell.display_pub.set_parent(parent)
         shell.data_pub.set_parent(parent)
-        sys.stdout.set_parent(parent)
-        sys.stderr.set_parent(parent)
+        try:
+            sys.stdout.set_parent(parent)
+        except AttributeError:
+            pass
+        try:
+            sys.stderr.set_parent(parent)
+        except AttributeError:
+            pass
 
         # Re-broadcast our input for the benefit of listening clients, and
         # start computing output
@@ -567,14 +573,20 @@ def apply_request(self, stream, ident, parent):
             return
 
         self._publish_status(u'busy', parent)
-        
+
         # Set the parent message of the display hook and out streams.
         shell = self.shell
         shell.displayhook.set_parent(parent)
         shell.display_pub.set_parent(parent)
         shell.data_pub.set_parent(parent)
-        sys.stdout.set_parent(parent)
-        sys.stderr.set_parent(parent)
+        try:
+            sys.stdout.set_parent(parent)
+        except AttributeError:
+            pass
+        try:
+            sys.stderr.set_parent(parent)
+        except AttributeError:
+            pass
 
         # pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
         # self.iopub_socket.send(pyin_msg)


Test patch:
Repository: ipython/ipython

Issue:
Up arrow key history search gets stuck in QTConsole
With the ipython installed with with commit 50a583890fd0640492fcd76d6ecc97b5c3f23ae0, going through history with up arrow key in qtconsole works without any problem. But in current commit 48b63c19a53f9e26dc4f64150641c730cb6a2305, in qtconsole, it gets "stuck" after several items - pressing up arrow key does not do anything. It seems to be happening when the currently showing history is longer than the qtconsole width. 

Since there are more than 120 commits in between, I haven't tried to identify what was the commit which caused this.

Also, in terminal this does not happen.



Discussion:
Can you provide specific reproduction steps?  The relevant change is almost certainly #2819.

> Also, in terminal this does not happen.

Not surprising, since there isn't a line of code in common wrt the input history (terminal is 100% readline, qtconsole doesn't involve readline).


Resolving patch:
diff --git a/IPython/frontend/qt/console/history_console_widget.py b/IPython/frontend/qt/console/history_console_widget.py
--- a/IPython/frontend/qt/console/history_console_widget.py
+++ b/IPython/frontend/qt/console/history_console_widget.py
@@ -88,9 +88,15 @@ def _up_pressed(self, shift_modifier):
             # to the line up to the cursor is if we are already
             # in a simple scroll (no prefix),
             # and the cursor is at the end of the first line
-            first_line = input_buffer.split('\n', 1)[0]
+            
+            # check if we are at the end of the first line
+            c = self._get_cursor()
+            current_pos = c.position()
+            c.movePosition(QtGui.QTextCursor.EndOfLine)
+            at_eol = (c.position() == current_pos)
+            
             if self._history_index == len(self._history) or \
-                not (self._history_prefix == '' and col == len(first_line)) or \
+                not (self._history_prefix == '' and at_eol) or \
                 not (self._get_edited_history(self._history_index)[:col] == input_buffer[:col]):
                 self._history_prefix = input_buffer[:col]
 


Test patch:
Repository: ipython/ipython

Issue:
File magic (%%file) does not work with paths beginning with tilde (e.g., ~/anaconda/stuff.txt)
Found this quirk teaching a Software Carpentry class at LBL, wanted to jot down before I forgot it. I don't know if it's been resolved yet; this behavior occurred with IPython 0.13.1 in the notebook interface.



Discussion:

Resolving patch:
diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py
--- a/IPython/core/magics/osm.py
+++ b/IPython/core/magics/osm.py
@@ -711,7 +711,7 @@ def file(self, line, cell):
         For frontends that do not support stdin (Notebook), -f is implied.
         """
         args = magic_arguments.parse_argstring(self.file, line)
-        filename = unquote_filename(args.filename)
+        filename = os.path.expanduser(unquote_filename(args.filename))
         
         if os.path.exists(filename):
             if args.amend:


Test patch:
Repository: ipython/ipython

Issue:
cython_pyximport reload broken in python3
python3.3 notebook, tested in 0.13.1 but the code looks the same in HEAD:

%%cython_pyximport foo
def f(x):
    return 4.0*x

execute twice and you get 

```
/usr/lib/python3/dist-packages/IPython/extensions/cythonmagic.py in cython_pyximport(self, line, cell)
     99         if module_name in self._reloads:
    100             module = self._reloads[module_name]
--> 101             reload(module)
    102         else:
    103             __import__(module_name)

NameError: global name 'reload' is not defined
```

imp.reload should be used here



Discussion:
The version of [2to3 in the next release on Python](http://bugs.python.org/issue11797) will fix this.  In the mean time I guess we'll have to add a workaround.


Resolving patch:
diff --git a/IPython/extensions/cythonmagic.py b/IPython/extensions/cythonmagic.py
--- a/IPython/extensions/cythonmagic.py
+++ b/IPython/extensions/cythonmagic.py
@@ -41,6 +41,11 @@
 import sys
 import time
 
+try:
+    reload
+except NameError:   # Python 3
+    from imp import reload
+
 try:
     import hashlib
 except ImportError:


Test patch:
Repository: ipython/ipython

Issue:
docstring typo/inconsistency: mention of an xml notebook format?
The helptext for the `%notebook` magic mentions that you can save the notebook in an xml format, e.g. [here](https://github.com/ipython/ipython/blob/master/IPython/core/magics/basic.py#L557) and [here](https://github.com/ipython/ipython/blob/master/IPython/core/magics/basic.py#L564), but in [the code](https://github.com/ipython/ipython/blob/master/IPython/core/magics/basic.py#L602) it seems pretty clear that the xml format isn't allowed.



Discussion:

Resolving patch:
diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py
--- a/IPython/core/magics/basic.py
+++ b/IPython/core/magics/basic.py
@@ -554,14 +554,13 @@ def precision(self, s=''):
         help='Export IPython history as a notebook. The filename argument '
              'is used to specify the notebook name and format. For example '
              'a filename of notebook.ipynb will result in a notebook name '
-             'of "notebook" and a format of "xml". Likewise using a ".json" '
-             'or ".py" file extension will write the notebook in the json '
-             'or py formats.'
+             'of "notebook" and a format of "json". Likewise using a ".py" '
+             'file extension will write the notebook as a Python script'
     )
     @magic_arguments.argument(
         '-f', '--format',
         help='Convert an existing IPython notebook to a new format. This option '
-             'specifies the new format and can have the values: xml, json, py. '
+             'specifies the new format and can have the values: json, py. '
              'The target filename is chosen automatically based on the new '
              'format. The filename argument gives the name of the source file.'
     )


Test patch:
Repository: ipython/ipython

Issue:
ipython pyqt 4.10 incompatibilty, QTextBlockUserData
ipython qtconsole seems to be incompatible with pytqt 4.10, if you type in a line you get this

```
if 1:
   print 1

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/frontend_widget.py", line 59, in highlightBlock
    super(FrontendHighlighter, self).highlightBlock(string)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/pygments_highlighter.py", line 109, in highlightBlock
    self._lexer._saved_state_stack = prev_data.syntax_stack
AttributeError: 'QTextBlockUserData' object has no attribute 'syntax_stack'
```

this needs to be fixed in two places, pyqt needs an update (currently available as snapshot) and ipython needs a fix in pygments_highlighter.py

```
self._document = QtGui.QTextDocument()
```

...to...

```
self._document = self.document()
```

see:
http://www.riverbankcomputing.com/pipermail/pyqt/2013-March/032512.html



Discussion:

Resolving patch:
diff --git a/IPython/frontend/qt/console/pygments_highlighter.py b/IPython/frontend/qt/console/pygments_highlighter.py
--- a/IPython/frontend/qt/console/pygments_highlighter.py
+++ b/IPython/frontend/qt/console/pygments_highlighter.py
@@ -94,7 +94,7 @@ class PygmentsHighlighter(QtGui.QSyntaxHighlighter):
     def __init__(self, parent, lexer=None):
         super(PygmentsHighlighter, self).__init__(parent)
 
-        self._document = QtGui.QTextDocument()
+        self._document = self.document()
         self._formatter = HtmlFormatter(nowrap=True)
         self._lexer = lexer if lexer else PythonLexer()
         self.set_style('default')


Test patch:
Repository: ipython/ipython

Issue:
Fails to install under Jython 2.7 beta
This is the error I get:

```
% pip install ipython-0.13.tar.gz 
Unpacking ./ipython-0.13.tar.gz
  Running setup.py egg_info for package from file:///home/aaditya/work/epsilon/installer/packages/ipython-0.13.tar.gz
    Unsupported operating system: java
    Complete output from command python setup.py egg_info:
    Unsupported operating system: java
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -93,13 +93,10 @@ def cleanup():
 # Handle OS specific things
 #-------------------------------------------------------------------------------
 
-if os.name == 'posix':
-    os_name = 'posix'
-elif os.name in ['nt','dos']:
+if os.name in ('nt','dos'):
     os_name = 'windows'
 else:
-    print('Unsupported operating system:',os.name)
-    sys.exit(1)
+    os_name = os.name
 
 # Under Windows, 'sdist' has not been supported.  Now that the docs build with
 # Sphinx it might work, but let's not turn it on until someone confirms that it


Test patch:
Repository: ipython/ipython

Issue:
update pretty to use Python 3 style for sets
In Python 3, `repr(set([1,2,3]))` is `{1,2,3}`, but pretty currently forces the output to be `set([1,2,3])`.  We should probably use the set-literal format on Python 3, or just use it all the time.



Discussion:

Resolving patch:
diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py
--- a/IPython/lib/pretty.py
+++ b/IPython/lib/pretty.py
@@ -668,7 +668,7 @@ def _exception_pprint(obj, p, cycle):
     list:                       _seq_pprinter_factory('[', ']', list),
     dict:                       _dict_pprinter_factory('{', '}', dict),
     
-    set:                        _seq_pprinter_factory('set([', '])', set),
+    set:                        _seq_pprinter_factory('{', '}', set),
     frozenset:                  _seq_pprinter_factory('frozenset([', '])', frozenset),
     super:                      _super_pprint,
     _re_pattern_type:           _re_pattern_pprint,


Test patch:
Repository: ipython/ipython

Issue:
script magic error message loop
this script magic worked in 0.13.2:

```
%%script python /tmp/test.py
```

now it gives this error:

```
%%script (with double %) expects code beneath it. Did you mean %script
```

if I use that I get:

```
Line magic function %script not found, ... did you mean %%script?
```

what I'm doing is probably wrong (I guess I should use !python file.py) but %%script should not recommend %script if that does not exist.



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
@@ -2111,13 +2111,15 @@ def run_cell_magic(self, magic_name, line, cell):
         fn = self.find_cell_magic(magic_name)
         if fn is None:
             lm = self.find_line_magic(magic_name)
-            etpl = "Cell magic function `%%{0}` not found{1}."
+            etpl = "Cell magic `%%{0}` not found{1}."
             extra = '' if lm is None else (' (But line magic `%{0}` exists, '
                             'did you mean that instead?)'.format(magic_name))
             error(etpl.format(magic_name, extra))
         elif cell == '':
-            raise UsageError('%%{0} (with double %) expects code beneath it. '
-                            'Did you mean %{0} (single %)?'.format(magic_name))
+            message = '%%{0} is a cell magic, but the cell body is empty.'.format(magic_name)
+            if self.find_line_magic(magic_name) is not None:
+                message += ' Did you mean the line magic %{0} (single %)?'.format(magic_name)
+            raise UsageError(message)
         else:
             # Note: this is the distance in the stack to the user's frame.
             # This will need to be updated if the internal calling logic gets


Test patch:
Repository: ipython/ipython

Issue:
OverflowError execption in handlers.py
Please see https://github.com/facebook/tornado/issues/713

IPython uses the same code fragment and creates an OverflowError when trying to load a sketch using procesing.js.



Discussion:

Resolving patch:
diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py
--- a/IPython/frontend/html/notebook/handlers.py
+++ b/IPython/frontend/html/notebook/handlers.py
@@ -820,7 +820,7 @@ def get(self, path, include_body=True):
             raise HTTPError(403, "%s is not a file", path)
 
         stat_result = os.stat(abspath)
-        modified = datetime.datetime.fromtimestamp(stat_result[stat.ST_MTIME])
+        modified = datetime.datetime.utcfromtimestamp(stat_result[stat.ST_MTIME])
 
         self.set_header("Last-Modified", modified)
 
@@ -844,7 +844,7 @@ def get(self, path, include_body=True):
         ims_value = self.request.headers.get("If-Modified-Since")
         if ims_value is not None:
             date_tuple = email.utils.parsedate(ims_value)
-            if_since = datetime.datetime.fromtimestamp(time.mktime(date_tuple))
+            if_since = datetime.datetime(*date_tuple[:6])
             if if_since >= modified:
                 self.set_status(304)
                 return


Test patch:
Repository: ipython/ipython

Issue:
improve config line magic
check for MissUpperCasing and add additional info
if there is a case insensitive match on clas

if line of the form

%config Class.value

return the value of the trait instead of just throwing bad usage

---

Yes the code is ugly, I'll reread it when I'll be backs.



Discussion:

Resolving patch:
diff --git a/IPython/core/magics/config.py b/IPython/core/magics/config.py
--- a/IPython/core/magics/config.py
+++ b/IPython/core/magics/config.py
@@ -24,6 +24,7 @@
 # Magic implementation classes
 #-----------------------------------------------------------------------------
 
+reg = re.compile('^\w+\.\w+$')
 @magics_class
 class ConfigMagics(Magics):
 
@@ -129,9 +130,20 @@ def config(self, s):
             help = re.sub(re.compile(r'^--', re.MULTILINE), '', help)
             print help
             return
+        elif reg.match(line):
+            cls, attr = line.split('.')
+            return getattr(configurables[classnames.index(cls)],attr)
         elif '=' not in line:
-            raise UsageError("Invalid config statement: %r, "
-                             "should be Class.trait = value" % line)
+            msg = "Invalid config statement: %r, "\
+                  "should be `Class.trait = value`."
+            
+            ll = line.lower()
+            for classname in classnames:
+                if ll == classname.lower():
+                    msg = msg + '\nDid you mean %s (note the case)?' % classname
+                    break
+
+            raise UsageError( msg % line)
 
         # otherwise, assume we are setting configurables.
         # leave quotes on args when splitting, because we want


Test patch:
Repository: ipython/ipython

Issue:
Improve documentation of ipcontroller and possible BUG
I tried to follow the documentation to setup a simple cluster with one host acting as controller (Ubuntu) and a second host running several ipengine (Windows7).

There is a misleading command in the doc. To launch the controller the doc says in "General consideration":

```
ipcontroller --ip=*
```

and in "Using the ipcontroller and ipengine commands"

```
ipcontroller --ip=192.168.1.16
```

(and BTW there is no mention anymore to the \* syntax). However the command that worked for me is:

```
ipcontroller --ip='*' --location=192.168.1.64
```

where location is the ip address of the host running the controller. Without location, the ipengine JSON file doesn't have the proper ip address (it has 127.0.0.1 instead).

On a related note, the doc also states to use the following command to retrieve the local ip address in ipcontroller_config.py:

```
import socket
ex_ip = socket.gethostbyname_ex(socket.gethostname())[-1][0]
```

but running this command on Ubuntu 12.04 returns 127.0.0.1, which is wrong. This maybe the reason why the ipcontroller command fails without the --location flag.



Discussion:
Clarifying the docs `--ip=*` is identical to `--ip=0.0.0.0`, which is to say "listen on all interfaces".  Now, this does not contain any information about the actual IP of the machine, though it is _accessible_ on every IP that points to it.  The `location` is the value used for resolving this ambiguity.  The default value for this is

```
socket.gethostbyname_ex(socket.gethostname())[-1][-1]
```

Which is typically the external IP of a machine, but not always.  If your machine cannot guess its own external IP, you have to specify this as `location`.  This ambiguity doesn't come up if you specify a particular IP.

I'll try to add some explanation of this to the docs, and maybe even some fallback code that should get the right IP in your case.

For reference, what do you get from:

```
socket.gethostbyname_ex(socket.gethostname() + '.local')
```


Resolving patch:
diff --git a/IPython/utils/localinterfaces.py b/IPython/utils/localinterfaces.py
--- a/IPython/utils/localinterfaces.py
+++ b/IPython/utils/localinterfaces.py
@@ -36,7 +36,11 @@
 
 PUBLIC_IPS = []
 try:
-    PUBLIC_IPS = socket.gethostbyname_ex(socket.gethostname())[2]
+    hostname = socket.gethostname()
+    PUBLIC_IPS = socket.gethostbyname_ex(hostname)[2]
+    # try hostname.local, in case hostname has been short-circuited to loopback
+    if not hostname.endswith('.local') and all(ip.startswith('127') for ip in PUBLIC_IPS):
+        PUBLIC_IPS = socket.gethostbyname_ex(socket.gethostname() + '.local')[2]
 except socket.gaierror:
     pass
 else:


Test patch: