1 | ~/sagefiles/sage-9.2.rc0/src/bin/sage-ipython in <module> |
---|
2 | |
---|
3 | 1 #!/usr/bin/env sage-python |
---|
4 | |
---|
5 | 2 # -*- coding: utf-8 -*- |
---|
6 | |
---|
7 | 3 """ |
---|
8 | |
---|
9 | 4 Sage IPython startup script. |
---|
10 | |
---|
11 | 5 """ |
---|
12 | |
---|
13 | 6 |
---|
14 | |
---|
15 | 7 # Display startup banner. Do this before anything else to give the user |
---|
16 | |
---|
17 | 8 # early feedback that Sage is starting. |
---|
18 | |
---|
19 | 9 from sage.misc.banner import banner |
---|
20 | |
---|
21 | 10 banner() |
---|
22 | |
---|
23 | 11 |
---|
24 | |
---|
25 | 12 from sage.repl.interpreter import SageTerminalApp |
---|
26 | |
---|
27 | 13 |
---|
28 | |
---|
29 | 14 app = SageTerminalApp.instance() |
---|
30 | |
---|
31 | ---> 15 app.initialize() |
---|
32 | |
---|
33 | global app.initialize = <bound method TerminalIPythonApp.initialize of <sage.repl.interpreter.SageTerminalApp object at 0x104527880>> |
---|
34 | |
---|
35 | 16 app.start() |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | </Users/wdj/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/decorator.py:decorator-gen-113> in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None) |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/traitlets/config/application.py in catch_config_error(method=<function TerminalIPythonApp.initialize>, app=<sage.repl.interpreter.SageTerminalApp object>, *args=(None,), **kwargs={}) |
---|
44 | |
---|
45 | 72 TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False |
---|
46 | |
---|
47 | 73 else: |
---|
48 | |
---|
49 | 74 raise ValueError("Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar ) |
---|
50 | |
---|
51 | 75 |
---|
52 | |
---|
53 | 76 |
---|
54 | |
---|
55 | 77 @decorator |
---|
56 | |
---|
57 | 78 def catch_config_error(method, app, *args, **kwargs): |
---|
58 | |
---|
59 | 79 """Method decorator for catching invalid config (Trait/ArgumentErrors) during init. |
---|
60 | |
---|
61 | 80 |
---|
62 | |
---|
63 | 81 On a TraitError (generally caused by bad config), this will print the trait's |
---|
64 | |
---|
65 | 82 message, and exit the app. |
---|
66 | |
---|
67 | 83 |
---|
68 | |
---|
69 | 84 For use on init methods, to prevent invoking excepthook on invalid input. |
---|
70 | |
---|
71 | 85 """ |
---|
72 | |
---|
73 | 86 try: |
---|
74 | |
---|
75 | ---> 87 return method(app, *args, **kwargs) |
---|
76 | |
---|
77 | method = <function TerminalIPythonApp.initialize at 0x105f83af0> |
---|
78 | |
---|
79 | app = <sage.repl.interpreter.SageTerminalApp object at 0x104527880> |
---|
80 | |
---|
81 | args = (None,) |
---|
82 | |
---|
83 | kwargs = {} |
---|
84 | |
---|
85 | 88 except (TraitError, ArgumentError) as e: |
---|
86 | |
---|
87 | 89 app.print_help() |
---|
88 | |
---|
89 | 90 app.log.fatal("Bad config encountered during initialization:") |
---|
90 | |
---|
91 | 91 app.log.fatal(str(e)) |
---|
92 | |
---|
93 | 92 app.log.debug("Config at the time: %s", app.config) |
---|
94 | |
---|
95 | 93 app.exit(1) |
---|
96 | |
---|
97 | 94 |
---|
98 | |
---|
99 | 95 |
---|
100 | |
---|
101 | 96 class ApplicationError(Exception): |
---|
102 | |
---|
103 | 97 pass |
---|
104 | |
---|
105 | 98 |
---|
106 | |
---|
107 | 99 |
---|
108 | |
---|
109 | 100 class LevelFormatter(logging.Formatter): |
---|
110 | |
---|
111 | 101 """Formatter with additional `highlevel` record |
---|
112 | |
---|
113 | 102 |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/IPython/terminal/ipapp.py in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None) |
---|
118 | |
---|
119 | 302 |
---|
120 | |
---|
121 | 303 return super(TerminalIPythonApp, self).parse_command_line(argv) |
---|
122 | |
---|
123 | 304 |
---|
124 | |
---|
125 | 305 @catch_config_error |
---|
126 | |
---|
127 | 306 def initialize(self, argv=None): |
---|
128 | |
---|
129 | 307 """Do actions after construct, but before starting the app.""" |
---|
130 | |
---|
131 | 308 super(TerminalIPythonApp, self).initialize(argv) |
---|
132 | |
---|
133 | 309 if self.subapp is not None: |
---|
134 | |
---|
135 | 310 # don't bother initializing further, starting subapp |
---|
136 | |
---|
137 | 311 return |
---|
138 | |
---|
139 | 312 # print self.extra_args |
---|
140 | |
---|
141 | 313 if self.extra_args and not self.something_to_run: |
---|
142 | |
---|
143 | 314 self.file_to_run = self.extra_args[0] |
---|
144 | |
---|
145 | 315 self.init_path() |
---|
146 | |
---|
147 | 316 # create the shell |
---|
148 | |
---|
149 | --> 317 self.init_shell() |
---|
150 | |
---|
151 | self.init_shell = <bound method SageTerminalApp.init_shell of <sage.repl.interpreter.SageTerminalApp object at 0x104527880>> |
---|
152 | |
---|
153 | 318 # and draw the banner |
---|
154 | |
---|
155 | 319 self.init_banner() |
---|
156 | |
---|
157 | 320 # Now a variety of things that happen after the banner is printed. |
---|
158 | |
---|
159 | 321 self.init_gui_pylab() |
---|
160 | |
---|
161 | 322 self.init_extensions() |
---|
162 | |
---|
163 | 323 self.init_code() |
---|
164 | |
---|
165 | 324 |
---|
166 | |
---|
167 | 325 def init_shell(self): |
---|
168 | |
---|
169 | 326 """initialize the InteractiveShell instance""" |
---|
170 | |
---|
171 | 327 # Create an InteractiveShell instance. |
---|
172 | |
---|
173 | 328 # shell.display_banner should always be False for the terminal |
---|
174 | |
---|
175 | 329 # based app, because we call shell.show_banner() by hand below |
---|
176 | |
---|
177 | 330 # so the banner shows *before* all extension loading stuff. |
---|
178 | |
---|
179 | 331 self.shell = self.interactive_shell_class.instance(parent=self, |
---|
180 | |
---|
181 | 332 profile_dir=self.profile_dir, |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/repl/interpreter.py in init_shell(self=<sage.repl.interpreter.SageTerminalApp object>) |
---|
186 | |
---|
187 | 755 Initialize the :class:`SageInteractiveShell` instance. |
---|
188 | |
---|
189 | 756 |
---|
190 | |
---|
191 | 757 .. note:: |
---|
192 | |
---|
193 | 758 |
---|
194 | |
---|
195 | 759 This code is based on |
---|
196 | |
---|
197 | 760 :meth:`TerminalIPythonApp.init_shell`. |
---|
198 | |
---|
199 | 761 |
---|
200 | |
---|
201 | 762 EXAMPLES:: |
---|
202 | |
---|
203 | 763 |
---|
204 | |
---|
205 | 764 sage: from sage.repl.interpreter import SageTerminalApp |
---|
206 | |
---|
207 | 765 sage: app = SageTerminalApp.instance() |
---|
208 | |
---|
209 | 766 sage: app.shell |
---|
210 | |
---|
211 | 767 <sage.repl.interpreter.SageTestShell object at 0x...> |
---|
212 | |
---|
213 | 768 """ |
---|
214 | |
---|
215 | 769 # Shell initialization |
---|
216 | |
---|
217 | --> 770 self.shell = self.shell_class.instance( |
---|
218 | |
---|
219 | self.shell = None |
---|
220 | |
---|
221 | self.shell_class.instance = <bound method SingletonConfigurable.instance of <class 'sage.repl.interpreter.SageTerminalInteractiveShell'>> |
---|
222 | |
---|
223 | global parent = undefined |
---|
224 | |
---|
225 | self = <sage.repl.interpreter.SageTerminalApp object at 0x104527880> |
---|
226 | |
---|
227 | global config = undefined |
---|
228 | |
---|
229 | self.config = {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': <class 'sage.repl.interpreter.SageTerminalInteractiveShell'>}, 'InteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'SageTerminalApp': {'force_interact': True}} |
---|
230 | |
---|
231 | global profile_dir = undefined |
---|
232 | |
---|
233 | self.profile_dir = <IPython.core.profiledir.ProfileDir object at 0x105fa5be0> |
---|
234 | |
---|
235 | global ipython_dir = undefined |
---|
236 | |
---|
237 | self.ipython_dir = '/Users/wdj/.sage/ipython-5.0.0' |
---|
238 | |
---|
239 | 771 parent=self, |
---|
240 | |
---|
241 | 772 config=self.config, |
---|
242 | |
---|
243 | 773 profile_dir=self.profile_dir, |
---|
244 | |
---|
245 | 774 ipython_dir=self.ipython_dir) |
---|
246 | |
---|
247 | 775 self.shell.configurables.append(self) |
---|
248 | |
---|
249 | 776 self.shell.has_sage_extensions = SAGE_EXTENSION in self.extensions |
---|
250 | |
---|
251 | 777 |
---|
252 | |
---|
253 | 778 # Load the %lprun extension if available |
---|
254 | |
---|
255 | 779 try: |
---|
256 | |
---|
257 | 780 import line_profiler |
---|
258 | |
---|
259 | 781 except ImportError: |
---|
260 | |
---|
261 | 782 pass |
---|
262 | |
---|
263 | 783 else: |
---|
264 | |
---|
265 | 784 self.extensions.append('line_profiler') |
---|
266 | |
---|
267 | 785 |
---|
268 | |
---|
269 | |
---|
270 | |
---|
271 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/traitlets/config/configurable.py in instance(cls=<class 'sage.repl.interpreter.SageTerminalInteractiveShell'>, *args=(), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...']}, 'SageTerminalApp': {'force_interact': True}}, 'ipython_dir': '/Users/wdj/.sage/ipython-5.0.0', 'parent': <sage.repl.interpreter.SageTerminalApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>}) |
---|
272 | |
---|
273 | 397 >>> class Foo(SingletonConfigurable): pass |
---|
274 | |
---|
275 | 398 >>> foo = Foo.instance() |
---|
276 | |
---|
277 | 399 >>> foo == Foo.instance() |
---|
278 | |
---|
279 | 400 True |
---|
280 | |
---|
281 | 401 |
---|
282 | |
---|
283 | 402 Create a subclass that is retrived using the base class instance:: |
---|
284 | |
---|
285 | 403 |
---|
286 | |
---|
287 | 404 >>> class Bar(SingletonConfigurable): pass |
---|
288 | |
---|
289 | 405 >>> class Bam(Bar): pass |
---|
290 | |
---|
291 | 406 >>> bam = Bam.instance() |
---|
292 | |
---|
293 | 407 >>> bam == Bar.instance() |
---|
294 | |
---|
295 | 408 True |
---|
296 | |
---|
297 | 409 """ |
---|
298 | |
---|
299 | 410 # Create and save the instance |
---|
300 | |
---|
301 | 411 if cls._instance is None: |
---|
302 | |
---|
303 | --> 412 inst = cls(*args, **kwargs) |
---|
304 | |
---|
305 | inst = undefined |
---|
306 | |
---|
307 | cls = <class 'sage.repl.interpreter.SageTerminalInteractiveShell'> |
---|
308 | |
---|
309 | args = () |
---|
310 | |
---|
311 | kwargs = {'parent': <sage.repl.interpreter.SageTerminalApp object at 0x104527880>, 'config': {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': <class 'sage.repl.interpreter.SageTerminalInteractiveShell'>}, 'InteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'SageTerminalApp': {'force_interact': True}}, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x105fa5be0>, 'ipython_dir': '/Users/wdj/.sage/ipython-5.0.0'} |
---|
312 | |
---|
313 | 413 # Now make sure that the instance will also be returned by |
---|
314 | |
---|
315 | 414 # parent classes' _instance attribute. |
---|
316 | |
---|
317 | 415 for subclass in cls._walk_mro(): |
---|
318 | |
---|
319 | 416 subclass._instance = inst |
---|
320 | |
---|
321 | 417 |
---|
322 | |
---|
323 | 418 if isinstance(cls._instance, cls): |
---|
324 | |
---|
325 | 419 return cls._instance |
---|
326 | |
---|
327 | 420 else: |
---|
328 | |
---|
329 | 421 raise MultipleInstanceError( |
---|
330 | |
---|
331 | 422 'Multiple incompatible subclass instances of ' |
---|
332 | |
---|
333 | 423 '%s are being created.' % cls.__name__ |
---|
334 | |
---|
335 | 424 ) |
---|
336 | |
---|
337 | 425 |
---|
338 | |
---|
339 | 426 @classmethod |
---|
340 | |
---|
341 | 427 def initialized(cls): |
---|
342 | |
---|
343 | |
---|
344 | |
---|
345 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in __init__(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>, *args=(), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...']}, 'SageTerminalApp': {'force_interact': True}}, 'ipython_dir': '/Users/wdj/.sage/ipython-5.0.0', 'parent': <sage.repl.interpreter.SageTerminalApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>}) |
---|
346 | |
---|
347 | 504 |
---|
348 | |
---|
349 | 505 def init_alias(self): |
---|
350 | |
---|
351 | 506 # The parent class defines aliases that can be safely used with any |
---|
352 | |
---|
353 | 507 # frontend. |
---|
354 | |
---|
355 | 508 super(TerminalInteractiveShell, self).init_alias() |
---|
356 | |
---|
357 | 509 |
---|
358 | |
---|
359 | 510 # Now define aliases that only make sense on the terminal, because they |
---|
360 | |
---|
361 | 511 # need direct access to the console in a way that we can't emulate in |
---|
362 | |
---|
363 | 512 # GUI or web frontend |
---|
364 | |
---|
365 | 513 if os.name == 'posix': |
---|
366 | |
---|
367 | 514 for cmd in ('clear', 'more', 'less', 'man'): |
---|
368 | |
---|
369 | 515 self.alias_manager.soft_define_alias(cmd, cmd) |
---|
370 | |
---|
371 | 516 |
---|
372 | |
---|
373 | 517 |
---|
374 | |
---|
375 | 518 def __init__(self, *args, **kwargs): |
---|
376 | |
---|
377 | --> 519 super(TerminalInteractiveShell, self).__init__(*args, **kwargs) |
---|
378 | |
---|
379 | global super = undefined |
---|
380 | |
---|
381 | global TerminalInteractiveShell = <class 'IPython.terminal.interactiveshell.TerminalInteractiveShell'> |
---|
382 | |
---|
383 | self.__init__ = <bound method TerminalInteractiveShell.__init__ of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x105fa5dc0>> |
---|
384 | |
---|
385 | args = () |
---|
386 | |
---|
387 | kwargs = {'parent': <sage.repl.interpreter.SageTerminalApp object at 0x104527880>, 'config': {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': <class 'sage.repl.interpreter.SageTerminalInteractiveShell'>}, 'InteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': <class 'sage.repl.prompts.SagePrompts'>, 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'SageTerminalApp': {'force_interact': True}}, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x105fa5be0>, 'ipython_dir': '/Users/wdj/.sage/ipython-5.0.0'} |
---|
388 | |
---|
389 | 520 self.init_prompt_toolkit_cli() |
---|
390 | |
---|
391 | 521 self.init_term_title() |
---|
392 | |
---|
393 | 522 self.keep_running = True |
---|
394 | |
---|
395 | 523 |
---|
396 | |
---|
397 | 524 self.debugger_history = InMemoryHistory() |
---|
398 | |
---|
399 | 525 |
---|
400 | |
---|
401 | 526 def ask_exit(self): |
---|
402 | |
---|
403 | 527 self.keep_running = False |
---|
404 | |
---|
405 | 528 |
---|
406 | |
---|
407 | 529 rl_next_input = None |
---|
408 | |
---|
409 | 530 |
---|
410 | |
---|
411 | 531 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED): |
---|
412 | |
---|
413 | 532 |
---|
414 | |
---|
415 | 533 if display_banner is not DISPLAY_BANNER_DEPRECATED: |
---|
416 | |
---|
417 | 534 warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2) |
---|
418 | |
---|
419 | |
---|
420 | |
---|
421 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/IPython/core/interactiveshell.py in __init__(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>, ipython_dir='/Users/wdj/.sage/ipython-5.0.0', profile_dir=<IPython.core.profiledir.ProfileDir object>, user_module=None, user_ns=None, custom_exceptions=((), None), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...']}, 'SageTerminalApp': {'force_interact': True}}, 'parent': <sage.repl.interpreter.SageTerminalApp object>}) |
---|
422 | |
---|
423 | 668 self.init_pushd_popd_magic() |
---|
424 | |
---|
425 | 669 self.init_user_ns() |
---|
426 | |
---|
427 | 670 self.init_logger() |
---|
428 | |
---|
429 | 671 self.init_builtins() |
---|
430 | |
---|
431 | 672 |
---|
432 | |
---|
433 | 673 # The following was in post_config_initialization |
---|
434 | |
---|
435 | 674 self.init_inspector() |
---|
436 | |
---|
437 | 675 self.raw_input_original = input |
---|
438 | |
---|
439 | 676 self.init_completer() |
---|
440 | |
---|
441 | 677 # TODO: init_io() needs to happen before init_traceback handlers |
---|
442 | |
---|
443 | 678 # because the traceback handlers hardcode the stdout/stderr streams. |
---|
444 | |
---|
445 | 679 # This logic in in debugger.Pdb and should eventually be changed. |
---|
446 | |
---|
447 | 680 self.init_io() |
---|
448 | |
---|
449 | 681 self.init_traceback_handlers(custom_exceptions) |
---|
450 | |
---|
451 | 682 self.init_prompts() |
---|
452 | |
---|
453 | --> 683 self.init_display_formatter() |
---|
454 | |
---|
455 | self.init_display_formatter = <bound method SageTerminalInteractiveShell.init_display_formatter of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x105fa5dc0>> |
---|
456 | |
---|
457 | 684 self.init_display_pub() |
---|
458 | |
---|
459 | 685 self.init_data_pub() |
---|
460 | |
---|
461 | 686 self.init_displayhook() |
---|
462 | |
---|
463 | 687 self.init_magics() |
---|
464 | |
---|
465 | 688 self.init_alias() |
---|
466 | |
---|
467 | 689 self.init_logstart() |
---|
468 | |
---|
469 | 690 self.init_pdb() |
---|
470 | |
---|
471 | 691 self.init_extension_manager() |
---|
472 | |
---|
473 | 692 self.init_payload() |
---|
474 | |
---|
475 | 693 self.init_deprecation_warnings() |
---|
476 | |
---|
477 | 694 self.hooks.late_startup_hook() |
---|
478 | |
---|
479 | 695 self.events.trigger('shell_initialized', self) |
---|
480 | |
---|
481 | 696 atexit.register(self.atexit_operations) |
---|
482 | |
---|
483 | 697 |
---|
484 | |
---|
485 | 698 # The trio runner is used for running Trio in the foreground thread. It |
---|
486 | |
---|
487 | |
---|
488 | |
---|
489 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/repl/interpreter.py in init_display_formatter(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>) |
---|
490 | |
---|
491 | 281 |
---|
492 | |
---|
493 | 282 sage: from sage.repl.interpreter import SageTerminalInteractiveShell |
---|
494 | |
---|
495 | 283 sage: SageTerminalInteractiveShell() # not tested |
---|
496 | |
---|
497 | 284 <sage.repl.interpreter.SageNotebookInteractiveShell object at 0x...> |
---|
498 | |
---|
499 | 285 """ |
---|
500 | |
---|
501 | 286 |
---|
502 | |
---|
503 | 287 def init_display_formatter(self): |
---|
504 | |
---|
505 | 288 """ |
---|
506 | |
---|
507 | 289 Switch to the Sage IPython commandline rich output backend |
---|
508 | |
---|
509 | 290 |
---|
510 | |
---|
511 | 291 EXAMPLES:: |
---|
512 | |
---|
513 | 292 |
---|
514 | |
---|
515 | 293 sage: from sage.repl.interpreter import SageTerminalInteractiveShell |
---|
516 | |
---|
517 | 294 sage: SageTerminalInteractiveShell().init_display_formatter() # not tested |
---|
518 | |
---|
519 | 295 """ |
---|
520 | |
---|
521 | --> 296 from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline |
---|
522 | |
---|
523 | global sage.repl.rich_output.backend_ipython = undefined |
---|
524 | |
---|
525 | BackendIPythonCommandline = undefined |
---|
526 | |
---|
527 | 297 backend = BackendIPythonCommandline() |
---|
528 | |
---|
529 | 298 backend.get_display_manager().switch_backend(backend, shell=self) |
---|
530 | |
---|
531 | 299 |
---|
532 | |
---|
533 | 300 |
---|
534 | |
---|
535 | 301 class SageTestShell(SageShellOverride, TerminalInteractiveShell): |
---|
536 | |
---|
537 | 302 """ |
---|
538 | |
---|
539 | 303 Test Shell |
---|
540 | |
---|
541 | 304 |
---|
542 | |
---|
543 | 305 Care must be taken in these doctests to quit the test shell in |
---|
544 | |
---|
545 | 306 order to switch back the rich output display backend to the |
---|
546 | |
---|
547 | 307 doctest backend. |
---|
548 | |
---|
549 | 308 |
---|
550 | |
---|
551 | 309 EXAMPLES:: |
---|
552 | |
---|
553 | 310 |
---|
554 | |
---|
555 | 311 sage: from sage.repl.interpreter import get_test_shell |
---|
556 | |
---|
557 | |
---|
558 | |
---|
559 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/repl/rich_output/__init__.py in <module> |
---|
560 | |
---|
561 | 1 # -*- encoding: utf-8 -*- |
---|
562 | |
---|
563 | 2 |
---|
564 | |
---|
565 | ----> 3 from .display_manager import get_display_manager |
---|
566 | |
---|
567 | global display_manager = undefined |
---|
568 | |
---|
569 | global get_display_manager = undefined |
---|
570 | |
---|
571 | 4 from .pretty_print import pretty_print |
---|
572 | |
---|
573 | 5 |
---|
574 | |
---|
575 | 6 |
---|
576 | |
---|
577 | |
---|
578 | |
---|
579 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/repl/rich_output/display_manager.py in <module> |
---|
580 | |
---|
581 | 24 The Sage display manager using the doctest backend |
---|
582 | |
---|
583 | 25 """ |
---|
584 | |
---|
585 | 26 |
---|
586 | |
---|
587 | 27 # **************************************************************************** |
---|
588 | |
---|
589 | 28 # Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com> |
---|
590 | |
---|
591 | 29 # |
---|
592 | |
---|
593 | 30 # Distributed under the terms of the GNU General Public License (GPL) |
---|
594 | |
---|
595 | 31 # as published by the Free Software Foundation; either version 2 of |
---|
596 | |
---|
597 | 32 # the License, or (at your option) any later version. |
---|
598 | |
---|
599 | 33 # http://www.gnu.org/licenses/ |
---|
600 | |
---|
601 | 34 # **************************************************************************** |
---|
602 | |
---|
603 | 35 |
---|
604 | |
---|
605 | 36 |
---|
606 | |
---|
607 | 37 import warnings |
---|
608 | |
---|
609 | 38 |
---|
610 | |
---|
611 | ---> 39 from sage.structure.sage_object import SageObject |
---|
612 | |
---|
613 | global sage.structure.sage_object = undefined |
---|
614 | |
---|
615 | global SageObject = undefined |
---|
616 | |
---|
617 | 40 from sage.repl.rich_output.output_basic import ( |
---|
618 | |
---|
619 | 41 OutputPlainText, OutputAsciiArt, OutputUnicodeArt, OutputLatex, |
---|
620 | |
---|
621 | 42 ) |
---|
622 | |
---|
623 | 43 from sage.repl.rich_output.preferences import DisplayPreferences |
---|
624 | |
---|
625 | 44 |
---|
626 | |
---|
627 | 45 |
---|
628 | |
---|
629 | 46 class DisplayException(Exception): |
---|
630 | |
---|
631 | 47 """ |
---|
632 | |
---|
633 | 48 Base exception for all rich output-related exceptions. |
---|
634 | |
---|
635 | 49 |
---|
636 | |
---|
637 | 50 EXAMPLES:: |
---|
638 | |
---|
639 | 51 |
---|
640 | |
---|
641 | 52 sage: from sage.repl.rich_output.display_manager import DisplayException |
---|
642 | |
---|
643 | 53 sage: raise DisplayException('foo') |
---|
644 | |
---|
645 | 54 Traceback (most recent call last): |
---|
646 | |
---|
647 | |
---|
648 | |
---|
649 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/structure/__init__.py in <module> |
---|
650 | |
---|
651 | 1 # Resolve a cyclic import |
---|
652 | |
---|
653 | ----> 2 import sage.structure.element |
---|
654 | |
---|
655 | global sage.structure.element = undefined |
---|
656 | |
---|
657 | |
---|
658 | |
---|
659 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/structure/element.pyx in init sage.structure.element (build/cythonized/sage/structure/element.c:35676)() |
---|
660 | |
---|
661 | ----> 1 # Compile this with -Os because it works around a bug with |
---|
662 | |
---|
663 | 2 # GCC-4.7.3 + Cython 0.19 on Itanium, see Trac #14452. Moreover, it |
---|
664 | |
---|
665 | 3 # actually results in faster code than -O3. |
---|
666 | |
---|
667 | 4 # |
---|
668 | |
---|
669 | 5 # distutils: extra_compile_args = -Os |
---|
670 | |
---|
671 | 6 |
---|
672 | |
---|
673 | 7 r""" |
---|
674 | |
---|
675 | 8 Elements |
---|
676 | |
---|
677 | 9 |
---|
678 | |
---|
679 | 10 AUTHORS: |
---|
680 | |
---|
681 | 11 |
---|
682 | |
---|
683 | 12 - David Harvey (2006-10-16): changed CommutativeAlgebraElement to |
---|
684 | |
---|
685 | 13 derive from CommutativeRingElement instead of AlgebraElement |
---|
686 | |
---|
687 | 14 |
---|
688 | |
---|
689 | 15 - David Harvey (2006-10-29): implementation and documentation of new |
---|
690 | |
---|
691 | 16 arithmetic architecture |
---|
692 | |
---|
693 | 17 |
---|
694 | |
---|
695 | 18 - William Stein (2006-11): arithmetic architecture -- pushing it |
---|
696 | |
---|
697 | 19 through to completion. |
---|
698 | |
---|
699 | 20 |
---|
700 | |
---|
701 | 21 - Gonzalo Tornaria (2007-06): recursive base extend for coercion -- |
---|
702 | |
---|
703 | 22 lots of tests |
---|
704 | |
---|
705 | 23 |
---|
706 | |
---|
707 | 24 - Robert Bradshaw (2007-2010): arithmetic operators and coercion |
---|
708 | |
---|
709 | 25 |
---|
710 | |
---|
711 | 26 - Maarten Derickx (2010-07): added architecture for is_square and sqrt |
---|
712 | |
---|
713 | 27 |
---|
714 | |
---|
715 | 28 - Jeroen Demeyer (2016-08): moved all coercion to the base class |
---|
716 | |
---|
717 | 29 :class:`Element`, see :trac:`20767` |
---|
718 | |
---|
719 | 30 |
---|
720 | |
---|
721 | 31 The Abstract Element Class Hierarchy |
---|
722 | |
---|
723 | |
---|
724 | |
---|
725 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/structure/sage_object.pyx in init sage.structure.sage_object (build/cythonized/sage/structure/sage_object.c:11967)() |
---|
726 | |
---|
727 | 1 # -*- encoding: utf-8 -*- |
---|
728 | |
---|
729 | 2 r""" |
---|
730 | |
---|
731 | 3 Abstract base class for Sage objects |
---|
732 | |
---|
733 | 4 """ |
---|
734 | |
---|
735 | 5 |
---|
736 | |
---|
737 | ----> 6 from sage.misc.persist import (_base_dumps, _base_save, |
---|
738 | |
---|
739 | global sage.misc.persist = undefined |
---|
740 | |
---|
741 | global _base_dumps = undefined |
---|
742 | |
---|
743 | global _base_save = undefined |
---|
744 | |
---|
745 | global register_unpickle_override = undefined |
---|
746 | |
---|
747 | global make_None = undefined |
---|
748 | |
---|
749 | 7 register_unpickle_override, make_None) |
---|
750 | |
---|
751 | 8 |
---|
752 | |
---|
753 | 9 from sage.misc.lazy_import import LazyImport |
---|
754 | |
---|
755 | 10 |
---|
756 | |
---|
757 | 11 # NOTE: These imports are just for backwards-compatibility |
---|
758 | |
---|
759 | 12 loads = LazyImport('sage.misc.persist', 'loads', deprecation=25153) |
---|
760 | |
---|
761 | 13 dumps = LazyImport('sage.misc.persist', 'dumps', deprecation=25153) |
---|
762 | |
---|
763 | 14 save = LazyImport('sage.misc.persist', 'save', deprecation=25153) |
---|
764 | |
---|
765 | 15 load = LazyImport('sage.misc.persist', 'load', deprecation=25153) |
---|
766 | |
---|
767 | 16 unpickle_all = LazyImport('sage.misc.persist', 'unpickle_all', |
---|
768 | |
---|
769 | 17 deprecation=25153) |
---|
770 | |
---|
771 | 18 unpickle_global = LazyImport('sage.misc.persist', 'unpickle_global', |
---|
772 | |
---|
773 | 19 deprecation=25153) |
---|
774 | |
---|
775 | 20 unpickle_override = LazyImport('sage.misc.persist', 'unpickle_override', |
---|
776 | |
---|
777 | 21 deprecation=25153) |
---|
778 | |
---|
779 | 22 |
---|
780 | |
---|
781 | 23 |
---|
782 | |
---|
783 | 24 # Generators is no longer used (#21382) |
---|
784 | |
---|
785 | 25 register_unpickle_override('sage.structure.generators', 'make_list_gens', |
---|
786 | |
---|
787 | 26 make_None) |
---|
788 | |
---|
789 | 27 |
---|
790 | |
---|
791 | 28 |
---|
792 | |
---|
793 | 29 __all__ = ['SageObject'] |
---|
794 | |
---|
795 | 30 |
---|
796 | |
---|
797 | 31 |
---|
798 | |
---|
799 | |
---|
800 | |
---|
801 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/site-packages/sage/misc/persist.pyx in init sage.misc.persist (build/cythonized/sage/misc/persist.c:11955)() |
---|
802 | |
---|
803 | 25 correctly or work correctly. |
---|
804 | |
---|
805 | 26 |
---|
806 | |
---|
807 | 27 - Objects are zlib compressed for space efficiency. |
---|
808 | |
---|
809 | 28 """ |
---|
810 | |
---|
811 | 29 |
---|
812 | |
---|
813 | 30 import io |
---|
814 | |
---|
815 | 31 import os |
---|
816 | |
---|
817 | 32 import pickle |
---|
818 | |
---|
819 | 33 import sys |
---|
820 | |
---|
821 | 34 |
---|
822 | |
---|
823 | 35 from textwrap import dedent |
---|
824 | |
---|
825 | 36 |
---|
826 | |
---|
827 | 37 # change to import zlib to use zlib instead; but this |
---|
828 | |
---|
829 | 38 # slows down loading any data stored in the other format |
---|
830 | |
---|
831 | 39 import zlib; comp = zlib |
---|
832 | |
---|
833 | ---> 40 import bz2; comp_other = bz2 |
---|
834 | |
---|
835 | global bz2 = undefined |
---|
836 | |
---|
837 | global comp_other = undefined |
---|
838 | |
---|
839 | 41 |
---|
840 | |
---|
841 | 42 from .misc import SAGE_DB |
---|
842 | |
---|
843 | 43 from .sage_unittest import TestSuite |
---|
844 | |
---|
845 | 44 |
---|
846 | |
---|
847 | 45 |
---|
848 | |
---|
849 | 46 cdef _normalize_filename(s): |
---|
850 | |
---|
851 | 47 """ |
---|
852 | |
---|
853 | 48 Append the .sobj extension to a filename if it doesn't already have it. |
---|
854 | |
---|
855 | 49 """ |
---|
856 | |
---|
857 | 50 if s[-5:] != '.sobj': |
---|
858 | |
---|
859 | 51 return s + '.sobj' |
---|
860 | |
---|
861 | 52 |
---|
862 | |
---|
863 | 53 return s |
---|
864 | |
---|
865 | 54 |
---|
866 | |
---|
867 | 55 |
---|
868 | |
---|
869 | |
---|
870 | |
---|
871 | ~/sagefiles/sage-9.2.rc0/local/lib/python3.8/bz2.py in <module> |
---|
872 | |
---|
873 | 4 (de)compression, and functions for one-shot (de)compression. |
---|
874 | |
---|
875 | 5 """ |
---|
876 | |
---|
877 | 6 |
---|
878 | |
---|
879 | 7 __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", |
---|
880 | |
---|
881 | 8 "open", "compress", "decompress"] |
---|
882 | |
---|
883 | 9 |
---|
884 | |
---|
885 | 10 __author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>" |
---|
886 | |
---|
887 | 11 |
---|
888 | |
---|
889 | 12 from builtins import open as _builtin_open |
---|
890 | |
---|
891 | 13 import io |
---|
892 | |
---|
893 | 14 import os |
---|
894 | |
---|
895 | 15 import warnings |
---|
896 | |
---|
897 | 16 import _compression |
---|
898 | |
---|
899 | 17 from threading import RLock |
---|
900 | |
---|
901 | 18 |
---|
902 | |
---|
903 | ---> 19 from _bz2 import BZ2Compressor, BZ2Decompressor |
---|
904 | |
---|
905 | global _bz2 = undefined |
---|
906 | |
---|
907 | global BZ2Compressor = undefined |
---|
908 | |
---|
909 | global BZ2Decompressor = undefined |
---|
910 | |
---|
911 | 20 |
---|
912 | |
---|
913 | 21 |
---|
914 | |
---|
915 | 22 _MODE_CLOSED = 0 |
---|
916 | |
---|
917 | 23 _MODE_READ = 1 |
---|
918 | |
---|
919 | 24 # Value 2 no longer used |
---|
920 | |
---|
921 | 25 _MODE_WRITE = 3 |
---|
922 | |
---|
923 | 26 |
---|
924 | |
---|
925 | 27 _sentinel = object() |
---|
926 | |
---|
927 | 28 |
---|
928 | |
---|
929 | 29 |
---|
930 | |
---|
931 | 30 class BZ2File(_compression.BaseStream): |
---|
932 | |
---|
933 | 31 |
---|
934 | |
---|
935 | 32 """A file object providing transparent bzip2 (de)compression. |
---|
936 | |
---|
937 | 33 |
---|
938 | |
---|
939 | 34 A BZ2File can act as a wrapper for an existing file object, or refer |
---|
940 | |
---|
941 | |
---|
942 | |
---|
943 | ModuleNotFoundError: No module named '_bz2' |
---|
944 | |
---|
945 | |
---|
946 | |
---|
947 | ********************************************************************** |
---|
948 | |
---|
949 | |
---|
950 | |
---|
951 | Oops, Sage crashed. We do our best to make it stable, but... |
---|
952 | |
---|
953 | |
---|
954 | |
---|
955 | A crash report was automatically generated with the following information: |
---|
956 | |
---|
957 | - A verbatim copy of the crash traceback. |
---|
958 | |
---|
959 | - A copy of your input history during this session. |
---|
960 | |
---|
961 | - Data on your current Sage configuration. |
---|
962 | |
---|
963 | |
---|
964 | |
---|
965 | It was left in the file named: |
---|
966 | |
---|
967 | '/Users/wdj/.sage/ipython-5.0.0/Sage_crash_report.txt' |
---|
968 | |
---|
969 | If you can email this file to the developers, the information in it will help |
---|
970 | |
---|
971 | them in understanding and correcting the problem. |
---|
972 | |
---|
973 | |
---|
974 | |
---|
975 | You can mail it to: sage-support at sage-support@googlegroups.com |
---|
976 | |
---|
977 | with the subject 'Sage Crash Report'. |
---|
978 | |
---|
979 | |
---|
980 | |
---|
981 | If you want to do it now, the following command will work (under Unix): |
---|
982 | |
---|
983 | mail -s 'Sage Crash Report' sage-support@googlegroups.com < /Users/wdj/.sage/ipython-5.0.0/Sage_crash_report.txt |
---|
984 | |
---|
985 | |
---|
986 | |
---|
987 | In your email, please also include information about: |
---|
988 | |
---|
989 | - The operating system under which the crash happened: Linux, macOS, Windows, |
---|
990 | |
---|
991 | other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2, |
---|
992 | |
---|
993 | Windows 10 Pro), and whether it is 32-bit or 64-bit; |
---|
994 | |
---|
995 | - How Sage was installed: using pip or conda, from GitHub, as part of |
---|
996 | |
---|
997 | a Docker container, or other, providing more detail if possible; |
---|
998 | |
---|
999 | - How to reproduce the crash: what exact sequence of instructions can one |
---|
1000 | |
---|
1001 | input to get the same crash? Ideally, find a minimal yet complete sequence |
---|
1002 | |
---|
1003 | of instructions that yields the crash. |
---|
1004 | |
---|
1005 | |
---|
1006 | |
---|
1007 | To ensure accurate tracking of this issue, please file a report about it at: |
---|
1008 | |
---|
1009 | http://trac.sagemath.org |
---|
1010 | |
---|
1011 | |
---|