Opened 5 years ago

Closed 5 years ago

#16053 closed enhancement (duplicate)

Update to IPython 2.1

Reported by: jason Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: packages: standard Keywords:
Cc: Merged in:
Authors: Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by tmonteil)

IPython 2.0 was released yesterday and contains quite some good stuff, in particular extended support for interactive widgets:

http://ipython.org/ipython-doc/2/whatsnew/version2.0.html

I don't think it requires significant changes, as most relevant changes were made to update to IPython 1.2.1 on #14713.

We might consider bundling the dependencies needed to run the IPython notebook, see #16455. That would give users two ways of having an online notebook.

Change History (10)

comment:1 Changed 5 years ago by nthiery

  • Description modified (diff)

comment:2 Changed 5 years ago by nthiery

  • Description modified (diff)

+1 on bundling pyzmq and tornado.

comment:3 Changed 5 years ago by jhpalmieri

We already build tornado, since matplotlib uses it.

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:5 Changed 5 years ago by rws

  • Summary changed from Update to IPython 2.0 to Update to IPython 2.1

Looking at the new 2.1 vs. our previous patch file, nearly all patches from the changeset have been applied upstream, except these three:

 IPython/core/interactiveshell.py                   | 308 +++++++++++----------
 .../pr/incompat-inputsplitter-source-raw-reset.rst |   6 +
 .../whatsnew/pr/inputtransformer-syntaxerrors.rst  |   4 +
 create mode 100644 docs/source/whatsnew/pr/incompat-inputsplitter-source-raw-reset.rst
 create mode 100644 docs/source/whatsnew/pr/inputtransformer-syntaxerrors.rst

@@ -2613,73 +2647,53 @@ def run_cell(self, raw_cell, store_history=False, silent=False, shell_futures=Tr
         compiler = self.compile if shell_futures else CachingCompiler()
 
         with self.builtin_trap:
-            prefilter_failed = False
-            if len(cell.splitlines()) == 1:
-                try:
-                    # use prefilter_lines to handle trailing newlines
-                    # restore trailing newline for ast.parse
-                    cell = self.prefilter_manager.prefilter_lines(cell) + '\n'
-                except AliasError as e:
-                    error(e)
-                    prefilter_failed = True
-                except Exception:
-                    # don't allow prefilter errors to crash IPython
-                    self.showtraceback()
-                    prefilter_failed = True
-
-            # Store raw and processed history
-            if store_history:
-                self.history_manager.store_inputs(self.execution_count,
-                                                  cell, raw_cell)
-            if not silent:
-                self.logger.log(cell, raw_cell)
-
-            if not prefilter_failed:
-                # don't run if prefilter failed
-                cell_name = self.compile.cache(cell, self.execution_count)
+            cell_name = self.compile.cache(cell, self.execution_count)
 
-                with self.display_trap:
+            with self.display_trap:
+                # Compile to bytecode
+                try:
+                    code_ast = compiler.ast_parse(cell, filename=cell_name)
+                except IndentationError:
+                    self.showindentationerror()
+                    if store_history:
+                        self.execution_count += 1
+                    return None
+                except (OverflowError, SyntaxError, ValueError, TypeError,
+                        MemoryError):
+                    self.showsyntaxerror()
+                    if store_history:
+                        self.execution_count += 1
+                    return None
+
+                # Apply AST transformations
+                code_ast = self.transform_ast(code_ast)
+
+                # Execute the user code
+                interactivity = "none" if silent else self.ast_node_interactivity
+                self.run_ast_nodes(code_ast.body, cell_name,
+                                   interactivity=interactivity, compiler=compiler)
+
+                # Execute any registered post-execution functions.
+                # unless we are silent
+                post_exec = [] if silent else self._post_execute.iteritems()
+
+                for func, status in post_exec:
+                    if self.disable_failing_post_execute and not status:
+                        continue
                     try:
-                        code_ast = compiler.ast_parse(cell, filename=cell_name)
-                    except IndentationError:
-                        self.showindentationerror()
-                        if store_history:
-                            self.execution_count += 1
-                        return None
-                    except (OverflowError, SyntaxError, ValueError, TypeError,
-                            MemoryError):
-                        self.showsyntaxerror()
-                        if store_history:
-                            self.execution_count += 1
-                        return None
-                    
-                    code_ast = self.transform_ast(code_ast)
-                    
-                    interactivity = "none" if silent else self.ast_node_interactivity
-                    self.run_ast_nodes(code_ast.body, cell_name,
-                                       interactivity=interactivity, compiler=compiler)
-                    
-                    # Execute any registered post-execution functions.
-                    # unless we are silent
-                    post_exec = [] if silent else self._post_execute.iteritems()
-                    
-                    for func, status in post_exec:
-                        if self.disable_failing_post_execute and not status:
-                            continue
-                        try:
-                            func()
-                        except KeyboardInterrupt:
-                            print("\nKeyboardInterrupt", file=io.stderr)
-                        except Exception:
-                            # register as failing:
-                            self._post_execute[func] = False
-                            self.showtraceback()
-                            print('\n'.join([
-                                "post-execution function %r produced an error." % func,
-                                "If this problem persists, you can disable failing post-exec functions with:",
-                                "",
-                                "    get_ipython().disable_failing_post_execute = True"
-                            ]), file=io.stderr)
+                        func()
+                    except KeyboardInterrupt:
+                        print("\nKeyboardInterrupt", file=io.stderr)
+                    except Exception:
+                        # register as failing:
+                        self._post_execute[func] = False
+                        self.showtraceback()
+                        print('\n'.join([
+                            "post-execution function %r produced an error." % func,
+                            "If this problem persists, you can disable failing post-exec functions with:",
+                            "",
+                            "    get_ipython().disable_failing_post_execute = True"
+                        ]), file=io.stderr)
 
         if store_history:
             # Write output to the database. Does nothing unless
diff --git a/docs/source/whatsnew/pr/incompat-inputsplitter-source-raw-reset.rst b/docs/source/whatsnew/pr/incompat-inputsplitter-source-raw-reset.rst
new file mode 100644
index 0000000..7e9056f
--- /dev/null
+++ b/docs/source/whatsnew/pr/incompat-inputsplitter-source-raw-reset.rst
@@ -0,0 +1,6 @@
+* :class:`IPython.core.inputsplitter.IPythonInputSplitter` no longer has a method
+  ``source_raw_reset()``, but gains :meth:`~IPython.core.inputsplitter.IPythonInputSplitter.raw_reset`
+  instead. Use of ``source_raw_reset`` can be replaced with::
+  
+      raw = isp.source_raw
+      transformed = isp.source_reset()
diff --git a/docs/source/whatsnew/pr/inputtransformer-syntaxerrors.rst b/docs/source/whatsnew/pr/inputtransformer-syntaxerrors.rst
new file mode 100644
index 0000000..74d3594
--- /dev/null
+++ b/docs/source/whatsnew/pr/inputtransformer-syntaxerrors.rst
@@ -0,0 +1,4 @@
+* Input transformers (see :doc:`/config/inputtransforms`) may now raise
+  :exc:`SyntaxError` if they determine that input is invalid. The input
+  transformation machinery in IPython will handle displaying the exception to
+  the user and resetting state.
-- 
1.8.5.3

where the first half of the first was applied too but the post-execute part was changed quite differently than we did, and I have no idea what still has to be changed in 2.1, if anything. Also the two rst files have not been included, curiously.

comment:6 Changed 5 years ago by tmonteil

  • Description modified (diff)

comment:7 Changed 5 years ago by tmonteil

Ticket #16455 updates zeromq and pyzmq to latest version and new git layout, so if they become standard packages, IPython notebook will work out of the box within Sage.

comment:8 Changed 5 years ago by tmonteil

  • Milestone changed from sage-6.3 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

It seems this ticket became a duplicate of #16488.

comment:9 Changed 5 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

Concur.

comment:10 Changed 5 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.