[issue41612] python3.8.3/traceback.py:312, AttributeError: 'KeyError' object has no attribute 'tb_frame'

2020-08-21 Thread Abael He


Abael He  added the comment:

This is a bug caused by IPython:

/opt/conda/lib/python3.8/site-packages/IPython/terminal/ptutils.py in 
get_completions(self, document, complete_event)
114 except Exception as e:
115 from traceback import print_tb
--> 116 print_tb(e)
117 
118 @staticmethod


##
# Simulation investigation for above KeyError:
In [3]: def fun():
   ...: try:
   ...: s = {}
   ...: k = s['0']
   ...: except Exception as e:
   ...: import sys
   ...: from traceback import print_tb
   ...: exc_type, exc_value, exc_traceback = sys.exc_info()
   ...: print_tb(exc_traceback)
   ...: 

In [4]: fun()
  File "", line 4, in fun
k = s['0']

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41612] python3.8.3/traceback.py:312, AttributeError: 'KeyError' object has no attribute 'tb_frame'

2020-08-21 Thread Abael He


New submission from Abael He :

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py in 
prompt(self, message, editing_mode, refresh_interval, vi_mode, lexer, 
completer, complete_in_thread, is_password, key_bindings, bottom_toolbar, 
style, color_depth, include_default_pygments_style, style_transformation, 
swap_light_and_dark_colors, rprompt, multiline, prompt_continuation, 
wrap_lines, enable_history_search, search_ignore_case, complete_while_typing, 
validate_while_typing, complete_style, auto_suggest, validator, clipboard, 
mouse_support, input_processors, reserve_space_for_menu, enable_system_prompt, 
enable_suspend, enable_open_in_editor, tempfile_suffix, tempfile, default, 
accept_default, pre_run, set_exception_handler)
992 return 
get_event_loop().run_until_complete(self._dumb_prompt(self.message))
993 
--> 994 return self.app.run(set_exception_handler=set_exception_handler)
995 
996 async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/application/application.py
 in run(self, pre_run, set_exception_handler)
809 set_event_loop(loop)
810 
--> 811 return loop.run_until_complete(
812 self.run_async(pre_run=pre_run, 
set_exception_handler=set_exception_handler)
813 )

/opt/conda/lib/python3.8/asyncio/base_events.py in run_until_complete(self, 
future)
614 raise RuntimeError('Event loop stopped before Future 
completed.')
615 
--> 616 return future.result()
617 
618 def stop(self):

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/application/application.py
 in run_async(self, pre_run, set_exception_handler)
776 loop.set_exception_handler(previous_exc_handler)
777 
--> 778 return await _run_async2()
779 
780 def run(

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/application/application.py
 in _run_async2()
764 # `KeyboardInterrupt`, we still want to wait 
for the
765 # background tasks.
--> 766 await 
self.cancel_and_wait_for_background_tasks()
767 
768 # Set the `_is_running` flag to `False`. 
Normally this

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/application/application.py
 in cancel_and_wait_for_background_tasks(self)
865 for task in self.background_tasks:
866 try:
--> 867 await task
868 except CancelledError:
869 pass

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/buffer.py in 
new_coroutine(*a, **kw)
   1852 while True:
   1853 try:
-> 1854 await coroutine(*a, **kw)
   1855 except _Retry:
   1856 continue

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/buffer.py in 
async_completer(select_first, select_last, insert_common_part, complete_event)
   1681 return self.complete_state == complete_state
   1682 
-> 1683 async for completion in 
self.completer.get_completions_async(
   1684 document, complete_event
   1685 ):

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in 
get_completions_async(self, document, complete_event)
267 completer = self.get_completer() or DummyCompleter()
268 
--> 269 async for completion in completer.get_completions_async(
270 document, complete_event
271 ):

/opt/conda/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in 
get_completions_async(self, document, complete_event)
194 Asynchronous generator of :class:`.Completion` objects.
195 """
--> 196 for item in self.get_completions(document, complete_event):
197 yield item
198 

/opt/conda/lib/python3.8/site-packages/IPython/terminal/ptutils.py in 
get_completions(self, document, complete_event)
114 except Exception as e:
115 from traceback import print_tb
--> 116 print_tb(e)
117 
118 @staticmethod

/opt/conda/lib/python3.8/traceback.py in print_tb(tb, limit, file)
 51 method.
 52 """
---> 53 print_list(extract_tb(tb, limit=limit), file=file)
 54 
 55 def format_tb(tb, limit=None):

/opt/conda/lib/python3.8/traceback.py in extract_tb(tb, limit)
 70 whitespace stripped; if the source is not available it is None.
 71 """
---> 72 return StackSummary.extract(walk_tb(tb), limit=limit)
 73 
 74 #

/opt/conda/lib/python3.8/traceback.py in extract(klass, frame_gen, limit, 
lookup_lines, capture_locals)
345 result = klass()
346 fnames = set()
--> 347 for f, lineno in frame_gen:
348 co =