Advertisement
JoelSjogren

Untitled

Aug 28th, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.52 KB | None | 0 0
  1. box% mv .sage .sage.old.2
  2. box% sage
  3. ┌────────────────────────────────────────────────────────────────────┐
  4. │ SageMath version 9.1, Release Date: 2020-05-20 │
  5. │ Using Python 3.8.5. Type "help()" for help. │
  6. └────────────────────────────────────────────────────────────────────┘
  7. sage:
  8. ---------------------------------------------------------------------------
  9. ---------------------------------------------------------------------------
  10. EOFError Python 3.8.5: /bin/python3
  11. Fri Aug 28 10:44:30 2020
  12. A problem occurred executing Python code. Here is the sequence of function
  13. calls leading up to the error, with the most recent (innermost) call last.
  14. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in _run_async2()
  15. 763 try:
  16. --> 764 result = await _run_async()
  17. result = undefined
  18. global _run_async = undefined
  19. 765 finally:
  20.  
  21. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in _run_async()
  22. 704 try:
  23. --> 705 result = await f
  24. result = undefined
  25. global f = undefined
  26. 706 finally:
  27.  
  28. EOFError:
  29.  
  30. During handling of the above exception, another exception occurred:
  31.  
  32. ---------------------------------------------------------------------------
  33. AttributeError Python 3.8.5: /bin/python3
  34. Fri Aug 28 10:44:30 2020
  35. A problem occurred executing Python code. Here is the sequence of function
  36. calls leading up to the error, with the most recent (innermost) call last.
  37. /usr/bin/sage-ipython in <module>
  38. 1 #!/usr/bin/env sage-python
  39. 2 # -*- coding: utf-8 -*-
  40. 3 """
  41. 4 Sage IPython startup script.
  42. 5 """
  43. 6
  44. 7 # Display startup banner. Do this before anything else to give the user
  45. 8 # early feedback that Sage is starting.
  46. 9 from sage.misc.banner import banner
  47. 10 banner()
  48. 11
  49. 12 from sage.repl.interpreter import SageTerminalApp
  50. 13
  51. 14 app = SageTerminalApp.instance()
  52. 15 app.initialize()
  53. ---> 16 app.start()
  54. global app.start = <bound method TerminalIPythonApp.start of <sage.repl.interpreter.SageTerminalApp object at 0x7fd24d808430>>
  55.  
  56. /usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py in start(self=<sage.repl.interpreter.SageTerminalApp object>)
  57. 341 if self.log_level <= logging.INFO: print()
  58. 342
  59. 343 def _pylab_changed(self, name, old, new):
  60. 344 """Replace --pylab='inline' with --pylab='auto'"""
  61. 345 if new == 'inline':
  62. 346 warnings.warn("'inline' not available as pylab backend, "
  63. 347 "using 'auto' instead.")
  64. 348 self.pylab = 'auto'
  65. 349
  66. 350 def start(self):
  67. 351 if self.subapp is not None:
  68. 352 return self.subapp.start()
  69. 353 # perform any prexec steps:
  70. 354 if self.interact:
  71. 355 self.log.debug("Starting IPython's mainloop...")
  72. --> 356 self.shell.mainloop()
  73. self.shell.mainloop = <bound method TerminalInteractiveShell.mainloop of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7fd24bc6bd90>>
  74. 357 else:
  75. 358 self.log.debug("IPython not interactive...")
  76. 359 if not self.shell.last_execution_succeeded:
  77. 360 sys.exit(1)
  78. 361
  79. 362 def load_default_config(ipython_dir=None):
  80. 363 """Load the default config file from the default ipython_dir.
  81. 364
  82. 365 This is useful for embedded shells.
  83. 366 """
  84. 367 if ipython_dir is None:
  85. 368 ipython_dir = get_ipython_dir()
  86. 369
  87. 370 profile_dir = os.path.join(ipython_dir, 'profile_default')
  88. 371 app = TerminalIPythonApp()
  89.  
  90. /usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in mainloop(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>, display_banner=<object object>)
  91. 549 if (not self.confirm_exit) \
  92. 550 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
  93. 551 self.ask_exit()
  94. 552
  95. 553 else:
  96. 554 if code:
  97. 555 self.run_cell(code, store_history=True)
  98. 556
  99. 557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
  100. 558 # An extra layer of protection in case someone mashing Ctrl-C breaks
  101. 559 # out of our internal code.
  102. 560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
  103. 561 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
  104. 562 while True:
  105. 563 try:
  106. --> 564 self.interact()
  107. self.interact = <bound method TerminalInteractiveShell.interact of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7fd24bc6bd90>>
  108. 565 break
  109. 566 except KeyboardInterrupt as e:
  110. 567 print("\n%s escaped interact()\n" % type(e).__name__)
  111. 568 finally:
  112. 569 # An interrupt during the eventloop will mess up the
  113. 570 # internal state of the prompt_toolkit library.
  114. 571 # Stopping the eventloop fixes this, see
  115. 572 # https://github.com/ipython/ipython/pull/9867
  116. 573 if hasattr(self, '_eventloop'):
  117. 574 self._eventloop.stop()
  118. 575
  119. 576 self.restore_term_title()
  120. 577
  121. 578
  122. 579 _inputhook = None
  123.  
  124. /usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in interact(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>, display_banner=<object object>)
  125. 532 def ask_exit(self):
  126. 533 self.keep_running = False
  127. 534
  128. 535 rl_next_input = None
  129. 536
  130. 537 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
  131. 538
  132. 539 if display_banner is not DISPLAY_BANNER_DEPRECATED:
  133. 540 warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
  134. 541
  135. 542 self.keep_running = True
  136. 543 while self.keep_running:
  137. 544 print(self.separate_in, end='')
  138. 545
  139. 546 try:
  140. --> 547 code = self.prompt_for_code()
  141. code = undefined
  142. self.prompt_for_code = <bound method TerminalInteractiveShell.prompt_for_code of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7fd24bc6bd90>>
  143. 548 except EOFError:
  144. 549 if (not self.confirm_exit) \
  145. 550 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
  146. 551 self.ask_exit()
  147. 552
  148. 553 else:
  149. 554 if code:
  150. 555 self.run_cell(code, store_history=True)
  151. 556
  152. 557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
  153. 558 # An extra layer of protection in case someone mashing Ctrl-C breaks
  154. 559 # out of our internal code.
  155. 560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
  156. 561 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
  157. 562 while True:
  158.  
  159. /usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>)
  160. 458 # In order to make sure that asyncio code written in the
  161. 459 # interactive shell doesn't interfere with the prompt, we run the
  162. 460 # prompt in a different event loop.
  163. 461 # If we don't do this, people could spawn coroutine with a
  164. 462 # while/true inside which will freeze the prompt.
  165. 463
  166. 464 try:
  167. 465 old_loop = asyncio.get_event_loop()
  168. 466 except RuntimeError:
  169. 467 # This happens when the user used `asyncio.run()`.
  170. 468 old_loop = None
  171. 469
  172. 470 asyncio.set_event_loop(self.pt_loop)
  173. 471 try:
  174. 472 with patch_stdout(raw=True):
  175. --> 473 text = self.pt_app.prompt(
  176. text = undefined
  177. self.pt_app.prompt = <bound method PromptSession.prompt of <prompt_toolkit.shortcuts.prompt.PromptSession object at 0x7fd249f5f550>>
  178. default = ''
  179. self._extra_prompt_options = <bound method TerminalInteractiveShell._extra_prompt_options of <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7fd24bc6bd90>>
  180. 474 default=default,
  181. 475 **self._extra_prompt_options())
  182. 476 finally:
  183. 477 # Restore the original event loop.
  184. 478 asyncio.set_event_loop(old_loop)
  185. 479
  186. 480 return text
  187. 481
  188. 482 def enable_win_unicode_console(self):
  189. 483 # Since IPython 7.10 doesn't support python < 3.6 and PEP 528, Python uses the unicode APIs for the Windows
  190. 484 # console by default, so WUC shouldn't be needed.
  191. 485 from warnings import warn
  192. 486 warn("`enable_win_unicode_console` is deprecated since IPython 7.10, does not do anything and will be removed in the future",
  193. 487 DeprecationWarning,
  194. 488 stacklevel=2)
  195.  
  196. /usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py in prompt(self=<prompt_toolkit.shortcuts.prompt.PromptSession object>, message=<prompt_toolkit.formatted_text.pygments.PygmentsTokens object>, editing_mode=None, refresh_interval=None, vi_mode=None, lexer=<IPython.terminal.ptutils.IPythonPTLexer object>, completer=None, complete_in_thread=False, is_password=None, key_bindings=None, bottom_toolbar=None, style=None, color_depth=None, include_default_pygments_style=None, style_transformation=None, swap_light_and_dark_colors=None, rprompt=None, multiline=True, prompt_continuation=<function TerminalInteractiveShell._extra_prompt_options.<locals>.<lambda>>, wrap_lines=None, enable_history_search=None, search_ignore_case=None, complete_while_typing=None, validate_while_typing=None, complete_style=<CompleteStyle.MULTI_COLUMN: 'MULTI_COLUMN'>, auto_suggest=None, validator=None, clipboard=None, mouse_support=None, input_processors=[ConditionalProcessor(processor=<prompt_toolkit.l...pt_options.<locals>.<lambda> at 0x7fcffb06e040>))], reserve_space_for_menu=6, enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None, tempfile_suffix=None, tempfile=None, default='', accept_default=False, pre_run=None, set_exception_handler=True)
  197. 979 self.tempfile_suffix = tempfile_suffix
  198. 980 if tempfile is not None:
  199. 981 self.tempfile = tempfile
  200. 982
  201. 983 self._add_pre_run_callables(pre_run, accept_default)
  202. 984 self.default_buffer.reset(
  203. 985 default if isinstance(default, Document) else Document(default)
  204. 986 )
  205. 987 self.app.refresh_interval = self.refresh_interval # This is not reactive.
  206. 988
  207. 989 # If we are using the default output, and have a dumb terminal. Use the
  208. 990 # dumb prompt.
  209. 991 if self._output is None and is_dumb_terminal():
  210. 992 return get_event_loop().run_until_complete(self._dumb_prompt(self.message))
  211. 993
  212. --> 994 return self.app.run(set_exception_handler=set_exception_handler)
  213. self.app.run = <bound method Application.run of <prompt_toolkit.application.application.Application object at 0x7fd249f923d0>>
  214. set_exception_handler = True
  215. 995
  216. 996 async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:
  217. 997 """
  218. 998 Prompt function for dumb terminals.
  219. 999
  220. 1000 Dumb terminals have minimum rendering capabilities. We can only print
  221. 1001 text to the screen. We can't use colors, and we can't do cursor
  222. 1002 movements. The Emacs inferior shell is an example of a dumb terminal.
  223. 1003
  224. 1004 We will show the prompt, and wait for the input. We still handle arrow
  225. 1005 keys, and all custom key bindings, but we don't really render the
  226. 1006 cursor movements. Instead we only print the typed character that's
  227. 1007 right before the cursor.
  228. 1008 """
  229. 1009 # Send prompt to output.
  230.  
  231. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in run(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True)
  232. 800 """
  233. 801 # We don't create a new event loop by default, because we want to be
  234. 802 # sure that when this is called multiple times, each call of `run()`
  235. 803 # goes through the same event loop. This way, users can schedule
  236. 804 # background-tasks that keep running across multiple prompts.
  237. 805 try:
  238. 806 loop = get_event_loop()
  239. 807 except RuntimeError:
  240. 808 # Possibly we are not running in the main thread, where no event
  241. 809 # loop is set by default. Or somebody called `asyncio.run()`
  242. 810 # before, which closes the existing event loop. We can create a new
  243. 811 # loop.
  244. 812 loop = new_event_loop()
  245. 813 set_event_loop(loop)
  246. 814
  247. --> 815 return loop.run_until_complete(
  248. loop.run_until_complete = <bound method BaseEventLoop.run_until_complete of <_UnixSelectorEventLoop running=False closed=False debug=False>>
  249. self.run_async = <bound method Application.run_async of <prompt_toolkit.application.application.Application object at 0x7fd249f923d0>>
  250. pre_run = None
  251. set_exception_handler = True
  252. 816 self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
  253. 817 )
  254. 818
  255. 819 def _handle_exception(
  256. 820 self, loop: AbstractEventLoop, context: Dict[str, Any]
  257. 821 ) -> None:
  258. 822 """
  259. 823 Handler for event loop exceptions.
  260. 824 This will print the exception, using run_in_terminal.
  261. 825 """
  262. 826 # For Python 2: we have to get traceback at this point, because
  263. 827 # we're still in the 'except:' block of the event loop where the
  264. 828 # traceback is still available. Moving this code in the
  265. 829 # 'print_exception' coroutine will loose the exception.
  266. 830 tb = get_traceback_from_context(context)
  267.  
  268. /usr/lib/python3.8/asyncio/base_events.py in run_until_complete(self=<_UnixSelectorEventLoop running=False closed=False debug=False>, future=<Task finished name='Task-1' coro=<Application.r..."'KeyError' object has no attribute 'tb_frame'")>)
  269. 601 future.add_done_callback(_run_until_complete_cb)
  270. 602 try:
  271. 603 self.run_forever()
  272. 604 except:
  273. 605 if new_task and future.done() and not future.cancelled():
  274. 606 # The coroutine raised a BaseException. Consume the exception
  275. 607 # to not log a warning, the caller doesn't have access to the
  276. 608 # local task.
  277. 609 future.exception()
  278. 610 raise
  279. 611 finally:
  280. 612 future.remove_done_callback(_run_until_complete_cb)
  281. 613 if not future.done():
  282. 614 raise RuntimeError('Event loop stopped before Future completed.')
  283. 615
  284. --> 616 return future.result()
  285. future.result = <built-in method result of _asyncio.Task object at 0x7fcffb0d6360>
  286. 617
  287. 618 def stop(self):
  288. 619 """Stop running the event loop.
  289. 620
  290. 621 Every callback already scheduled will still run. This simply informs
  291. 622 run_forever to stop looping after a complete iteration.
  292. 623 """
  293. 624 self._stopping = True
  294. 625
  295. 626 def close(self):
  296. 627 """Close the event loop.
  297. 628
  298. 629 This clears the queues and shuts down the executor,
  299. 630 but does not wait for the executor to finish.
  300. 631
  301.  
  302. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in run_async(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True)
  303. 767 # go in the finally! If `_run_async` raises
  304. 768 # `KeyboardInterrupt`, we still want to wait for the
  305. 769 # background tasks.
  306. 770 await self.cancel_and_wait_for_background_tasks()
  307. 771
  308. 772 # Set the `_is_running` flag to `False`. Normally this
  309. 773 # happened already in the finally block in `run_async`
  310. 774 # above, but in case of exceptions, that's not always the
  311. 775 # case.
  312. 776 self._is_running = False
  313. 777 return result
  314. 778 finally:
  315. 779 if set_exception_handler:
  316. 780 loop.set_exception_handler(previous_exc_handler)
  317. 781
  318. --> 782 return await _run_async2()
  319. _run_async2 = <function Application.run_async.<locals>._run_async2 at 0x7fcffb06e160>
  320. 783
  321. 784 def run(
  322. 785 self,
  323. 786 pre_run: Optional[Callable[[], None]] = None,
  324. 787 set_exception_handler: bool = True,
  325. 788 ) -> _AppResult:
  326. 789 """
  327. 790 A blocking 'run' call that waits until the UI is finished.
  328. 791
  329. 792 This will start the current asyncio event loop. If no loop is set for
  330. 793 the current thread, then it will create a new loop.
  331. 794
  332. 795 :param pre_run: Optional callable, which is called right after the
  333. 796 "reset" of the application.
  334. 797 :param set_exception_handler: When set, in case of an exception, go out
  335.  
  336. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in _run_async2()
  337. 755
  338. 756 loop = get_event_loop()
  339. 757 if set_exception_handler:
  340. 758 previous_exc_handler = loop.get_exception_handler()
  341. 759 loop.set_exception_handler(self._handle_exception)
  342. 760
  343. 761 try:
  344. 762 with set_app(self):
  345. 763 try:
  346. 764 result = await _run_async()
  347. 765 finally:
  348. 766 # Wait for the background tasks to be done. This needs to
  349. 767 # go in the finally! If `_run_async` raises
  350. 768 # `KeyboardInterrupt`, we still want to wait for the
  351. 769 # background tasks.
  352. --> 770 await self.cancel_and_wait_for_background_tasks()
  353. global self.cancel_and_wait_for_background_tasks = undefined
  354. 771
  355. 772 # Set the `_is_running` flag to `False`. Normally this
  356. 773 # happened already in the finally block in `run_async`
  357. 774 # above, but in case of exceptions, that's not always the
  358. 775 # case.
  359. 776 self._is_running = False
  360. 777 return result
  361. 778 finally:
  362. 779 if set_exception_handler:
  363. 780 loop.set_exception_handler(previous_exc_handler)
  364. 781
  365. 782 return await _run_async2()
  366. 783
  367. 784 def run(
  368. 785 self,
  369.  
  370. /usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py in cancel_and_wait_for_background_tasks(self=<prompt_toolkit.application.application.Application object>)
  371. 856
  372. 857 async def cancel_and_wait_for_background_tasks(self) -> None:
  373. 858 """
  374. 859 Cancel all background tasks, and wait for the cancellation to be done.
  375. 860 If any of the background tasks raised an exception, this will also
  376. 861 propagate the exception.
  377. 862
  378. 863 (If we had nurseries like Trio, this would be the `__aexit__` of a
  379. 864 nursery.)
  380. 865 """
  381. 866 for task in self.background_tasks:
  382. 867 task.cancel()
  383. 868
  384. 869 for task in self.background_tasks:
  385. 870 try:
  386. --> 871 await task
  387. task = <Task finished name='Task-19' coro=<Buffer._create_completer_coroutine.<locals>.async_completer() done, defined at /usr/lib/python3.8/site-packages/prompt_toolkit/buffer.py:1841> exception=AttributeError("'KeyError' object has no attribute 'tb_frame'")>
  388. 872 except CancelledError:
  389. 873 pass
  390. 874
  391. 875 def cpr_not_supported_callback(self) -> None:
  392. 876 """
  393. 877 Called when we don't receive the cursor position response in time.
  394. 878 """
  395. 879 if not self.input.responds_to_cpr:
  396. 880 return # We know about this already.
  397. 881
  398. 882 def in_terminal() -> None:
  399. 883 self.output.write(
  400. 884 "WARNING: your terminal doesn't support cursor position requests (CPR).\r\n"
  401. 885 )
  402. 886 self.output.flush()
  403.  
  404. /usr/lib/python3.8/site-packages/prompt_toolkit/buffer.py in new_coroutine(*a=(), **kw={'complete_event': CompleteEvent(text_inserted=False, completion_requested=True), 'insert_common_part': True, 'select_first': False, 'select_last': False})
  405. 1839 running = False
  406. 1840
  407. 1841 @wraps(coroutine)
  408. 1842 async def new_coroutine(*a: Any, **kw: Any) -> Any:
  409. 1843 nonlocal running
  410. 1844
  411. 1845 # Don't start a new function, if the previous is still in progress.
  412. 1846 if running:
  413. 1847 return
  414. 1848
  415. 1849 running = True
  416. 1850
  417. 1851 try:
  418. 1852 while True:
  419. 1853 try:
  420. -> 1854 await coroutine(*a, **kw)
  421. global coroutine = undefined
  422. a = ()
  423. kw = {'select_first': False, 'select_last': False, 'insert_common_part': True, 'complete_event': CompleteEvent(text_inserted=False, completion_requested=True)}
  424. 1855 except _Retry:
  425. 1856 continue
  426. 1857 else:
  427. 1858 return None
  428. 1859 finally:
  429. 1860 running = False
  430. 1861
  431. 1862 return cast(_T, new_coroutine)
  432. 1863
  433. 1864
  434. 1865 class _Retry(Exception):
  435. 1866 " Retry in `_only_one_at_a_time`. "
  436. 1867
  437. 1868
  438. 1869 def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None:
  439.  
  440. /usr/lib/python3.8/site-packages/prompt_toolkit/buffer.py in async_completer(select_first=False, select_last=False, insert_common_part=True, complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
  441. 1668 complete_event = complete_event or CompleteEvent(text_inserted=True)
  442. 1669
  443. 1670 # Don't complete when we already have completions.
  444. 1671 if self.complete_state or not self.completer:
  445. 1672 return
  446. 1673
  447. 1674 # Create an empty CompletionState.
  448. 1675 complete_state = CompletionState(original_document=self.document)
  449. 1676 self.complete_state = complete_state
  450. 1677
  451. 1678 def proceed() -> bool:
  452. 1679 """ Keep retrieving completions. Input text has not yet changed
  453. 1680 while generating completions. """
  454. 1681 return self.complete_state == complete_state
  455. 1682
  456. -> 1683 async for completion in self.completer.get_completions_async(
  457. completion = undefined
  458. global self.completer.get_completions_async = undefined
  459. document = Document('plo', 3)
  460. complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
  461. 1684 document, complete_event
  462. 1685 ):
  463. 1686 complete_state.completions.append(completion)
  464. 1687 self.on_completions_changed.fire()
  465. 1688
  466. 1689 # If the input text changes, abort.
  467. 1690 if not proceed():
  468. 1691 break
  469. 1692
  470. 1693 completions = complete_state.completions
  471. 1694
  472. 1695 # When there is only one completion, which has nothing to add, ignore it.
  473. 1696 if len(completions) == 1 and completion_does_nothing(
  474. 1697 document, completions[0]
  475. 1698 ):
  476.  
  477. /usr/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=DynamicCompleter(<function PromptSession._create...ils.IPythonPTCompleter object at 0x7fd24a1321c0>), document=Document('plo', 3), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
  478. 254
  479. 255 def __init__(self, get_completer: Callable[[], Optional[Completer]]) -> None:
  480. 256 self.get_completer = get_completer
  481. 257
  482. 258 def get_completions(
  483. 259 self, document: Document, complete_event: CompleteEvent
  484. 260 ) -> Iterable[Completion]:
  485. 261 completer = self.get_completer() or DummyCompleter()
  486. 262 return completer.get_completions(document, complete_event)
  487. 263
  488. 264 async def get_completions_async(
  489. 265 self, document: Document, complete_event: CompleteEvent
  490. 266 ) -> AsyncGenerator[Completion, None]:
  491. 267 completer = self.get_completer() or DummyCompleter()
  492. 268
  493. --> 269 async for completion in completer.get_completions_async(
  494. completion = undefined
  495. completer.get_completions_async = <bound method Completer.get_completions_async of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x7fd24a1321c0>>
  496. document = Document('plo', 3)
  497. complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
  498. 270 document, complete_event
  499. 271 ):
  500. 272 yield completion
  501. 273
  502. 274 def __repr__(self) -> str:
  503. 275 return "DynamicCompleter(%r -> %r)" % (self.get_completer, self.get_completer())
  504. 276
  505. 277
  506. 278 class _MergedCompleter(Completer):
  507. 279 """
  508. 280 Combine several completers into one.
  509. 281 """
  510. 282
  511. 283 def __init__(self, completers: Sequence[Completer]) -> None:
  512. 284 self.completers = completers
  513.  
  514. /usr/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('plo', 3), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
  515. 181 :param document: :class:`~prompt_toolkit.document.Document` instance.
  516. 182 :param complete_event: :class:`.CompleteEvent` instance.
  517. 183 """
  518. 184 while False:
  519. 185 yield
  520. 186
  521. 187 async def get_completions_async(
  522. 188 self, document: Document, complete_event: CompleteEvent
  523. 189 ) -> AsyncGenerator[Completion, None]:
  524. 190 """
  525. 191 Asynchronous generator for completions. (Probably, you won't have to
  526. 192 override this.)
  527. 193
  528. 194 Asynchronous generator of :class:`.Completion` objects.
  529. 195 """
  530. --> 196 for item in self.get_completions(document, complete_event):
  531. item = undefined
  532. self.get_completions = <bound method IPythonPTCompleter.get_completions of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x7fd24a1321c0>>
  533. document = Document('plo', 3)
  534. complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
  535. 197 yield item
  536. 198
  537. 199
  538. 200 class ThreadedCompleter(Completer):
  539. 201 """
  540. 202 Wrapper that runs the `get_completions` generator in a thread.
  541. 203
  542. 204 (Use this to prevent the user interface from becoming unresponsive if the
  543. 205 generation of completions takes too much time.)
  544. 206
  545. 207 The completions will be displayed as soon as they are produced. The user
  546. 208 can already select a completion, even if not all completions are displayed.
  547. 209 """
  548. 210
  549. 211 def __init__(self, completer: Completer) -> None:
  550.  
  551. /usr/lib/python3.8/site-packages/IPython/terminal/ptutils.py in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('plo', 3), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
  552. 101 return
  553. 102 # Some bits of our completion system may print stuff (e.g. if a module
  554. 103 # is imported). This context manager ensures that doesn't interfere with
  555. 104 # the prompt.
  556. 105
  557. 106 with patch_stdout(), provisionalcompleter():
  558. 107 body = document.text
  559. 108 cursor_row = document.cursor_position_row
  560. 109 cursor_col = document.cursor_position_col
  561. 110 cursor_position = document.cursor_position
  562. 111 offset = cursor_to_position(body, cursor_row, cursor_col)
  563. 112 try:
  564. 113 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
  565. 114 except Exception as e:
  566. 115 from traceback import print_tb
  567. --> 116 print_tb(e)
  568. print_tb = <function print_tb at 0x7fd24d4804c0>
  569. e = undefined
  570. 117
  571. 118 @staticmethod
  572. 119 def _get_completions(body, offset, cursor_position, ipyc):
  573. 120 """
  574. 121 Private equivalent of get_completions() use only for unit_testing.
  575. 122 """
  576. 123 debug = getattr(ipyc, 'debug', False)
  577. 124 completions = _deduplicate_completions(
  578. 125 body, ipyc.completions(body, offset))
  579. 126 for c in completions:
  580. 127 if not c.text:
  581. 128 # Guard against completion machinery giving us an empty string.
  582. 129 continue
  583. 130 text = unicodedata.normalize('NFC', c.text)
  584. 131 # When the first character of the completion has a zero length,
  585.  
  586. /usr/lib/python3.8/traceback.py in print_tb(tb=KeyError('/usr/lib/python3.8/site-packages/sage/plot/plot.py'), limit=None, file=None)
  587. 38 """
  588. 39 return StackSummary.from_list(extracted_list).format()
  589. 40
  590. 41 #
  591. 42 # Printing and Extracting Tracebacks.
  592. 43 #
  593. 44
  594. 45 def print_tb(tb, limit=None, file=None):
  595. 46 """Print up to 'limit' stack trace entries from the traceback 'tb'.
  596. 47
  597. 48 If 'limit' is omitted or None, all entries are printed. If 'file'
  598. 49 is omitted or None, the output goes to sys.stderr; otherwise
  599. 50 'file' should be an open file or file-like object with a write()
  600. 51 method.
  601. 52 """
  602. ---> 53 print_list(extract_tb(tb, limit=limit), file=file)
  603. global print_list = <function print_list at 0x7fd24d4803a0>
  604. global extract_tb = <function extract_tb at 0x7fd24d4805e0>
  605. tb = KeyError('/usr/lib/python3.8/site-packages/sage/plot/plot.py')
  606. limit = None
  607. file = None
  608. 54
  609. 55 def format_tb(tb, limit=None):
  610. 56 """A shorthand for 'format_list(extract_tb(tb, limit))'."""
  611. 57 return extract_tb(tb, limit=limit).format()
  612. 58
  613. 59 def extract_tb(tb, limit=None):
  614. 60 """
  615. 61 Return a StackSummary object representing a list of
  616. 62 pre-processed entries from traceback.
  617. 63
  618. 64 This is useful for alternate formatting of stack traces. If
  619. 65 'limit' is omitted or None, all entries are extracted. A
  620. 66 pre-processed stack trace entry is a FrameSummary object
  621. 67 containing attributes filename, lineno, name, and line
  622. 68 representing the information that is usually printed for a stack
  623.  
  624. /usr/lib/python3.8/traceback.py in extract_tb(tb=KeyError('/usr/lib/python3.8/site-packages/sage/plot/plot.py'), limit=None)
  625. 57 return extract_tb(tb, limit=limit).format()
  626. 58
  627. 59 def extract_tb(tb, limit=None):
  628. 60 """
  629. 61 Return a StackSummary object representing a list of
  630. 62 pre-processed entries from traceback.
  631. 63
  632. 64 This is useful for alternate formatting of stack traces. If
  633. 65 'limit' is omitted or None, all entries are extracted. A
  634. 66 pre-processed stack trace entry is a FrameSummary object
  635. 67 containing attributes filename, lineno, name, and line
  636. 68 representing the information that is usually printed for a stack
  637. 69 trace. The line is a string with leading and trailing
  638. 70 whitespace stripped; if the source is not available it is None.
  639. 71 """
  640. ---> 72 return StackSummary.extract(walk_tb(tb), limit=limit)
  641. global StackSummary.extract = <bound method StackSummary.extract of <class 'traceback.StackSummary'>>
  642. global walk_tb = <function walk_tb at 0x7fd24d4841f0>
  643. tb = KeyError('/usr/lib/python3.8/site-packages/sage/plot/plot.py')
  644. limit = None
  645. 73
  646. 74 #
  647. 75 # Exception formatting and output.
  648. 76 #
  649. 77
  650. 78 _cause_message = (
  651. 79 "\nThe above exception was the direct cause "
  652. 80 "of the following exception:\n\n")
  653. 81
  654. 82 _context_message = (
  655. 83 "\nDuring handling of the above exception, "
  656. 84 "another exception occurred:\n\n")
  657. 85
  658. 86
  659. 87 def print_exception(etype, value, tb, limit=None, file=None, chain=True):
  660.  
  661. /usr/lib/python3.8/traceback.py in extract(klass=<class 'traceback.StackSummary'>, frame_gen=<generator object walk_tb>, limit=None, lookup_lines=True, capture_locals=False)
  662. 332 :param capture_locals: If True, the local variables from each frame will
  663. 333 be captured as object representations into the FrameSummary.
  664. 334 """
  665. 335 if limit is None:
  666. 336 limit = getattr(sys, 'tracebacklimit', None)
  667. 337 if limit is not None and limit < 0:
  668. 338 limit = 0
  669. 339 if limit is not None:
  670. 340 if limit >= 0:
  671. 341 frame_gen = itertools.islice(frame_gen, limit)
  672. 342 else:
  673. 343 frame_gen = collections.deque(frame_gen, maxlen=-limit)
  674. 344
  675. 345 result = klass()
  676. 346 fnames = set()
  677. --> 347 for f, lineno in frame_gen:
  678. f = undefined
  679. lineno = undefined
  680. frame_gen = <generator object walk_tb at 0x7fcffb048a50>
  681. 348 co = f.f_code
  682. 349 filename = co.co_filename
  683. 350 name = co.co_name
  684. 351
  685. 352 fnames.add(filename)
  686. 353 linecache.lazycache(filename, f.f_globals)
  687. 354 # Must defer line lookups until we have called checkcache.
  688. 355 if capture_locals:
  689. 356 f_locals = f.f_locals
  690. 357 else:
  691. 358 f_locals = None
  692. 359 result.append(FrameSummary(
  693. 360 filename, lineno, name, lookup_line=False, locals=f_locals))
  694. 361 for filename in fnames:
  695. 362 linecache.checkcache(filename)
  696.  
  697. /usr/lib/python3.8/traceback.py in walk_tb(tb=KeyError('/usr/lib/python3.8/site-packages/sage/plot/plot.py'))
  698. 297 """
  699. 298 if f is None:
  700. 299 f = sys._getframe().f_back.f_back
  701. 300 while f is not None:
  702. 301 yield f, f.f_lineno
  703. 302 f = f.f_back
  704. 303
  705. 304
  706. 305 def walk_tb(tb):
  707. 306 """Walk a traceback yielding the frame and line number for each frame.
  708. 307
  709. 308 This will follow tb.tb_next (and thus is in the opposite order to
  710. 309 walk_stack). Usually used with StackSummary.extract.
  711. 310 """
  712. 311 while tb is not None:
  713. --> 312 yield tb.tb_frame, tb.tb_lineno
  714. tb.tb_frame = undefined
  715. tb.tb_lineno = undefined
  716. 313 tb = tb.tb_next
  717. 314
  718. 315
  719. 316 _RECURSIVE_CUTOFF = 3 # Also hardcoded in traceback.c.
  720. 317
  721. 318 class StackSummary(list):
  722. 319 """A stack of frames."""
  723. 320
  724. 321 @classmethod
  725. 322 def extract(klass, frame_gen, *, limit=None, lookup_lines=True,
  726. 323 capture_locals=False):
  727. 324 """Create a StackSummary from a traceback or stack object.
  728. 325
  729. 326 :param frame_gen: A generator that yields (frame, lineno) tuples to
  730. 327 include in the stack.
  731.  
  732. AttributeError: 'KeyError' object has no attribute 'tb_frame'
  733.  
  734. **********************************************************************
  735.  
  736. Oops, Sage crashed. We do our best to make it stable, but...
  737.  
  738. A crash report was automatically generated with the following information:
  739. - A verbatim copy of the crash traceback.
  740. - A copy of your input history during this session.
  741. - Data on your current Sage configuration.
  742.  
  743. It was left in the file named:
  744. '/home/joel/.ipython/Sage_crash_report.txt'
  745. If you can email this file to the developers, the information in it will help
  746. them in understanding and correcting the problem.
  747.  
  748. You can mail it to: sage-support at sage-support@googlegroups.com
  749. with the subject 'Sage Crash Report'.
  750.  
  751. If you want to do it now, the following command will work (under Unix):
  752. mail -s 'Sage Crash Report' sage-support@googlegroups.com < /home/joel/.ipython/Sage_crash_report.txt
  753.  
  754. In your email, please also include information about:
  755. - The operating system under which the crash happened: Linux, macOS, Windows,
  756. other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
  757. Windows 10 Pro), and whether it is 32-bit or 64-bit;
  758. - How Sage was installed: using pip or conda, from GitHub, as part of
  759. a Docker container, or other, providing more detail if possible;
  760. - How to reproduce the crash: what exact sequence of instructions can one
  761. input to get the same crash? Ideally, find a minimal yet complete sequence
  762. of instructions that yields the crash.
  763.  
  764. To ensure accurate tracking of this issue, please file a report about it at:
  765. http://trac.sagemath.org
  766.  
  767. Hit <Enter> to quit (your terminal may close):
  768.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement