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

Issue:
ipdb completely broken in Qt console
When starting the debugger via `%debug` in the Qt console, no valid command works:

```
ipdb> l
*** SyntaxError: invalid syntax (<stdin>, line 1)
```



Discussion:
Not just ipdb, raw_input.  Broken by c7a90e3949e0136265c893090ec8f9a300592b13 (PR #3409).  I will try to debug, and rollback the whole PR if I can't figure it out.


Resolving patch:
diff --git a/IPython/qt/console/console_widget.py b/IPython/qt/console/console_widget.py
--- a/IPython/qt/console/console_widget.py
+++ b/IPython/qt/console/console_widget.py
@@ -2060,6 +2060,7 @@ def _show_prompt(self, prompt=None, html=False, newline=True):
                 self._prompt = prompt
                 self._prompt_html = None
 
+        self._flush_pending_stream()
         self._prompt_pos = self._get_end_cursor().position()
         self._prompt_started()
 


Test patch:
Repository: ipython/ipython

Issue:
test_qt fails due to assertion error 'qt4' != 'qt'
I used MacPorts to setup my IPython environment, so I used the command port install qt4-mac to install qt.

``` no-highlight
iptest.py IPython.core
..................................................................................................................................................................................................S.........S...............................................................................................................................................F...................................
======================================================================
FAIL: IPython.core.tests.test_pylabtools.TestPylabSwitch.test_qt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/core/tests/test_pylabtools.py", line 98, in test_qt
    nt.assert_equal(gui, 'qt')
nose.proxy.AssertionError: 'qt4' != 'qt'
- qt4
?   -
+ qt

    """Fail immediately, with the given message."""
>>  raise self.failureException("'qt4' != 'qt'\n- qt4\n?   -\n+ qt\n")


----------------------------------------------------------------------
Ran 384 tests in 16.873s

FAILED (SKIP=2, failures=1)
```

``` no-highlight
**********************************************************************
Test suite completed for system with the following information:
{'codename': 'An Afternoon Hack',
 'commit_hash': 'ad1b59c',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython',
 'ipython_version': '1.0.0-rc1',
 'os_name': 'posix',
 'platform': 'Darwin-11.4.2-x86_64-i386-64bit',
 'sys_executable': '/opt/local/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.3.2 (default, May 21 2013, 11:50:39) \n[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))]'}

Tools and libraries available at test time:
   curses jinja2 matplotlib numpy pexpect pygments qt sphinx sqlite3 tornado zmq

Tools and libraries NOT available at test time:
   azure cython oct2py pymongo rpy2 wx wx.aui

Ran 14 test groups in 137.774s

Status:
ERROR - 1 out of 14 test groups failed.
```



Discussion:

Resolving patch:
diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py
--- a/IPython/core/pylabtools.py
+++ b/IPython/core/pylabtools.py
@@ -40,6 +40,8 @@
 # most part it's just a reverse of the above dict, but we also need to add a
 # few others that map to the same GUI manually:
 backend2gui = dict(zip(backends.values(), backends.keys()))
+# Our tests expect backend2gui to just return 'qt'
+backend2gui['Qt4Agg'] = 'qt'
 # In the reverse mapping, there are a few extra valid matplotlib backends that
 # map to the same GUI support
 backend2gui['GTK'] = backend2gui['GTKCairo'] = 'gtk'


Test patch:
Repository: ipython/ipython

Issue:
under Windows, "ipython3 nbconvert "C:/blabla/first_try.ipynb" --to latex --post PDF" POST processing action fails because of a bad parameter
Hello,

The "one single step" option to create a ".pdf" from a .ipynb" fails on my windows python3 pc 

Nbconvert  apparently  tries compile ".TEX"  result with 

"pdflatex .\first_try.tex" 

==> It generates a bad behaviour of pdflatex, which picks "pdfTex" option instead of "PdfLatex".

The working option, on my Windows PC  and when I do it by hand, is not to put the ".\" 

"pdflatex first_try.tex" 

UPDATE : replacing ".\" per "./" seems also to be a solution.
"pdflatex ./first_try.tex" 

Hint to  the problem comes from here 
http://tex.stackexchange.com/questions/78178/miktex-how-to-run-pdflatex-from-cmd-prompt-on-windows-7-compared-to-windows-xp 

Details below.

Sheers

*\* instruction *\* 
ipython3 nbconvert "C:/blabla/first_try.ipynb" --to latex --post PDF"

**\* (start of the output ) ***
C:\Users\parent\Desktop\winpython\WinPython-32bit-3.3.2.1rc1\python-3.3.2>ipytho
n3 nbconvert "C:/blabla//first_try.ipynb" --to latex --po
st PDF
[NbConvertApp] Using existing profile dir: 'C:\Users\parent\Desktop\winpytho
n\WinPython-32bit-3.3.2.1rc1\settings\.ipython\profile_default'
[NbConvertApp] Converting notebook C:/blabla/first_try.ipynb to latex
[NbConvertApp] Support files will be in first_try_files\
[NbConvertApp] Loaded template latex_article.tplx
[NbConvertApp] Writing 53680 bytes to .\first_try.tex
[NbConvertApp] Building PDF: `pdflatex .\first_try.tex`
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/W32TeX)
 restricted \write18 enabled.
entering extended mode
! Undefined control sequence.
<_> .\first
           _try.tex
?
*_\* (end of the output ) ***



Discussion:

Resolving patch:
diff --git a/IPython/nbconvert/writers/files.py b/IPython/nbconvert/writers/files.py
--- a/IPython/nbconvert/writers/files.py
+++ b/IPython/nbconvert/writers/files.py
@@ -30,7 +30,7 @@ class FilesWriter(WriterBase):
     """Consumes nbconvert output and produces files."""
 
 
-    build_directory = Unicode(".", config=True, 
+    build_directory = Unicode("", config=True,
                               help="""Directory to write output to.  Leave blank
                               to output to the current directory""")
 


Test patch:
Repository: ipython/ipython

Issue:
The PDF option for `--post` should work with lowercase 
Right now to get a PDF out of nbconvert you have to to

```
ipython nbconvert --to latex --post PDF foo.ipynb
```

Many users will try `pdf` instead and the error message is very confusing.  We should just make it work with lowercase.



Discussion:
Got it, this applies to all the alias flags in nbconvert.  I'll change the look up so it's case insensitive.


Resolving patch:
diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py
--- a/IPython/nbconvert/nbconvertapp.py
+++ b/IPython/nbconvert/nbconvertapp.py
@@ -154,14 +154,14 @@ def _classes_default(self):
     writer_class = DottedObjectName('FilesWriter', config=True, 
                                     help="""Writer class used to write the 
                                     results of the conversion""")
-    writer_aliases = {'FilesWriter': 'IPython.nbconvert.writers.files.FilesWriter',
-                      'DebugWriter': 'IPython.nbconvert.writers.debug.DebugWriter',
-                      'StdoutWriter': 'IPython.nbconvert.writers.stdout.StdoutWriter'}
+    writer_aliases = {'fileswriter': 'IPython.nbconvert.writers.files.FilesWriter',
+                      'debugwriter': 'IPython.nbconvert.writers.debug.DebugWriter',
+                      'stdoutwriter': 'IPython.nbconvert.writers.stdout.StdoutWriter'}
     writer_factory = Type()
 
     def _writer_class_changed(self, name, old, new):
-        if new in self.writer_aliases:
-            new = self.writer_aliases[new]
+        if new.lower() in self.writer_aliases:
+            new = self.writer_aliases[new.lower()]
         self.writer_factory = import_item(new)
 
     # Post-processor specific variables
@@ -172,13 +172,13 @@ def _writer_class_changed(self, name, old, new):
     post_processor_class = DottedOrNone(config=True, 
                                     help="""PostProcessor class used to write the 
                                     results of the conversion""")
-    post_processor_aliases = {'PDF': 'IPython.nbconvert.post_processors.pdf.PDFPostProcessor',
+    post_processor_aliases = {'pdf': 'IPython.nbconvert.post_processors.pdf.PDFPostProcessor',
                               'serve': 'IPython.nbconvert.post_processors.serve.ServePostProcessor'}
     post_processor_factory = Type()
 
     def _post_processor_class_changed(self, name, old, new):
-        if new in self.post_processor_aliases:
-            new = self.post_processor_aliases[new]
+        if new.lower() in self.post_processor_aliases:
+            new = self.post_processor_aliases[new.lower()]
         if new:
             self.post_processor_factory = import_item(new)
 


Test patch:
Repository: ipython/ipython

Issue:
qtconsole: ValueError('close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr',)
Line 308 in IPython/kernel/connect.py should be changed to

```
    return Popen([sys.executable, '-c', cmd, '--existing', cf] + argv,
    stdout=PIPE, stderr=PIPE, close_fds=sys.platform != "win32",
```

to account for this ValueError on windows.



Discussion:
closed by 14b007d

Hi, 
I've just uploaded my IPython to version 1.0.0 and I got exactly this error trying to launch the qtconsole.
I've also fixed the problem manually changing  IPython/kernel/connect.py file as in 14b007d.

@Aezio what is `sys.platform` for you?

'win32'
I've downloaded the executable file (py2.7 32 bit), maybe this fix has not been implemented in this build


Resolving patch:
diff --git a/IPython/kernel/connect.py b/IPython/kernel/connect.py
--- a/IPython/kernel/connect.py
+++ b/IPython/kernel/connect.py
@@ -316,7 +316,7 @@ def connect_qtconsole(connection_file=None, argv=None, profile=None):
     ])
     
     return Popen([sys.executable, '-c', cmd, '--existing', cf] + argv,
-        stdout=PIPE, stderr=PIPE, close_fds=True,
+        stdout=PIPE, stderr=PIPE, close_fds=(sys.platform != 'win32'),
     )
 
 


Test patch:
Repository: ipython/ipython

Issue:
parallel.client.client references undefined error.EngineError
parallel/client/client.py, line 712 tries to instantiate the undefined class error.EngineError
It seems to me that it should be defined in parallel/error.py
I'm using IPython 1.0.0
In the current master trunk, error.EngineError is referenced on line 718, and is still undefined.



Discussion:

Resolving patch:
diff --git a/IPython/parallel/error.py b/IPython/parallel/error.py
--- a/IPython/parallel/error.py
+++ b/IPython/parallel/error.py
@@ -43,6 +43,9 @@ class IPythonError(Exception):
 class KernelError(IPythonError):
     pass
 
+class EngineError(KernelError):
+    pass
+
 class NoEnginesRegistered(KernelError):
     pass
 


Test patch:
Repository: ipython/ipython

Issue:
Wrong default argument of DirectView.clear
DirectView.clear
in
parallel/client/view.py
line 800
seems to have the wrong default-argument for _block_:
def clear(self, targets=None, block=False)

It should probably be None instead of False.



Discussion:

Resolving patch:
diff --git a/IPython/parallel/client/view.py b/IPython/parallel/client/view.py
--- a/IPython/parallel/client/view.py
+++ b/IPython/parallel/client/view.py
@@ -379,7 +379,7 @@ def imap(self, f, *sequences, **kwargs):
     # Decorators
     #-------------------------------------------------------------------
 
-    def remote(self, block=True, **flags):
+    def remote(self, block=None, **flags):
         """Decorator for making a RemoteFunction"""
         block = self.block if block is None else block
         return remote(self, block=block, **flags)
@@ -797,7 +797,7 @@ def __getitem__(self, key):
     def __setitem__(self,key, value):
         self.update({key:value})
 
-    def clear(self, targets=None, block=False):
+    def clear(self, targets=None, block=None):
         """Clear the remote namespaces on my engines."""
         block = block if block is not None else self.block
         targets = targets if targets is not None else self.targets


Test patch:
Repository: ipython/ipython

Issue:
nbconvert markdown issues
Markdown converter is set to show html output as the richest repr, but does not show it. and add extra $$ around latex one.



Discussion:
same with rst converter


Resolving patch:
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
@@ -68,7 +68,8 @@
         'strip_math_space': filters.strip_math_space,
         'wrap_text': filters.wrap_text,
         'escape_latex': filters.escape_latex,
-        'citation2latex': filters.citation2latex
+        'citation2latex': filters.citation2latex,
+        'path2url': filters.path2url,
 }
 
 #-----------------------------------------------------------------------------
diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py
--- a/IPython/nbconvert/exporters/markdown.py
+++ b/IPython/nbconvert/exporters/markdown.py
@@ -13,6 +13,7 @@
 # Imports
 #-----------------------------------------------------------------------------
 
+from IPython.config import Config
 from IPython.utils.traitlets import Unicode
 
 from .exporter import Exporter
@@ -29,3 +30,9 @@ class MarkdownExporter(Exporter):
     file_extension = Unicode(
         'md', config=True, 
         help="Extension of the file that should be written to disk")
+
+    @property
+    def default_config(self):
+        c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
+        c.merge(super(MarkdownExporter,self).default_config)
+        return c
diff --git a/IPython/nbconvert/filters/strings.py b/IPython/nbconvert/filters/strings.py
--- a/IPython/nbconvert/filters/strings.py
+++ b/IPython/nbconvert/filters/strings.py
@@ -19,6 +19,7 @@
 import os
 import re
 import textwrap
+from urllib2 import quote
 from xml.etree import ElementTree
 
 from IPython.core.interactiveshell import InteractiveShell
@@ -38,6 +39,7 @@
     'get_lines',
     'ipython2python',
     'posix_path',
+    'path2url',
 ]
 
 
@@ -181,3 +183,8 @@ def posix_path(path):
     if os.path.sep != '/':
         return path.replace(os.path.sep, '/')
     return path
+
+def path2url(path):
+    """Turn a file path into a URL"""
+    parts = path.split(os.path.sep)
+    return '/'.join(quote(part) for part in parts)


Test patch:
Repository: ipython/ipython

Issue:
remove spurious print statement from parallel annoted functions
```
my_view.map(lambda x : x + 1, range(4))
```

versus

```
@my_view.parallel()
def testMap(x):
  return x[0] + 1

testMap(range(100))
```

the second one prints out an annoying

```
in sync results <function ParallelFunction.__call__ at 0x7fb058110950>
```

Presumably left over from debugging?



Discussion:

Resolving patch:
diff --git a/IPython/parallel/client/remotefunction.py b/IPython/parallel/client/remotefunction.py
--- a/IPython/parallel/client/remotefunction.py
+++ b/IPython/parallel/client/remotefunction.py
@@ -89,7 +89,6 @@ def sync_view_results(f, self, *args, **kwargs):
     view = self.view
     if view._in_sync_results:
         return f(self, *args, **kwargs)
-    print 'in sync results', f
     view._in_sync_results = True
     try:
         ret = f(self, *args, **kwargs)


Test patch:
diff --git a/IPython/parallel/tests/__init__.py b/IPython/parallel/tests/__init__.py
--- a/IPython/parallel/tests/__init__.py
+++ b/IPython/parallel/tests/__init__.py
@@ -63,8 +63,7 @@ def setup():
     tic = time.time()
     while not os.path.exists(engine_json) or not os.path.exists(client_json):
         if cp.poll() is not None:
-            print cp.poll()
-            raise RuntimeError("The test controller failed to start.")
+            raise RuntimeError("The test controller exited with status %s" % cp.poll())
         elif time.time()-tic > 15:
             raise RuntimeError("Timeout waiting for the test controller to start.")
         time.sleep(0.1)
diff --git a/IPython/parallel/tests/test_client.py b/IPython/parallel/tests/test_client.py
--- a/IPython/parallel/tests/test_client.py
+++ b/IPython/parallel/tests/test_client.py
@@ -172,7 +172,6 @@ def test_get_execute_result(self):
         # give the monitor time to notice the message
         time.sleep(.25)
         ahr = self.client.get_result(ar.msg_ids[0])
-        print ar.get(), ahr.get(), ar._single_result, ahr._single_result
         self.assertTrue(isinstance(ahr, AsyncHubResult))
         self.assertEqual(ahr.get().pyout, ar.get().pyout)
         ar2 = self.client.get_result(ar.msg_ids[0])
Repository: ipython/ipython

Issue:
Nbconvert, default_preprocessors to list of dotted name not list of obj
in some places in nbconvert we have default that are list of object.
they should be list of `DottedObject` (strings). Which is probably easier to configure, 
and does not lead to the following in config files ...

```
# List of preprocessors available by default, by name, namespace,  instance, or
# type.
# c.TemplateExporter.default_preprocessors = [<function wrappedfunc at 
0x106d86d70>, <class
 'IPython.nbconvert.preprocessors.svg2pdf.SVG2PDFPreprocessor'>, <class 
'IPython.nbconvert.preprocessors.extractoutput.ExtractOutputPreprocessor'>, <class 
'IPython.nbconvert.preprocessors.csshtmlheader.CSSHTMLHeaderPreprocessor'>, 
<class 'IPython.nbconvert.preprocessors.revealhelp.RevealHelpPreprocessor'>, <class 
'IPython.nbconvert.preprocessors.latex.LatexPreprocessor'>, <class 
'IPython.nbconvert.preprocessors.highlightmagics.HighlightMagicsPreprocessor'>]
```

nothing prevent us from also supporting directly object/fucntions ...



Discussion:

Resolving patch:
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
@@ -62,13 +62,13 @@ class Exporter(LoggingConfigurable):
 
     _preprocessors = None
 
-    default_preprocessors = List([nbpreprocessors.coalesce_streams,
-                                 nbpreprocessors.SVG2PDFPreprocessor,
-                                 nbpreprocessors.ExtractOutputPreprocessor,
-                                 nbpreprocessors.CSSHTMLHeaderPreprocessor,
-                                 nbpreprocessors.RevealHelpPreprocessor,
-                                 nbpreprocessors.LatexPreprocessor,
-                                 nbpreprocessors.HighlightMagicsPreprocessor],
+    default_preprocessors = List(['IPython.nbconvert.preprocessors.coalesce_streams',
+                                  'IPython.nbconvert.preprocessors.SVG2PDFPreprocessor',
+                                  'IPython.nbconvert.preprocessors.ExtractOutputPreprocessor',
+                                  'IPython.nbconvert.preprocessors.CSSHTMLHeaderPreprocessor',
+                                  'IPython.nbconvert.preprocessors.RevealHelpPreprocessor',
+                                  'IPython.nbconvert.preprocessors.LatexPreprocessor',
+                                  'IPython.nbconvert.preprocessors.HighlightMagicsPreprocessor'],
         config=True,
         help="""List of preprocessors available by default, by name, namespace, 
         instance, or type.""")


Test patch:
Repository: ipython/ipython

Issue:
sync_imports() fails in python 3.3
builtins.**import** no longer seems to use level=-1,
view.py, line 481:
if level == -1 and key not in modules:

This if never get executed and nothing is imported on engines because level defaults to 0 for python 3.3

I changed to:
if level == 0 and key not in modules:
Which works for me, but is probably not a good fix.



Discussion:
Can you give an example of a failure? Ideally, we'd write a test which currently fails, then fix it so that the test passes.


Resolving patch:
diff --git a/IPython/parallel/client/view.py b/IPython/parallel/client/view.py
--- a/IPython/parallel/client/view.py
+++ b/IPython/parallel/client/view.py
@@ -457,7 +457,7 @@ def remote_import(name, fromlist, level):
             else:
                 user_ns[name] = sys.modules[name]
 
-        def view_import(name, globals={}, locals={}, fromlist=[], level=-1):
+        def view_import(name, globals={}, locals={}, fromlist=[], level=0):
             """the drop-in replacement for __import__, that optionally imports
             locally as well.
             """
@@ -478,7 +478,7 @@ def view_import(name, globals={}, locals={}, fromlist=[], level=-1):
             imp.release_lock()
 
             key = name+':'+','.join(fromlist or [])
-            if level == -1 and key not in modules:
+            if level <= 0 and key not in modules:
                 modules.add(key)
                 if not quiet:
                     if fromlist:


Test patch:
diff --git a/IPython/parallel/tests/test_view.py b/IPython/parallel/tests/test_view.py
--- a/IPython/parallel/tests/test_view.py
+++ b/IPython/parallel/tests/test_view.py
@@ -805,4 +805,30 @@ def echoxy(p):
         view = self.client[-1]
         tup = view.apply_sync(echoxy, point(1, 2))
         self.assertEqual(tup, (2,1))
+    
+    def test_sync_imports(self):
+        view = self.client[-1]
+        with capture_output() as io:
+            with view.sync_imports():
+                import IPython
+        self.assertIn("IPython", io.stdout)
+        
+        @interactive
+        def find_ipython():
+            return 'IPython' in globals()
+        
+        assert view.apply_sync(find_ipython)
+
+    def test_sync_imports_quiet(self):
+        view = self.client[-1]
+        with capture_output() as io:
+            with view.sync_imports(quiet=True):
+                import IPython
+        self.assertEqual(io.stdout, '')
+        
+        @interactive
+        def find_ipython():
+            return 'IPython' in globals()
+        
+        assert view.apply_sync(find_ipython)
Repository: ipython/ipython

Issue:
local mathjax install doesn't work
Hi,

the command line provided in the popup when using mathjax offline doesn't work:
from IPython.external import mathjax; mathjax.install_mathjax()

the url is out of date:
HTTPError: HTTP Error 500: Internal Server Error
Downloading mathjax source from https://github.com/mathjax/MathJax/tarball/v2.2

x.



Discussion:

Resolving patch:
diff --git a/IPython/external/mathjax.py b/IPython/external/mathjax.py
--- a/IPython/external/mathjax.py
+++ b/IPython/external/mathjax.py
@@ -164,7 +164,7 @@ def install_mathjax(tag='v2.2', dest=default_dest, replace=False, file=None, ext
 
     if file is None:
         # download mathjax
-        mathjax_url = "https://github.com/mathjax/MathJax/tarball/%s" % tag
+        mathjax_url = "https://github.com/mathjax/MathJax/archive/%s.tar.gz" %tag
         print "Downloading mathjax source from %s" % mathjax_url
         response = urllib2.urlopen(mathjax_url)
         file = response.fp


Test patch: