summarylogtreecommitdiffstats
path: root/sagemath-ipython7.patch
blob: 7c7951f2c475a3a5b541b89f59f266c7bab7139a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py
index 11967fbf96..ccb9c4e0c0 100644
--- a/src/sage/repl/attach.py
+++ b/src/sage/repl/attach.py
@@ -597,12 +597,7 @@ def reload_attached_files_if_modified():
         basename = os.path.basename(filename)
         timestr = time.strftime('%T', mtime)
         notice = '### reloading attached file {0} modified at {1} ###'.format(basename, timestr)
-        if ip and ip.pt_cli:
-            with ip.pt_cli.patch_stdout_context(raw=True):
-                print(notice)
-                code = load_wrap(filename, attach=True)
-                ip.run_cell(code)
-        elif ip:
+        if ip:
             print(notice)
             code = load_wrap(filename, attach=True)
             ip.run_cell(code)
diff --git a/src/sage/repl/display/fancy_repr.py b/src/sage/repl/display/fancy_repr.py
index 818498fbae..af33f92126 100644
--- a/src/sage/repl/display/fancy_repr.py
+++ b/src/sage/repl/display/fancy_repr.py
@@ -15,10 +15,12 @@ Representations of objects.
 import types
 
 from IPython.lib.pretty import (
-    _safe_getattr, _baseclass_reprs,
+    _safe_getattr,
     _type_pprinters,
 )
 
+_baseclass_reprs = (object.__repr__,)
+
 from sage.repl.display.util import format_list
 
 
diff --git a/src/sage/repl/display/formatter.py b/src/sage/repl/display/formatter.py
index 5eece441c6..11db26b0db 100644
--- a/src/sage/repl/display/formatter.py
+++ b/src/sage/repl/display/formatter.py
@@ -173,8 +173,8 @@ class SageDisplayFormatter(DisplayFormatter):
             sage: shell.run_cell('ipython_image')
             <IPython.core.display.Image object>
             sage: shell.run_cell('get_ipython().display_formatter.format(ipython_image)')
-            ({u'image/png': ...'\x89PNG...',
-              u'text/plain': u'<IPython.core.display.Image object>'},
+            ({'image/png': ...',
+              'text/plain': '<IPython.core.display.Image object>'},
             {})
 
         Test that IPython images still work even in latex output mode::
diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
index e843486e26..780cae264d 100644
--- a/src/sage/repl/interpreter.py
+++ b/src/sage/repl/interpreter.py
@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
     dummy line
     ...
     ZeroDivisionError...Traceback (most recent call last)
-    <ipython-input-...> in <module>()
+    <ipython-input-...> in <module>...
     ----> 1 Integer(1)/Integer(0)
     .../sage/rings/integer.pyx in sage.rings.integer.Integer...div... (.../cythonized/sage/rings/integer.c:...)()
     ...
@@ -364,22 +364,19 @@ class SageTestShell(SageShellOverride, TerminalInteractiveShell):
 ###################################################################
 # Transformers used in the SageInputSplitter
 ###################################################################
-from IPython.core.inputtransformer import (CoroutineInputTransformer,
-                                           StatelessInputTransformer,
-                                           _strip_prompts)
+from IPython.core.inputtransformer2 import PromptStripper
 
-@StatelessInputTransformer.wrap
-def SagePreparseTransformer(line):
+def SagePreparseTransformer(lines):
     r"""
     EXAMPLES::
 
         sage: from sage.repl.interpreter import SagePreparseTransformer
-        sage: spt = SagePreparseTransformer()
-        sage: spt.push('1+1r+2.3^2.3r')
-        "Integer(1)+1+RealNumber('2.3')**2.3"
+        sage: spt = SagePreparseTransformer
+        sage: spt(['1+1r+2.3^2.3r'])
+        ["Integer(1)+1+RealNumber('2.3')**2.3"]
         sage: preparser(False)
-        sage: spt.push('2.3^2')
-        '2.3^2'
+        sage: spt(['2.3^2'])
+        ['2.3^2']
 
     TESTS:
 
@@ -400,57 +397,15 @@ def SagePreparseTransformer(line):
         <BLANKLINE>
         sage: shell.quit()
     """
-    if _do_preparse and not line.startswith('%'):
-        return preparse(line)
-    else:
-        return line
-
-@CoroutineInputTransformer.wrap
-def SagePromptTransformer():
-    r"""
-    Strip the sage:/....: prompts of Sage.
-
-    EXAMPLES::
-
-        sage: from sage.repl.interpreter import SagePromptTransformer
-        sage: spt = SagePromptTransformer()
-        sage: spt.push("sage: 2 + 2")
-        '2 + 2'
-        sage: spt.push('')
-        ''
-        sage: spt.push("....: 2+2")
-        '2+2'
-
-    This should strip multiple prompts: see :trac:`16297`::
-
-        sage: spt.push("sage:   sage: 2+2")
-        '2+2'
-        sage: spt.push("   sage: ....: 2+2")
-        '2+2'
-
-    The prompt contains a trailing space. Extra spaces between the
-    last prompt and the remainder should not be stripped::
-
-        sage: spt.push("   sage: ....:    2+2")
-        '   2+2'
-
-    We test that the input transformer is enabled on the Sage command
-    line::
-
-        sage: from sage.repl.interpreter import get_test_shell
-        sage: shell = get_test_shell()
-        sage: shell.run_cell('sage: a = 123')              # single line
-        sage: shell.run_cell('sage: a = [\n... 123]')      # old-style multi-line
-        sage: shell.run_cell('sage: a = [\n....: 123]')    # new-style multi-line
-
-    We test that :trac:`16196` is resolved::
+    lines_out = []
+    for line in lines:
+        if _do_preparse and not line.startswith('%'):
+            lines_out += [preparse(line)]
+        else:
+            lines_out += [line]
+    return lines_out
 
-        sage: shell.run_cell('    sage: 1+1')
-        2
-        sage: shell.quit()
-    """
-    _sage_prompt_re = re.compile(r'^(\s*(:?sage: |\.\.\.\.: ))+')
-    return _strip_prompts(_sage_prompt_re)
+SagePromptTransformer = PromptStripper(prompt_re=re.compile(r'^(\s*(:?sage: |\.\.\.\.: ))+'))
 
 ###################
 # Interface shell #
@@ -612,7 +567,7 @@ def interface_shell_embed(interface):
         sage: shell = interface_shell_embed(gap)
         sage: shell.run_cell('List( [1..10], IsPrime )')
         [ false, true, true, false, true, false, true, false, false, false ]
-        <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None result=[ false, true, true, false, true, false, true, false, false, false ]>
+        <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None ...result=[ false, true, true, false, true, false, true, false, false, false ]>
     """
     cfg = sage_ipython_config.copy()
     ipshell = InteractiveShellEmbed(config=cfg,
diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py
index fd27b43fc4..a0a9f80dff 100644
--- a/src/sage/repl/ipython_extension.py
+++ b/src/sage/repl/ipython_extension.py
@@ -511,10 +511,8 @@ class SageCustomizations(object):
         from .interpreter import (SagePreparseTransformer,
                                  SagePromptTransformer)
 
-        for s in (self.shell.input_splitter, self.shell.input_transformer_manager):
-            s.physical_line_transforms.insert(1, SagePromptTransformer())
-            s.python_line_transforms.append(SagePreparseTransformer())
-
+        self.shell.input_transformers_cleanup.insert(1, SagePromptTransformer)
+        self.shell.input_transformers_post.append(SagePreparseTransformer)
 
 class SageJupyterCustomizations(SageCustomizations):
     @staticmethod
diff --git a/src/sage/repl/ipython_tests.py b/src/sage/repl/ipython_tests.py
index d342ba7fac..ab9504337e 100644
--- a/src/sage/repl/ipython_tests.py
+++ b/src/sage/repl/ipython_tests.py
@@ -42,6 +42,7 @@ Next, test the pinfo magic for Cython code::
     Init docstring: ...ee help(type(...)) for...signature...
     File:           .../sage/tests/stl_vector.pyx
     Type:           type
+    ...
 
 Next, test the ``pinfo`` magic for ``R`` interface code, see :trac:`26906`::
 
@@ -67,6 +68,7 @@ calls when you ask for the double-questionmark help, like `foo??` ::
     sage: shell.run_cell(u'from sage.repl.ipython_tests import dummy')
     sage: shell.run_cell(u'%pinfo2 dummy')
     Signature: dummy(argument, optional=None)
+    ...
     Source:
     def dummy(argument, optional=None):
         """
@@ -116,6 +118,7 @@ Next, test the pinfo2 magic for Cython code::
     ...
     File:   .../sage/tests/stl_vector.pyx
     Type:   type
+    ...
 
 Next, test the ``pinfo2`` magic for ``R`` interface code, see :trac:`26906`::
 
diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
index 9c6ec027d0..4d3521c3e8 100644
--- a/src/sage/rings/qqbar.py
+++ b/src/sage/rings/qqbar.py
@@ -8096,13 +8096,13 @@ class ANBinaryExpr(ANDescr):
         decrease it before we return::
 
             sage: import sys; sys.getrecursionlimit()
-            1000
+            3000
             sage: s = SymmetricFunctions(QQ).schur()
             sage: a=s([3,2]).expand(8)(flatten([[QQbar.zeta(3)^d for d in range(3)], [QQbar.zeta(5)^d for d in range(5)]]))
             sage: a.exactify(); a # long time
             0
             sage: sys.getrecursionlimit()
-            1000
+            3000
 
         """
         import sys