#16053: Update to IPython 2.1
--------------------------------------+------------------------
Reporter: jason | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: packages: standard | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
--------------------------------------+------------------------
Comment (by rws):
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.
--
Ticket URL: <http://trac.sagemath.org/ticket/16053#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.