Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on attempting tab completion #13156

Closed
fkarg opened this issue Sep 23, 2021 · 2 comments
Closed

Crash on attempting tab completion #13156

fkarg opened this issue Sep 23, 2021 · 2 comments

Comments

@fkarg
Copy link

fkarg commented Sep 23, 2021

I'm trying to use ipython as a stand-in shell for interacting with a django server in a docker setup. When entering the shell via docker-compose exec <container> python manage.py shell -i ipython I'm being dropped in the ipython shell with the django context available. Everything then works properly, as long as I don't attempt to use tab (auto)completion. It worked just fine with all django instances in containers so far.

Specifically, attempting to Tab makes ipython not do anything (but stutter for a second), and crashes after manually completing the current command and pressing Enter.

asciinema recording: https://asciinema.org/a/CoxP5qqiW5dxD7QmPeWX1O6Tq (I attempt to autocomplete after having typed MyTe) (will vanish after 7 days).

On crashing, this cryptic error is being output (extended via the recommended %config Application.verbose_crash=True):

---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeError                              Python 3.6.15: /usr/local/bin/python
                                                   Thu Sep 23 15:52:50 2021
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/local/lib/python3.6/site-packages/IPython/terminal/ptutils.py in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('from dwms.models import My', 26), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
    112             try:
--> 113                 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
        self._get_completions = <function IPythonPTCompleter._get_completions at 0x7f34f94c9268>
        body = 'from dwms.models import My'
        offset = 26
        cursor_position = 26
        self.ipy_completer = <IPython.core.completer.IPCompleter object at 0x7f34af152be0>
    114             except Exception as e:

/usr/local/lib/python3.6/site-packages/IPython/terminal/ptutils.py in _get_completions(body='from dwms.models import My', offset=26, cursor_position=26, ipyc=<IPython.core.completer.IPCompleter object>)
    125             body, ipyc.completions(body, offset))
--> 126         for c in completions:
        c = undefined
        completions = <generator object _deduplicate_completions at 0x7f34aed8d200>
    127             if not c.text:

/usr/local/lib/python3.6/site-packages/IPython/core/completer.py in _deduplicate_completions(text='from dwms.models import My', completions=<generator object IPCompleter.completions>)
    437     ""
--> 438     completions = list(completions)
        completions = <generator object IPCompleter.completions at 0x7f34aed8d1a8>
        global list = undefined
    439     if not completions:

/usr/local/lib/python3.6/site-packages/IPython/core/completer.py in completions(self=<IPython.core.completer.IPCompleter object>, text='from dwms.models import My', offset=26)
   1817         try:
-> 1818             for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
        c = undefined
        self._completions = <bound method IPCompleter._completions of <IPython.core.completer.IPCompleter object at 0x7f34af152be0>>
        text = 'from dwms.models import My'
        offset = 26
        global _timeout = undefined
        self.jedi_compute_type_timeout = 400
   1819                 if c and (c in seen):

/usr/local/lib/python3.6/site-packages/IPython/core/completer.py in _completions(self=<IPython.core.completer.IPCompleter object>, full_text='from dwms.models import My', offset=26, _timeout=0.4)
   1861         matched_text, matches, matches_origin, jedi_matches = self._complete(
-> 1862             full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
        full_text = 'from dwms.models import My'
        cursor_line = 0
        global cursor_pos = undefined
        cursor_column = 26
   1863 

/usr/local/lib/python3.6/site-packages/IPython/core/completer.py in _complete(self=<IPython.core.completer.IPCompleter object>, cursor_line=0, cursor_pos=26, line_buffer='from dwms.models import My', text='My', full_text='from dwms.models import My')
   2029             completions = self._jedi_matches(
-> 2030                 cursor_pos, cursor_line, full_text)
        cursor_pos = 26
        cursor_line = 0
        full_text = 'from dwms.models import My'
   2031                 

/usr/local/lib/python3.6/site-packages/IPython/core/completer.py in _jedi_matches(self=<IPython.core.completer.IPCompleter object>, cursor_column=26, cursor_line=0, text='from dwms.models import My')
   1373         interpreter = jedi.Interpreter(
-> 1374             text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
        text = 'from dwms.models import My'
        offset = 26
        namespaces = [{'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], '_oh': {}, '_dh': ['/app'], 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>, 'exit': <IPython.core.autocall.ExitAutocall object at 0x7f34af1529b0>, 'quit': <IPython.core.autocall.ExitAutocall object at 0x7f34af1529b0>, '_': '', '__': '', '___': '', '_i': '', '_ii': '', '_iii': '', '_i1': '%config Application.verbose_crash=True'}, {'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], '_oh': {}, '_dh': ['/app'], 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>, 'exit': <IPython.core.autocall.ExitAutocall object at 0x7f34af1529b0>, 'quit': <IPython.core.autocall.ExitAutocall object at 0x7f34af1529b0>, '_': '', '__': '', '___': '', '_i': '', '_ii': '', '_iii': '', '_i1': '%config Application.verbose_crash=True'}]
        global column = undefined
        cursor_column = 26
        global line = undefined
        cursor_line = 0
   1375         try_jedi = True

/usr/local/lib/python3.6/site-packages/jedi/api/__init__.py in __init__(self=<class 'jedi.api.Interpreter'> instance, code='from dwms.models import My', namespaces=[{'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], 'Out': {}, '_': '', '__': '', '___': '', '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', '__loader__': None, '__name__': '__main__', ...}, {'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')"], 'Out': {}, '_': '', '__': '', '___': '', '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', '__loader__': None, '__name__': '__main__', ...}], **kwds={'column': 26, 'line': 1})
    725         super().__init__(code, environment=environment,
--> 726                          project=Project(Path.cwd()), **kwds)
        global project = <module 'jedi.api.project' from '/usr/local/lib/python3.6/site-packages/jedi/api/project.py'>
        global Project = <class 'jedi.api.project.Project'>
        global Path.cwd = <bound method Path.cwd of <class 'pathlib.Path'>>
        kwds = {'column': 26, 'line': 1}
    727         self.namespaces = namespaces

TypeError: __init__() got an unexpected keyword argument 'column'

During handling of the above exception, another exception occurred:

---------------------------------------------------------------------------
AttributeError                         Python 3.6.15: /usr/local/bin/python
                                                   Thu Sep 23 15:52:50 2021
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/app/manage.py in <module>
      7 def main():
      8     """Run administrative tasks."""
      9     os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dwms.settings')
     10     try:
     11         from django.core.management import execute_from_command_line
     12     except ImportError as exc:
     13         raise ImportError(
     14             "Couldn't import Django. Are you sure it's installed and "
     15             "available on your PYTHONPATH environment variable? Did you "
     16             "forget to activate a virtual environment?"
     17         ) from exc
     18     execute_from_command_line(sys.argv)
     19 
     20 
     21 if __name__ == '__main__':
---> 22     main()
        global main = <function main at 0x7f34fb589e18>

/app/manage.py in main()
      3 import os
      4 import sys
      5 
      6 
      7 def main():
      8     """Run administrative tasks."""
      9     os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dwms.settings')
     10     try:
     11         from django.core.management import execute_from_command_line
     12     except ImportError as exc:
     13         raise ImportError(
     14             "Couldn't import Django. Are you sure it's installed and "
     15             "available on your PYTHONPATH environment variable? Did you "
     16             "forget to activate a virtual environment?"
     17         ) from exc
---> 18     execute_from_command_line(sys.argv)
        execute_from_command_line = <function execute_from_command_line at 0x7f34fa7ebe18>
        global sys.argv = ['manage.py', 'shell', '-i', 'ipython']
     19 
     20 
     21 if __name__ == '__main__':
     22     main()

/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py in execute_from_command_line(argv=['manage.py', 'shell', '-i', 'ipython'])
    386             else:
    387                 self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
    388         # Special-cases: We want 'django-admin --version' and
    389         # 'django-admin --help' to work, for backwards compatibility.
    390         elif subcommand == 'version' or self.argv[1:] == ['--version']:
    391             sys.stdout.write(django.get_version() + '\n')
    392         elif self.argv[1:] in (['--help'], ['-h']):
    393             sys.stdout.write(self.main_help_text() + '\n')
    394         else:
    395             self.fetch_command(subcommand).run_from_argv(self.argv)
    396 
    397 
    398 def execute_from_command_line(argv=None):
    399     """Run a ManagementUtility."""
    400     utility = ManagementUtility(argv)
--> 401     utility.execute()
        utility.execute = <bound method ManagementUtility.execute of <django.core.management.ManagementUtility object at 0x7f34fb4e25c0>>

/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py in execute(self=<django.core.management.ManagementUtility object>)
    380 
    381         if subcommand == 'help':
    382             if '--commands' in args:
    383                 sys.stdout.write(self.main_help_text(commands_only=True) + '\n')
    384             elif not options.args:
    385                 sys.stdout.write(self.main_help_text() + '\n')
    386             else:
    387                 self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
    388         # Special-cases: We want 'django-admin --version' and
    389         # 'django-admin --help' to work, for backwards compatibility.
    390         elif subcommand == 'version' or self.argv[1:] == ['--version']:
    391             sys.stdout.write(django.get_version() + '\n')
    392         elif self.argv[1:] in (['--help'], ['-h']):
    393             sys.stdout.write(self.main_help_text() + '\n')
    394         else:
--> 395             self.fetch_command(subcommand).run_from_argv(self.argv)
        self.fetch_command = <bound method ManagementUtility.fetch_command of <django.core.management.ManagementUtility object at 0x7f34fb4e25c0>>
        subcommand.run_from_argv = undefined
        self.argv = ['manage.py', 'shell', '-i', 'ipython']
    396 
    397 
    398 def execute_from_command_line(argv=None):
    399     """Run a ManagementUtility."""
    400     utility = ManagementUtility(argv)
    401     utility.execute()

/usr/local/lib/python3.6/site-packages/django/core/management/base.py in run_from_argv(self=<django.core.management.commands.shell.Command object>, argv=['manage.py', 'shell', '-i', 'ipython'])
    315         Set up any environment changes requested (e.g., Python path
    316         and Django settings), then run this command. If the
    317         command raises a ``CommandError``, intercept it and print it sensibly
    318         to stderr. If the ``--traceback`` option is present or the raised
    319         ``Exception`` is not ``CommandError``, raise it.
    320         ""
    321         self._called_from_command_line = True
    322         parser = self.create_parser(argv[0], argv[1])
    323 
    324         options = parser.parse_args(argv[2:])
    325         cmd_options = vars(options)
    326         # Move positional args out of options to mimic legacy optparse
    327         args = cmd_options.pop('args', ())
    328         handle_default_options(options)
    329         try:
--> 330             self.execute(*args, **cmd_options)
        self.execute = <bound method BaseCommand.execute of <django.core.management.commands.shell.Command object at 0x7f34fb3bf5c0>>
        args = ()
        cmd_options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': 'ipython', 'command': None}
    331         except CommandError as e:
    332             if options.traceback:
    333                 raise
    334 
    335             # SystemCheckError takes care of its own formatting.
    336             if isinstance(e, SystemCheckError):
    337                 self.stderr.write(str(e), lambda x: x)
    338             else:
    339                 self.stderr.write('%s: %s' % (e.__class__.__name__, e))
    340             sys.exit(e.returncode)
    341         finally:
    342             try:
    343                 connections.close_all()
    344             except ImproperlyConfigured:
    345                 # Ignore if connections aren't setup at this point (e.g. no

/usr/local/lib/python3.6/site-packages/django/core/management/base.py in execute(self=<django.core.management.commands.shell.Command object>, *args=(), **options={'command': None, 'force_color': False, 'interface': 'ipython', 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
    356             raise CommandError("The --no-color and --force-color options can't be used together.")
    357         if options['force_color']:
    358             self.style = color_style(force_color=True)
    359         elif options['no_color']:
    360             self.style = no_style()
    361             self.stderr.style_func = None
    362         if options.get('stdout'):
    363             self.stdout = OutputWrapper(options['stdout'])
    364         if options.get('stderr'):
    365             self.stderr = OutputWrapper(options['stderr'])
    366 
    367         if self.requires_system_checks and not options['skip_checks']:
    368             self.check()
    369         if self.requires_migrations_checks:
    370             self.check_migrations()
--> 371         output = self.handle(*args, **options)
        output = undefined
        self.handle = <bound method Command.handle of <django.core.management.commands.shell.Command object at 0x7f34fb3bf5c0>>
        args = ()
        options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': 'ipython', 'command': None}
    372         if output:
    373             if self.output_transaction:
    374                 connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
    375                 output = '%s\n%s\n%s' % (
    376                     self.style.SQL_KEYWORD(connection.ops.start_transaction_sql()),
    377                     output,
    378                     self.style.SQL_KEYWORD(connection.ops.end_transaction_sql()),
    379                 )
    380             self.stdout.write(output)
    381         return output
    382 
    383     def check(self, app_configs=None, tags=None, display_num_errors=False,
    384               include_deployment_checks=False, fail_level=checks.ERROR,
    385               databases=None):
    386         ""

/usr/local/lib/python3.6/site-packages/django/core/management/commands/shell.py in handle(self=<django.core.management.commands.shell.Command object>, **options={'command': None, 'force_color': False, 'interface': 'ipython', 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
     85         # Execute the command and exit.
     86         if options['command']:
     87             exec(options['command'])
     88             return
     89 
     90         # Execute stdin if it has anything to read and exit.
     91         # Not supported on Windows due to select.select() limitations.
     92         if sys.platform != 'win32' and not sys.stdin.isatty() and select.select([sys.stdin], [], [], 0)[0]:
     93             exec(sys.stdin.read())
     94             return
     95 
     96         available_shells = [options['interface']] if options['interface'] else self.shells
     97 
     98         for shell in available_shells:
     99             try:
--> 100                 return getattr(self, shell)(options)
        global getattr = undefined
        self = <django.core.management.commands.shell.Command object at 0x7f34fb3bf5c0>
        shell = 'ipython'
        options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': 'ipython', 'command': None}
    101             except ImportError:
    102                 pass
    103         raise CommandError("Couldn't import {} interface.".format(shell))

/usr/local/lib/python3.6/site-packages/django/core/management/commands/shell.py in ipython(self=<django.core.management.commands.shell.Command object>, options={'command': None, 'force_color': False, 'interface': 'ipython', 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
     21         parser.add_argument(
     22             '--no-startup', action='store_true',
     23             help='When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.',
     24         )
     25         parser.add_argument(
     26             '-i', '--interface', choices=self.shells,
     27             help='Specify an interactive interpreter interface. Available options: "ipython", "bpython", and "python"',
     28         )
     29         parser.add_argument(
     30             '-c', '--command',
     31             help='Instead of opening an interactive shell, run a command as Django and exit.',
     32         )
     33 
     34     def ipython(self, options):
     35         from IPython import start_ipython
---> 36         start_ipython(argv=[])
        start_ipython = <function start_ipython at 0x7f34af156158>
        global argv = undefined
     37 
     38     def bpython(self, options):
     39         import bpython
     40         bpython.embed()
     41 
     42     def python(self, options):
     43         import code
     44 
     45         # Set up a dictionary to serve as the environment for the shell, so
     46         # that tab completion works on objects that are imported at runtime.
     47         imported_objects = {}
     48         try:  # Try activating rlcompleter, because it's handy.
     49             import readline
     50         except ImportError:
     51             pass

/usr/local/lib/python3.6/site-packages/IPython/__init__.py in start_ipython(argv=[], **kwargs={})
    111     This is a public API method, and will survive implementation changes.
    112     
    113     Parameters
    114     ----------
    115     
    116     argv : list or None, optional
    117         If unspecified or None, IPython will parse command-line options from sys.argv.
    118         To prevent any command-line parsing, pass an empty list: `argv=[]`.
    119     user_ns : dict, optional
    120         specify this dictionary to initialize the IPython user namespace with particular values.
    121     kwargs : various, optional
    122         Any other kwargs will be passed to the Application constructor,
    123         such as `config`.
    124     ""
    125     from IPython.terminal.ipapp import launch_new_instance
--> 126     return launch_new_instance(argv=argv, **kwargs)
        launch_new_instance = <bound method Application.launch_instance of <class 'IPython.terminal.ipapp.TerminalIPythonApp'>>
        argv = []
        kwargs = {}
    127 
    128 def start_kernel(argv=None, **kwargs):
    129     """Launch a normal IPython kernel instance (as opposed to embedded)
    130     
    131     `IPython.embed_kernel()` puts a shell in a particular calling scope,
    132     such as a function or method for debugging purposes,
    133     which is often not desirable.
    134     
    135     `start_kernel()` does full, regular IPython initialization,
    136     including loading startup files, configuration, etc.
    137     much of which is skipped by `embed()`.
    138     
    139     Parameters
    140     ----------
    141     """

/usr/local/lib/python3.6/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'IPython.terminal.ipapp.TerminalIPythonApp'>, argv=[], **kwargs={})
    649             lines.append(cls.class_config_section())
    650         return '\n'.join(lines)
    651 
    652     def exit(self, exit_status=0):
    653         self.log.debug("Exiting application: %s" % self.name)
    654         sys.exit(exit_status)
    655 
    656     @classmethod
    657     def launch_instance(cls, argv=None, **kwargs):
    658         """Launch a global instance of this Application
    659 
    660         If a global instance already exists, this reinitializes and starts it
    661         """
    662         app = cls.instance(**kwargs)
    663         app.initialize(argv)
--> 664         app.start()
        app.start = <bound method TerminalIPythonApp.start of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x7f34aff6e8d0>>
    665 
    666 #-----------------------------------------------------------------------------
    667 # utility functions, for convenience
    668 #-----------------------------------------------------------------------------
    669 
    670 def boolean_flag(name, configurable, set_help='', unset_help=''):
    671     """Helper for building basic --trait, --no-trait flags.
    672 
    673     Parameters
    674     ----------
    675 
    676     name : str
    677         The name of the flag.
    678     configurable : str
    679         The 'Class.trait' string of the trait to be set/unset with the flag
"""

/usr/local/lib/python3.6/site-packages/IPython/terminal/ipapp.py in start(self=<IPython.terminal.ipapp.TerminalIPythonApp object>)
    341         if self.log_level <= logging.INFO: print()
    342 
    343     def _pylab_changed(self, name, old, new):
    344         """Replace --pylab='inline' with --pylab='auto'"""
    345         if new == 'inline':
    346             warnings.warn("'inline' not available as pylab backend, "
    347                       "using 'auto' instead.")
    348             self.pylab = 'auto'
    349 
    350     def start(self):
    351         if self.subapp is not None:
    352             return self.subapp.start()
    353         # perform any prexec steps:
    354         if self.interact:
    355             self.log.debug("Starting IPython's mainloop...")
--> 356             self.shell.mainloop()
        self.shell.mainloop = <bound method TerminalInteractiveShell.mainloop of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>
    357         else:
    358             self.log.debug("IPython not interactive...")
    359             if not self.shell.last_execution_succeeded:
    360                 sys.exit(1)
    361 
    362 def load_default_config(ipython_dir=None):
    363     """Load the default config file from the default ipython_dir.
    364 
    365     This is useful for embedded shells.
    366     """
    367     if ipython_dir is None:
    368         ipython_dir = get_ipython_dir()
    369 
    370     profile_dir = os.path.join(ipython_dir, 'profile_default')
    371     app = TerminalIPythonApp()

/usr/local/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in mainloop(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
    548                 if (not self.confirm_exit) \
    549                         or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
    550                     self.ask_exit()
    551 
    552             else:
    553                 if code:
    554                     self.run_cell(code, store_history=True)
    555 
    556     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    557         # An extra layer of protection in case someone mashing Ctrl-C breaks
    558         # out of our internal code.
    559         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    560             warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    561         while True:
    562             try:
--> 563                 self.interact()
        self.interact = <bound method TerminalInteractiveShell.interact of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>
    564                 break
    565             except KeyboardInterrupt as e:
    566                 print("\n%s escaped interact()\n" % type(e).__name__)
    567             finally:
    568                 # An interrupt during the eventloop will mess up the
    569                 # internal state of the prompt_toolkit library.
    570                 # Stopping the eventloop fixes this, see
    571                 # https://github.com/ipython/ipython/pull/9867
    572                 if hasattr(self, '_eventloop'):
    573                     self._eventloop.stop()
    574 
    575                 self.restore_term_title()
    576 
    577 
    578     _inputhook = None

/usr/local/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in interact(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
    531     def ask_exit(self):
    532         self.keep_running = False
    533 
    534     rl_next_input = None
    535 
    536     def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    537 
    538         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    539             warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    540 
    541         self.keep_running = True
    542         while self.keep_running:
    543             print(self.separate_in, end='')
    544 
    545             try:
--> 546                 code = self.prompt_for_code()
        code = '%config Application.verbose_crash=True'
        self.prompt_for_code = <bound method TerminalInteractiveShell.prompt_for_code of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>
    547             except EOFError:
    548                 if (not self.confirm_exit) \
    549                         or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
    550                     self.ask_exit()
    551 
    552             else:
    553                 if code:
    554                     self.run_cell(code, store_history=True)
    555 
    556     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    557         # An extra layer of protection in case someone mashing Ctrl-C breaks
    558         # out of our internal code.
    559         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    560             warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    561         while True:

/usr/local/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>)
    459         # prompt in a different event loop.
    460         # If we don't do this, people could spawn coroutine with a
    461         # while/true inside which will freeze the prompt.
    462 
    463         try:
    464             old_loop = asyncio.get_event_loop()
    465         except RuntimeError:
    466             # This happens when the user used `asyncio.run()`.
    467             old_loop = None
    468 
    469         asyncio.set_event_loop(self.pt_loop)
    470         try:
    471             with patch_stdout(raw=True):
    472                 text = self.pt_app.prompt(
    473                     default=default,
--> 474                     **self._extra_prompt_options())
        self._extra_prompt_options = <bound method TerminalInteractiveShell._extra_prompt_options of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f34af0e95c0>>
    475         finally:
    476             # Restore the original event loop.
    477             asyncio.set_event_loop(old_loop)
    478 
    479         return text
    480 
    481     def enable_win_unicode_console(self):
    482         # Since IPython 7.10 doesn't support python < 3.6 and PEP 528, Python uses the unicode APIs for the Windows
    483         # console by default, so WUC shouldn't be needed.
    484         from warnings import warn
    485         warn("`enable_win_unicode_console` is deprecated since IPython 7.10, does not do anything and will be removed in the future",
    486              DeprecationWarning,
    487              stacklevel=2)
    488 
    489     def init_io(self):

/usr/local/lib/python3.6/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 0x7f34aee62f28>))], placeholder=None, 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, in_thread=False)
   1006             self.tempfile = tempfile
   1007 
   1008         self._add_pre_run_callables(pre_run, accept_default)
   1009         self.default_buffer.reset(
   1010             default if isinstance(default, Document) else Document(default)
   1011         )
   1012         self.app.refresh_interval = self.refresh_interval  # This is not reactive.
   1013 
   1014         # If we are using the default output, and have a dumb terminal. Use the
   1015         # dumb prompt.
   1016         if self._output is None and is_dumb_terminal():
   1017             with self._dumb_prompt(self.message) as dump_app:
   1018                 return dump_app.run(in_thread=in_thread)
   1019 
   1020         return self.app.run(
-> 1021             set_exception_handler=set_exception_handler, in_thread=in_thread
        set_exception_handler = True
        in_thread = False
   1022         )
   1023 
   1024     @contextmanager
   1025     def _dumb_prompt(self, message: AnyFormattedText = "") -> Iterator[Application[_T]]:
   1026         """
   1027         Create prompt `Application` for prompt function for dumb terminals.
   1028 
   1029         Dumb terminals have minimum rendering capabilities. We can only print
   1030         text to the screen. We can't use colors, and we can't do cursor
   1031         movements. The Emacs inferior shell is an example of a dumb terminal.
   1032 
   1033         We will show the prompt, and wait for the input. We still handle arrow
   1034         keys, and all custom key bindings, but we don't really render the
   1035         cursor movements. Instead we only print the typed character that's
   1036         right before the cursor.
"""

/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True, in_thread=False)
    877         # We don't create a new event loop by default, because we want to be
    878         # sure that when this is called multiple times, each call of `run()`
    879         # goes through the same event loop. This way, users can schedule
    880         # background-tasks that keep running across multiple prompts.
    881         try:
    882             loop = get_event_loop()
    883         except RuntimeError:
    884             # Possibly we are not running in the main thread, where no event
    885             # loop is set by default. Or somebody called `asyncio.run()`
    886             # before, which closes the existing event loop. We can create a new
    887             # loop.
    888             loop = new_event_loop()
    889             set_event_loop(loop)
    890 
    891         return loop.run_until_complete(
--> 892             self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
        self.run_async = <bound method Application.run_async of <prompt_toolkit.application.application.Application object at 0x7f34aef7dac8>>
        pre_run = None
        set_exception_handler = True
    893         )
    894 
    895     def _handle_exception(
    896         self, loop: AbstractEventLoop, context: Dict[str, Any]
    897     ) -> None:
    898         """
    899         Handler for event loop exceptions.
    900         This will print the exception, using run_in_terminal.
    901         """
    902         # For Python 2: we have to get traceback at this point, because
    903         # we're still in the 'except:' block of the event loop where the
    904         # traceback is still available. Moving this code in the
    905         # 'print_exception' coroutine will loose the exception.
    906         tb = get_traceback_from_context(context)
    907         formatted_tb = "".join(format_tb(tb))

/usr/local/lib/python3.6/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'",)>)
    473         future.add_done_callback(_run_until_complete_cb)
    474         try:
    475             self.run_forever()
    476         except:
    477             if new_task and future.done() and not future.cancelled():
    478                 # The coroutine raised a BaseException. Consume the exception
    479                 # to not log a warning, the caller doesn't have access to the
    480                 # local task.
    481                 future.exception()
    482             raise
    483         finally:
    484             future.remove_done_callback(_run_until_complete_cb)
    485         if not future.done():
    486             raise RuntimeError('Event loop stopped before Future completed.')
    487 
--> 488         return future.result()
        future.result = <built-in method result of _asyncio.Task object at 0x7f34aee628c8>
    489 
    490     def stop(self):
    491         """Stop running the event loop.
    492 
    493         Every callback already scheduled will still run.  This simply informs
    494         run_forever to stop looping after a complete iteration.
    495         """
    496         self._stopping = True
    497 
    498     def close(self):
    499         """Close the event loop.
    500 
    501         This clears the queues and shuts down the executor,
    502         but does not wait for the executor to finish.
    503 """

/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run_async(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True)
    801                         # happened already in the finally block in `run_async`
    802                         # above, but in case of exceptions, that's not always the
    803                         # case.
    804                         self._is_running = False
    805 
    806                         # Also remove the Future again. (This brings the
    807                         # application back to its initial state, where it also
    808                         # doesn't have a Future.)
    809                         self.future = None
    810 
    811                     return result
    812             finally:
    813                 if set_exception_handler:
    814                     loop.set_exception_handler(previous_exc_handler)
    815 
--> 816         return await _run_async2()
        global await = undefined
        _run_async2 = <function Application.run_async.<locals>._run_async2 at 0x7f34aef45a60>
    817 
    818     def run(
    819         self,
    820         pre_run: Optional[Callable[[], None]] = None,
    821         set_exception_handler: bool = True,
    822         in_thread: bool = False,
    823     ) -> _AppResult:
    824         """
    825         A blocking 'run' call that waits until the UI is finished.
    826 
    827         This will start the current asyncio event loop. If no loop is set for
    828         the current thread, then it will create a new loop. If a new loop was
    829         created, this won't close the new loop (if `in_thread=False`).
    830 
    831         :param pre_run: Optional callable, which is called right after the
"""

/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async2()
    783 
    784             loop = get_event_loop()
    785             if set_exception_handler:
    786                 previous_exc_handler = loop.get_exception_handler()
    787                 loop.set_exception_handler(self._handle_exception)
    788 
    789             try:
    790                 with set_app(self), self._enable_breakpointhook():
    791                     try:
    792                         result = await _run_async()
    793                     finally:
    794                         # Wait for the background tasks to be done. This needs to
    795                         # go in the finally! If `_run_async` raises
    796                         # `KeyboardInterrupt`, we still want to wait for the
    797                         # background tasks.
--> 798                         await self.cancel_and_wait_for_background_tasks()
        global await = undefined
        global self.cancel_and_wait_for_background_tasks = undefined
    799 
    800                         # Set the `_is_running` flag to `False`. Normally this
    801                         # happened already in the finally block in `run_async`
    802                         # above, but in case of exceptions, that's not always the
    803                         # case.
    804                         self._is_running = False
    805 
    806                         # Also remove the Future again. (This brings the
    807                         # application back to its initial state, where it also
    808                         # doesn't have a Future.)
    809                         self.future = None
    810 
    811                     return result
    812             finally:
    813                 if set_exception_handler:

/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py in cancel_and_wait_for_background_tasks(self=<prompt_toolkit.application.application.Application object>)
    986 
    987     async def cancel_and_wait_for_background_tasks(self) -> None:
    988         """
    989         Cancel all background tasks, and wait for the cancellation to be done.
    990         If any of the background tasks raised an exception, this will also
    991         propagate the exception.
    992 
    993         (If we had nurseries like Trio, this would be the `__aexit__` of a
    994         nursery.)
    995         """
    996         for task in self.background_tasks:
    997             task.cancel()
    998 
    999         for task in self.background_tasks:
   1000             try:
-> 1001                 await task
        global await = undefined
        task = <Task finished coro=<Buffer._create_completer_coroutine.<locals>.async_completer() done, defined at /usr/local/lib/python3.6/site-packages/prompt_toolkit/buffer.py:1896> exception=AttributeError("'TypeError' object has no attribute 'tb_frame'",)>
   1002             except CancelledError:
   1003                 pass
   1004 
   1005     async def _poll_output_size(self) -> None:
   1006         """
   1007         Coroutine for polling the terminal dimensions.
   1008 
   1009         Useful for situations where `attach_winch_signal_handler` is not sufficient:
   1010         - If we are not running in the main thread.
   1011         - On Windows.
   1012         """
   1013         size: Optional[Size] = None
   1014         interval = self.terminal_size_polling_interval
   1015 
   1016         if interval is None:

/usr/local/lib/python3.6/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})
   1894     running = False
   1895 
   1896     @wraps(coroutine)
   1897     async def new_coroutine(*a: Any, **kw: Any) -> Any:
   1898         nonlocal running
   1899 
   1900         # Don't start a new function, if the previous is still in progress.
   1901         if running:
   1902             return
   1903 
   1904         running = True
   1905 
   1906         try:
   1907             while True:
   1908                 try:
-> 1909                     await coroutine(*a, **kw)
        global await = undefined
        global coroutine = undefined
        a = ()
        kw = {'select_first': False, 'select_last': False, 'insert_common_part': True, 'complete_event': CompleteEvent(text_inserted=False, completion_requested=True)}
   1910                 except _Retry:
   1911                     continue
   1912                 else:
   1913                     return None
   1914         finally:
   1915             running = False
   1916 
   1917     return cast(_T, new_coroutine)
   1918 
   1919 
   1920 class _Retry(Exception):
   1921     "Retry in `_only_one_at_a_time`."
   1922 
   1923 
   1924 def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None:

/usr/local/lib/python3.6/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))
   1724 
   1725             # Don't complete when we already have completions.
   1726             if self.complete_state or not self.completer:
   1727                 return
   1728 
   1729             # Create an empty CompletionState.
   1730             complete_state = CompletionState(original_document=self.document)
   1731             self.complete_state = complete_state
   1732 
   1733             def proceed() -> bool:
   1734                 """Keep retrieving completions. Input text has not yet changed
   1735                 while generating completions."""
   1736                 return self.complete_state == complete_state
   1737 
   1738             async for completion in self.completer.get_completions_async(
-> 1739                 document, complete_event
        document = Document('from dwms.models import My', 26)
        complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
   1740             ):
   1741                 complete_state.completions.append(completion)
   1742                 self.on_completions_changed.fire()
   1743 
   1744                 # If the input text changes, abort.
   1745                 if not proceed():
   1746                     break
   1747 
   1748             completions = complete_state.completions
   1749 
   1750             # When there is only one completion, which has nothing to add, ignore it.
   1751             if len(completions) == 1 and completion_does_nothing(
   1752                 document, completions[0]
   1753             ):
   1754                 del completions[:]

/usr/local/lib/python3.6/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=DynamicCompleter(<function PromptSession._create...ils.IPythonPTCompleter object at 0x7f34fa977160>), document=Document('from dwms.models import My', 26), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
    257     def __init__(self, get_completer: Callable[[], Optional[Completer]]) -> None:
    258         self.get_completer = get_completer
    259 
    260     def get_completions(
    261         self, document: Document, complete_event: CompleteEvent
    262     ) -> Iterable[Completion]:
    263         completer = self.get_completer() or DummyCompleter()
    264         return completer.get_completions(document, complete_event)
    265 
    266     async def get_completions_async(
    267         self, document: Document, complete_event: CompleteEvent
    268     ) -> AsyncGenerator[Completion, None]:
    269         completer = self.get_completer() or DummyCompleter()
    270 
    271         async for completion in completer.get_completions_async(
--> 272             document, complete_event
        document = Document('from dwms.models import My', 26)
        complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
    273         ):
    274             yield completion
    275 
    276     def __repr__(self) -> str:
    277         return "DynamicCompleter(%r -> %r)" % (self.get_completer, self.get_completer())
    278 
    279 
    280 class ConditionalCompleter(Completer):
    281     """
    282     Wrapper around any other completer that will enable/disable the completions
    283     depending on whether the received condition is satisfied.
    284 
    285     :param completer: :class:`.Completer` instance.
    286     :param filter: :class:`.Filter` instance.
    287     """

/usr/local/lib/python3.6/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('from dwms.models import My', 26), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
    183         :param document: :class:`~prompt_toolkit.document.Document` instance.
    184         :param complete_event: :class:`.CompleteEvent` instance.
    185         ""
    186         while False:
    187             yield
    188 
    189     async def get_completions_async(
    190         self, document: Document, complete_event: CompleteEvent
    191     ) -> AsyncGenerator[Completion, None]:
    192         """
    193         Asynchronous generator for completions. (Probably, you won't have to
    194         override this.)
    195 
    196         Asynchronous generator of :class:`.Completion` objects.
    197         """
--> 198         for item in self.get_completions(document, complete_event):
        item = undefined
        self.get_completions = <bound method IPythonPTCompleter.get_completions of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x7f34fa977160>>
        document = Document('from dwms.models import My', 26)
        complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
    199             yield item
    200 
    201 
    202 class ThreadedCompleter(Completer):
    203     """
    204     Wrapper that runs the `get_completions` generator in a thread.
    205 
    206     (Use this to prevent the user interface from becoming unresponsive if the
    207     generation of completions takes too much time.)
    208 
    209     The completions will be displayed as soon as they are produced. The user
    210     can already select a completion, even if not all completions are displayed.
    211     """
    212 
    213     def __init__(self, completer: Completer) -> None:

/usr/local/lib/python3.6/site-packages/IPython/terminal/ptutils.py in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('from dwms.models import My', 26), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
    101             return
    102         # Some bits of our completion system may print stuff (e.g. if a module
    103         # is imported). This context manager ensures that doesn't interfere with
    104         # the prompt.
    105 
    106         with patch_stdout(), provisionalcompleter():
    107             body = document.text
    108             cursor_row = document.cursor_position_row
    109             cursor_col = document.cursor_position_col
    110             cursor_position = document.cursor_position
    111             offset = cursor_to_position(body, cursor_row, cursor_col)
    112             try:
    113                 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
    114             except Exception as e:
    115                 from traceback import print_tb
--> 116                 print_tb(e)
        print_tb = <function print_tb at 0x7f34fb309ea0>
        e = undefined
    117 
    118     @staticmethod
    119     def _get_completions(body, offset, cursor_position, ipyc):
    120         """
    121         Private equivalent of get_completions() use only for unit_testing.
    122         """
    123         debug = getattr(ipyc, 'debug', False)
    124         completions = _deduplicate_completions(
    125             body, ipyc.completions(body, offset))
    126         for c in completions:
    127             if not c.text:
    128                 # Guard against completion machinery giving us an empty string.
    129                 continue
    130             text = unicodedata.normalize('NFC', c.text)
    131             # When the first character of the completion has a zero length,

/usr/local/lib/python3.6/traceback.py in print_tb(tb=TypeError("__init__() got an unexpected keyword argument 'column'",), limit=None, file=None)
     38     ""
     39     return StackSummary.from_list(extracted_list).format()
     40 
     41 #
     42 # Printing and Extracting Tracebacks.
     43 #
     44 
     45 def print_tb(tb, limit=None, file=None):
     46     """Print up to 'limit' stack trace entries from the traceback 'tb'.
     47 
     48     If 'limit' is omitted or None, all entries are printed.  If 'file'
     49     is omitted or None, the output goes to sys.stderr; otherwise
     50     'file' should be an open file or file-like object with a write()
     51     method.
     52     """
---> 53     print_list(extract_tb(tb, limit=limit), file=file)
        global print_list = <function print_list at 0x7f34fb3c9620>
        global extract_tb = <function extract_tb at 0x7f34fb30d048>
        tb = TypeError("__init__() got an unexpected keyword argument 'column'",)
        limit = None
        file = None
     54 
     55 def format_tb(tb, limit=None):
     56     """A shorthand for 'format_list(extract_tb(tb, limit))'."""
     57     return extract_tb(tb, limit=limit).format()
     58 
     59 def extract_tb(tb, limit=None):
     60     """
     61     Return a StackSummary object representing a list of
     62     pre-processed entries from traceback.
     63 
     64     This is useful for alternate formatting of stack traces.  If
     65     'limit' is omitted or None, all entries are extracted.  A
     66     pre-processed stack trace entry is a FrameSummary object
     67     containing attributes filename, lineno, name, and line
     68     representing the information that is usually printed for a stack
"""

/usr/local/lib/python3.6/traceback.py in extract_tb(tb=TypeError("__init__() got an unexpected keyword argument 'column'",), limit=None)
     57     return extract_tb(tb, limit=limit).format()
     58 
     59 def extract_tb(tb, limit=None):
     60     """
     61     Return a StackSummary object representing a list of
     62     pre-processed entries from traceback.
     63 
     64     This is useful for alternate formatting of stack traces.  If
     65     'limit' is omitted or None, all entries are extracted.  A
     66     pre-processed stack trace entry is a FrameSummary object
     67     containing attributes filename, lineno, name, and line
     68     representing the information that is usually printed for a stack
     69     trace.  The line is a string with leading and trailing
     70     whitespace stripped; if the source is not available it is None.
     71     """
---> 72     return StackSummary.extract(walk_tb(tb), limit=limit)
        global StackSummary.extract = <bound method StackSummary.extract of <class 'traceback.StackSummary'>>
        global walk_tb = <function walk_tb at 0x7f34fb30dae8>
        tb = TypeError("__init__() got an unexpected keyword argument 'column'",)
        limit = None
     73 
     74 #
     75 # Exception formatting and output.
     76 #
     77 
     78 _cause_message = (
     79     "\nThe above exception was the direct cause "
     80     "of the following exception:\n\n")
     81 
     82 _context_message = (
     83     "\nDuring handling of the above exception, "
     84     "another exception occurred:\n\n")
     85 
     86 
     87 def print_exception(etype, value, tb, limit=None, file=None, chain=True):

/usr/local/lib/python3.6/traceback.py in extract(klass=<class 'traceback.StackSummary'>, frame_gen=<generator object walk_tb>, limit=None, lookup_lines=True, capture_locals=False)
    330         :param capture_locals: If True, the local variables from each frame will
    331             be captured as object representations into the FrameSummary.
    332         ""
    333         if limit is None:
    334             limit = getattr(sys, 'tracebacklimit', None)
    335             if limit is not None and limit < 0:
    336                 limit = 0
    337         if limit is not None:
    338             if limit >= 0:
    339                 frame_gen = itertools.islice(frame_gen, limit)
    340             else:
    341                 frame_gen = collections.deque(frame_gen, maxlen=-limit)
    342 
    343         result = klass()
    344         fnames = set()
--> 345         for f, lineno in frame_gen:
        f = undefined
        lineno = undefined
        frame_gen = <generator object walk_tb at 0x7f34aed8d150>
    346             co = f.f_code
    347             filename = co.co_filename
    348             name = co.co_name
    349 
    350             fnames.add(filename)
    351             linecache.lazycache(filename, f.f_globals)
    352             # Must defer line lookups until we have called checkcache.
    353             if capture_locals:
    354                 f_locals = f.f_locals
    355             else:
    356                 f_locals = None
    357             result.append(FrameSummary(
    358                 filename, lineno, name, lookup_line=False, locals=f_locals))
    359         for filename in fnames:
    360             linecache.checkcache(filename)

/usr/local/lib/python3.6/traceback.py in walk_tb(tb=TypeError("__init__() got an unexpected keyword argument 'column'",))
    295     ""
    296     if f is None:
    297         f = sys._getframe().f_back.f_back
    298     while f is not None:
    299         yield f, f.f_lineno
    300         f = f.f_back
    301 
    302 
    303 def walk_tb(tb):
    304     """Walk a traceback yielding the frame and line number for each frame.
    305 
    306     This will follow tb.tb_next (and thus is in the opposite order to
    307     walk_stack). Usually used with StackSummary.extract.
    308     """
    309     while tb is not None:
--> 310         yield tb.tb_frame, tb.tb_lineno
        tb.tb_frame = undefined
        tb.tb_lineno = undefined
    311         tb = tb.tb_next
    312 
    313 
    314 _RECURSIVE_CUTOFF = 3 # Also hardcoded in traceback.c.
    315 
    316 class StackSummary(list):
    317     """A stack of frames."""
    318 
    319     @classmethod
    320     def extract(klass, frame_gen, *, limit=None, lookup_lines=True,
    321             capture_locals=False):
    322         """Create a StackSummary from a traceback or stack object.
    323 
    324         :param frame_gen: A generator that yields (frame, lineno) tuples to
    325             include in the stack.
"""
AttributeError: 'TypeError' object has no attribute 'tb_frame'

Not sure if this is a bug from ipython, but I thought I'd want to let you know in case.

@Carreau
Copy link
Member

Carreau commented Sep 27, 2021

Most of those have been fixed in more recent version of IPython, though as you are on 3.6 you get the latest 3.6 compatible which is starting to be quite old and does not have those fixes.

IIRC you need to pin jedi to an earlier version (0.13.2 I believe). The stack error is fixed as well, but I don't believe there is a workaround, though if completion does not crash it should not be an issue.

@MrMino
Copy link
Member

MrMino commented Oct 23, 2021

The workaround is:

pip install jedi<=17.2

This has been fixed in #12793. We do not support 3.6 anymore, but the proposition to backport the fix is tracked under #13100.

@MrMino MrMino closed this as completed Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants