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