The jedi upgrade (to 0.18.0) does not fix the error, but does change the 
log:



jonatha...@googlemail.com schrieb am Dienstag, 9. Februar 2021 um 21:05:20 
UTC+1:

> Actually the error is reproducible:
>
>     def foo(): return 2
>     foo()
>     foo()
>
> What makes it crash is hitting TAB after opening the parenthesis and then 
> completing it and hitting enter.
>
> Matthias Koeppe schrieb am Dienstag, 9. Februar 2021 um 17:56:31 UTC+1:
>
>> A Jupyter upgrade is in https://trac.sagemath.org/ticket/31280 - which 
>> needs some help
>>
>> On Tuesday, February 9, 2021 at 6:52:51 AM UTC-8 Dima Pasechnik wrote:
>>
>>> it looks like https://github.com/davidhalter/jedi/issues/1615 
>>> and our version of jedi is older than the fix there. 
>>> Upgrade jedi (if this is possible without a full ipython/jupyter 
>>> upgrade, don't know) ? 
>>>
>>> On Tue, Feb 9, 2021 at 1:56 PM 'jonatha...@googlemail.com' via 
>>> sage-devel <sage-...@googlegroups.com> wrote: 
>>> > 
>>> > 
>>> > Dear all, 
>>> > 
>>> > sage crashes once in a while hard with some strange error. 
>>> > 
>>> > Does anyone know what is going on? This is somewhat new. Not 
>>> reproducible. 
>>> > 
>>> > Happened to me maybe 3 or 4 times now at various occasions. 
>>> > 
>>> > Jonathan 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "sage-devel" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to sage-devel+...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sage-devel/53367a09-45ff-4ebf-bcca-88766b0b77e9n%40googlegroups.com.
>>>  
>>>
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/703602b5-2699-4a57-a71d-bfb7de676db0n%40googlegroups.com.
***************************************************************************

IPython post-mortem report

{'commit_hash': 'd0b255042',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': 
'/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython',
 'ipython_version': '7.13.0',
 'os_name': 'posix',
 'platform': 'Linux-4.19.0-10-amd64-x86_64-with-debian-10.8',
 'sys_executable': '/srv/public/kliem/sage/local/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.7.3 (default, Jul 25 2020, 13:03:44) \n[GCC 8.3.0]'}

***************************************************************************



***************************************************************************

Crash traceback:

---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeError            Python 3.7.3: /srv/public/kliem/sage/local/bin/python3
                                                   Tue Feb  9 21:09:23 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.
/srv/public/kliem/sage/src/bin/sage-ipython in <module>
      1 #!/usr/bin/env sage-python
      2 # -*- coding: utf-8 -*-
      3 """
      4 Sage IPython startup script.
      5 """
      6 
      7 # Display startup banner. Do this before anything else to give the user
      8 # early feedback that Sage is starting.
      9 from sage.misc.banner import banner
     10 banner()
     11 
     12 from sage.repl.interpreter import SageTerminalApp
     13 
     14 app = SageTerminalApp.instance()
     15 app.initialize()
---> 16 app.start()
        global app.start = <bound method TerminalIPythonApp.start of 
<sage.repl.interpreter.SageTerminalApp object at 0x7fe035932470>>

/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython/terminal/ipapp.py
 in start(self=<sage.repl.interpreter.SageTerminalApp 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 <sage.repl.interpreter.SageTerminalInteractiveShell object at 
0x7fe0358ca0b8>>
    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()

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

/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>)
    526     def ask_exit(self):
    527         self.keep_running = False
    528 
    529     rl_next_input = None
    530 
    531     def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    532 
    533         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    534             warn('interact `display_banner` argument is deprecated 
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, 
stacklevel=2)
    535 
    536         self.keep_running = True
    537         while self.keep_running:
    538             print(self.separate_in, end='')
    539 
    540             try:
--> 541                 code = self.prompt_for_code()
        code = ''
        self.prompt_for_code = <bound method 
TerminalInteractiveShell.prompt_for_code of 
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7fe0358ca0b8>>
    542             except EOFError:
    543                 if (not self.confirm_exit) \
    544                         or self.ask_yes_no('Do you really want to exit 
([y]/n)?','y','n'):
    545                     self.ask_exit()
    546 
    547             else:
    548                 if code:
    549                     self.run_cell(code, store_history=True)
    550 
    551     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    552         # An extra layer of protection in case someone mashing Ctrl-C 
breaks
    553         # out of our internal code.
    554         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    555             warn('mainloop `display_banner` argument is deprecated 
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, 
stacklevel=2)
    556         while True:

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

/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 0x7fddafd942f0>))], 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)
    979             self.tempfile_suffix = tempfile_suffix
    980         if tempfile is not None:
    981             self.tempfile = tempfile
    982 
    983         self._add_pre_run_callables(pre_run, accept_default)
    984         self.default_buffer.reset(
    985             default if isinstance(default, Document) else 
Document(default)
    986         )
    987         self.app.refresh_interval = self.refresh_interval  # This is 
not reactive.
    988 
    989         # If we are using the default output, and have a dumb terminal. 
Use the
    990         # dumb prompt.
    991         if self._output is None and is_dumb_terminal():
    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)
        self.app.run = <bound method Application.run of 
<prompt_toolkit.application.application.Application object at 0x7fe0323de940>>
        set_exception_handler = True
    995 
    996     async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:
    997         """
    998         Prompt function for dumb terminals.
    999 
   1000         Dumb terminals have minimum rendering capabilities. We can only 
print
   1001         text to the screen. We can't use colors, and we can't do cursor
   1002         movements. The Emacs inferior shell is an example of a dumb 
terminal.
   1003 
   1004         We will show the prompt, and wait for the input. We still 
handle arrow
   1005         keys, and all custom key bindings, but we don't really render 
the
   1006         cursor movements. Instead we only print the typed character 
that's
   1007         right before the cursor.
   1008         """
   1009         # Send prompt to output.

/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)
    797         # We don't create a new event loop by default, because we want 
to be
    798         # sure that when this is called multiple times, each call of 
`run()`
    799         # goes through the same event loop. This way, users can schedule
    800         # background-tasks that keep running across multiple prompts.
    801         try:
    802             loop = get_event_loop()
    803         except RuntimeError:
    804             # Possibly we are not running in the main thread, where no 
event
    805             # loop is set by default. Or somebody called `asyncio.run()`
    806             # before, which closes the existing event loop. We can 
create a new
    807             # loop.
    808             loop = new_event_loop()
    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)
        self.run_async = <bound method Application.run_async of 
<prompt_toolkit.application.application.Application object at 0x7fe0323de940>>
        pre_run = None
        set_exception_handler = True
    813         )
    814 
    815     def _handle_exception(
    816         self, loop: AbstractEventLoop, context: Dict[str, Any]
    817     ) -> None:
    818         """
    819         Handler for event loop exceptions.
    820         This will print the exception, using run_in_terminal.
    821         """
    822         # For Python 2: we have to get traceback at this point, because
    823         # we're still in the 'except:' block of the event loop where the
    824         # traceback is still available. Moving this code in the
    825         # 'print_exception' coroutine will loose the exception.
    826         tb = get_traceback_from_context(context)
    827         formatted_tb = "".join(format_tb(tb))

/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...() got 
an unexpected keyword argument 'column'")>)
    569         future.add_done_callback(_run_until_complete_cb)
    570         try:
    571             self.run_forever()
    572         except:
    573             if new_task and future.done() and not future.cancelled():
    574                 # The coroutine raised a BaseException. Consume the 
exception
    575                 # to not log a warning, the caller doesn't have access 
to the
    576                 # local task.
    577                 future.exception()
    578             raise
    579         finally:
    580             future.remove_done_callback(_run_until_complete_cb)
    581         if not future.done():
    582             raise RuntimeError('Event loop stopped before Future 
completed.')
    583 
--> 584         return future.result()
        future.result = <built-in method result of _asyncio.Task object at 
0x7fddafe334a8>
    585 
    586     def stop(self):
    587         """Stop running the event loop.
    588 
    589         Every callback already scheduled will still run.  This simply 
informs
    590         run_forever to stop looping after a complete iteration.
    591         """
    592         self._stopping = True
    593 
    594     def close(self):
    595         """Close the event loop.
    596 
    597         This clears the queues and shuts down the executor,
    598         but does not wait for the executor to finish.
    599 

/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)
    763                         # go in the finally! If `_run_async` raises
    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
    769                         # happened already in the finally block in 
`run_async`
    770                         # above, but in case of exceptions, that's not 
always the
    771                         # case.
    772                         self._is_running = False
    773                     return result
    774             finally:
    775                 if set_exception_handler:
    776                     loop.set_exception_handler(previous_exc_handler)
    777 
--> 778         return await _run_async2()
        _run_async2 = <function Application.run_async.<locals>._run_async2 at 
0x7fddafd28598>
    779 
    780     def run(
    781         self,
    782         pre_run: Optional[Callable[[], None]] = None,
    783         set_exception_handler: bool = True,
    784     ) -> _AppResult:
    785         """
    786         A blocking 'run' call that waits until the UI is finished.
    787 
    788         This will start the current asyncio event loop. If no loop is 
set for
    789         the current thread, then it will create a new loop.
    790 
    791         :param pre_run: Optional callable, which is called right after 
the
    792             "reset" of the application.
    793         :param set_exception_handler: When set, in case of an 
exception, go out

/srv/public/kliem/sage/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py
 in _run_async2()
    751 
    752             loop = get_event_loop()
    753             if set_exception_handler:
    754                 previous_exc_handler = loop.get_exception_handler()
    755                 loop.set_exception_handler(self._handle_exception)
    756 
    757             try:
    758                 with set_app(self):
    759                     try:
    760                         result = await _run_async()
    761                     finally:
    762                         # Wait for the background tasks to be done. 
This needs to
    763                         # go in the finally! If `_run_async` raises
    764                         # `KeyboardInterrupt`, we still want to wait 
for the
    765                         # background tasks.
--> 766                         await 
self.cancel_and_wait_for_background_tasks()
        global self.cancel_and_wait_for_background_tasks = undefined
    767 
    768                         # Set the `_is_running` flag to `False`. 
Normally this
    769                         # happened already in the finally block in 
`run_async`
    770                         # above, but in case of exceptions, that's not 
always the
    771                         # case.
    772                         self._is_running = False
    773                     return result
    774             finally:
    775                 if set_exception_handler:
    776                     loop.set_exception_handler(previous_exc_handler)
    777 
    778         return await _run_async2()
    779 
    780     def run(
    781         self,

/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>)
    852 
    853     async def cancel_and_wait_for_background_tasks(self) -> None:
    854         """
    855         Cancel all background tasks, and wait for the cancellation to 
be done.
    856         If any of the background tasks raised an exception, this will 
also
    857         propagate the exception.
    858 
    859         (If we had nurseries like Trio, this would be the `__aexit__` 
of a
    860         nursery.)
    861         """
    862         for task in self.background_tasks:
    863             task.cancel()
    864 
    865         for task in self.background_tasks:
    866             try:
--> 867                 await task
        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=TypeError("__init__() got an unexpected keyword argument 'column'")>
    868             except CancelledError:
    869                 pass
    870 
    871     def cpr_not_supported_callback(self) -> None:
    872         """
    873         Called when we don't receive the cursor position response in 
time.
    874         """
    875         if not self.input.responds_to_cpr:
    876             return  # We know about this already.
    877 
    878         def in_terminal() -> None:
    879             self.output.write(
    880                 "WARNING: your terminal doesn't support cursor position 
requests (CPR).\r\n"
    881             )
    882             self.output.flush()

/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})
   1839     running = False
   1840 
   1841     @wraps(coroutine)
   1842     async def new_coroutine(*a: Any, **kw: Any) -> Any:
   1843         nonlocal running
   1844 
   1845         # Don't start a new function, if the previous is still in 
progress.
   1846         if running:
   1847             return
   1848 
   1849         running = True
   1850 
   1851         try:
   1852             while True:
   1853                 try:
-> 1854                     await coroutine(*a, **kw)
        global coroutine = undefined
        a = ()
        kw = {'select_first': False, 'select_last': False, 
'insert_common_part': True, 'complete_event': 
CompleteEvent(text_inserted=False, completion_requested=True)}
   1855                 except _Retry:
   1856                     continue
   1857                 else:
   1858                     return None
   1859         finally:
   1860             running = False
   1861 
   1862     return cast(_T, new_coroutine)
   1863 
   1864 
   1865 class _Retry(Exception):
   1866     " Retry in `_only_one_at_a_time`. "
   1867 
   1868 
   1869 def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) 
-> None:

/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))
   1669 
   1670             # Don't complete when we already have completions.
   1671             if self.complete_state or not self.completer:
   1672                 return
   1673 
   1674             # Create an empty CompletionState.
   1675             complete_state = 
CompletionState(original_document=self.document)
   1676             self.complete_state = complete_state
   1677 
   1678             def proceed() -> bool:
   1679                 """ Keep retrieving completions. Input text has not yet 
changed
   1680                 while generating completions. """
   1681                 return self.complete_state == complete_state
   1682 
   1683             async for completion in 
self.completer.get_completions_async(
-> 1684                 document, complete_event
        document = Document('foo', 3)
        complete_event = CompleteEvent(text_inserted=False, 
completion_requested=True)
   1685             ):
   1686                 complete_state.completions.append(completion)
   1687                 self.on_completions_changed.fire()
   1688 
   1689                 # If the input text changes, abort.
   1690                 if not proceed():
   1691                     break
   1692 
   1693             completions = complete_state.completions
   1694 
   1695             # When there is only one completion, which has nothing to 
add, ignore it.
   1696             if len(completions) == 1 and completion_does_nothing(
   1697                 document, completions[0]
   1698             ):
   1699                 del completions[:]

/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 0x7fe032522e48>), 
document=Document('foo', 3), complete_event=CompleteEvent(text_inserted=False, 
completion_requested=True))
    255     def __init__(self, get_completer: Callable[[], 
Optional[Completer]]) -> None:
    256         self.get_completer = get_completer
    257 
    258     def get_completions(
    259         self, document: Document, complete_event: CompleteEvent
    260     ) -> Iterable[Completion]:
    261         completer = self.get_completer() or DummyCompleter()
    262         return completer.get_completions(document, complete_event)
    263 
    264     async def get_completions_async(
    265         self, document: Document, complete_event: CompleteEvent
    266     ) -> AsyncGenerator[Completion, None]:
    267         completer = self.get_completer() or DummyCompleter()
    268 
    269         async for completion in completer.get_completions_async(
--> 270             document, complete_event
        document = Document('foo', 3)
        complete_event = CompleteEvent(text_inserted=False, 
completion_requested=True)
    271         ):
    272             yield completion
    273 
    274     def __repr__(self) -> str:
    275         return "DynamicCompleter(%r -> %r)" % (self.get_completer, 
self.get_completer())
    276 
    277 
    278 class _MergedCompleter(Completer):
    279     """
    280     Combine several completers into one.
    281     """
    282 
    283     def __init__(self, completers: Sequence[Completer]) -> None:
    284         self.completers = completers
    285 

/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('foo', 3), 
complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
    181         :param document: :class:`~prompt_toolkit.document.Document` 
instance.
    182         :param complete_event: :class:`.CompleteEvent` instance.
    183         """
    184         while False:
    185             yield
    186 
    187     async def get_completions_async(
    188         self, document: Document, complete_event: CompleteEvent
    189     ) -> AsyncGenerator[Completion, None]:
    190         """
    191         Asynchronous generator for completions. (Probably, you won't 
have to
    192         override this.)
    193 
    194         Asynchronous generator of :class:`.Completion` objects.
    195         """
--> 196         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 0x7fe032522e48>>
        document = Document('foo', 3)
        complete_event = CompleteEvent(text_inserted=False, 
completion_requested=True)
    197             yield item
    198 
    199 
    200 class ThreadedCompleter(Completer):
    201     """
    202     Wrapper that runs the `get_completions` generator in a thread.
    203 
    204     (Use this to prevent the user interface from becoming unresponsive 
if the
    205     generation of completions takes too much time.)
    206 
    207     The completions will be displayed as soon as they are produced. The 
user
    208     can already select a completion, even if not all completions are 
displayed.
    209     """
    210 
    211     def __init__(self, completer: Completer) -> None:

/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('foo', 3), complete_event=CompleteEvent(text_inserted=False, 
completion_requested=True))
     77             return self.shell.Completer
     78 
     79     def get_completions(self, document, complete_event):
     80         if not document.current_line.strip():
     81             return
     82         # Some bits of our completion system may print stuff (e.g. if a 
module
     83         # is imported). This context manager ensures that doesn't 
interfere with
     84         # the prompt.
     85 
     86         with patch_stdout(), provisionalcompleter():
     87             body = document.text
     88             cursor_row = document.cursor_position_row
     89             cursor_col = document.cursor_position_col
     90             cursor_position = document.cursor_position
     91             offset = cursor_to_position(body, cursor_row, cursor_col)
---> 92             yield from self._get_completions(body, offset, 
cursor_position, self.ipy_completer)
        self._get_completions = <function IPythonPTCompleter._get_completions 
at 0x7fe03428b378>
        body = 'foo'
        offset = 3
        cursor_position = 3
        self.ipy_completer = <IPython.core.completer.IPCompleter object at 
0x7fe0340d22e8>
     93 
     94     @staticmethod
     95     def _get_completions(body, offset, cursor_position, ipyc):
     96         """
     97         Private equivalent of get_completions() use only for 
unit_testing.
     98         """
     99         debug = getattr(ipyc, 'debug', False)
    100         completions = _deduplicate_completions(
    101             body, ipyc.completions(body, offset))
    102         for c in completions:
    103             if not c.text:
    104                 # Guard against completion machinery giving us an empty 
string.
    105                 continue
    106             text = unicodedata.normalize('NFC', c.text)
    107             # When the first character of the completion has a zero 
length,

/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython/terminal/ptutils.py
 in _get_completions(body='foo', offset=3, cursor_position=3, 
ipyc=<IPython.core.completer.IPCompleter object>)
     87             body = document.text
     88             cursor_row = document.cursor_position_row
     89             cursor_col = document.cursor_position_col
     90             cursor_position = document.cursor_position
     91             offset = cursor_to_position(body, cursor_row, cursor_col)
     92             yield from self._get_completions(body, offset, 
cursor_position, self.ipy_completer)
     93 
     94     @staticmethod
     95     def _get_completions(body, offset, cursor_position, ipyc):
     96         """
     97         Private equivalent of get_completions() use only for 
unit_testing.
     98         """
     99         debug = getattr(ipyc, 'debug', False)
    100         completions = _deduplicate_completions(
    101             body, ipyc.completions(body, offset))
--> 102         for c in completions:
        c = undefined
        completions = <generator object _deduplicate_completions at 
0x7fddafce8408>
    103             if not c.text:
    104                 # Guard against completion machinery giving us an empty 
string.
    105                 continue
    106             text = unicodedata.normalize('NFC', c.text)
    107             # When the first character of the completion has a zero 
length,
    108             # then it's probably a decomposed unicode character. E.g. 
caused by
    109             # the "\dot" completion. Try to compose again with the 
previous
    110             # character.
    111             if wcwidth(text[0]) == 0:
    112                 if cursor_position + c.start > 0:
    113                     char_before = body[c.start - 1]
    114                     fixed_text = unicodedata.normalize(
    115                         'NFC', char_before + text)
    116 
    117                     # Yield the modified completion instead, if this 
worked.

/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython/core/completer.py
 in _deduplicate_completions(text='foo', completions=<generator object 
IPCompleter.completions>)
    423         iterator over the completions to deduplicate
    424 
    425     Yields
    426     ------
    427     `Completions` objects
    428 
    429 
    430     Completions coming from multiple sources, may be different but end 
up having
    431     the same effect when applied to ``text``. If this is the case, this 
will
    432     consider completions as equal and only emit the first encountered.
    433 
    434     Not folded in `completions()` yet for debugging purpose, and to 
detect when
    435     the IPython completer does return things that Jedi does not, but 
should be
    436     at some point.
    437     """
--> 438     completions = list(completions)
        completions = <generator object IPCompleter.completions at 
0x7fddafce8390>
        global list = undefined
    439     if not completions:
    440         return
    441 
    442     new_start = min(c.start for c in completions)
    443     new_end = max(c.end for c in completions)
    444 
    445     seen = set()
    446     for c in completions:
    447         new_text = text[new_start:c.start] + c.text + 
text[c.end:new_end]
    448         if new_text not in seen:
    449             yield c
    450             seen.add(new_text)
    451 
    452 
    453 def rectify_completions(text: str, completions: _IC, *, 
_debug=False)->_IC:

/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython/core/completer.py
 in completions(self=<IPython.core.completer.IPCompleter object>, text='foo', 
offset=3)
   1804             and usual IPython completion.
   1805 
   1806         .. note::
   1807 
   1808             Completions are not completely deduplicated yet. If 
identical
   1809             completions are coming from different sources this function 
does not
   1810             ensure that each completion object will only be present 
once.
   1811         """
   1812         warnings.warn("_complete is a provisional API (as of IPython 
6.0). "
   1813                       "It may change without warnings. "
   1814                       "Use in corresponding context manager.",
   1815                       category=ProvisionalCompleterWarning, 
stacklevel=2)
   1816 
   1817         seen = set()
   1818         try:
-> 1819             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 0x7fe0340d22e8>>
        text = 'foo'
        offset = 3
        global _timeout = undefined
        self.jedi_compute_type_timeout = 400
   1820                 if c and (c in seen):
   1821                     continue
   1822                 yield c
   1823                 seen.add(c)
   1824         except KeyboardInterrupt:
   1825             """if completions take too long and users send keyboard 
interrupt,
   1826             do not crash and return ASAP. """
   1827             pass
   1828 
   1829     def _completions(self, full_text: str, offset: int, *, 
_timeout)->Iterator[Completion]:
   1830         """
   1831         Core completion module.Same signature as :any:`completions`, 
with the
   1832         extra `timeout` parameter (in seconds).
   1833 
   1834 

/srv/public/kliem/sage/local/lib/python3.7/site-packages/IPython/core/completer.py
 in _completions(self=<IPython.core.completer.IPCompleter object>, 
full_text='foo', offset=3, _timeout=0.4)
   1848         be marked as "unknown" an will have a chance to be computed 
next round
   1849         are things get cached.
   1850 
   1851         Keep in mind that Jedi is not the only thing treating the 
completion so
   1852         keep the timeout short-ish as if we take more than 0.3 second 
we still
   1853         have lots of processing to do.
   1854 
   1855         """
   1856         deadline = time.monotonic() + _timeout
   1857 
   1858 
   1859         before = full_text[:offset]
   1860         cursor_line, cursor_column = position_to_cursor(full_text, 
offset)
   1861 
   1862         matched_text, matches, matches_origin, jedi_matches = 
self._complete(
-> 1863             full_text=full_text, cursor_line=cursor_line, 
cursor_pos=cursor_column)
        full_text = 'foo'
        cursor_line = 0
        global cursor_pos = undefined
        cursor_column = 3
   1864 
   1865         iter_jm = iter(jedi_matches)
   1866         if _timeout:
   1867             for jm in iter_jm:
   1868                 try:
   1869                     type_ = jm.type
   1870                 except Exception:
   1871                     if self.debug:
   1872                         print("Error in Jedi getting type of ", jm)
   1873                     type_ = None
   1874                 delta = len(jm.name_with_symbols) - len(jm.complete)
   1875                 if type_ == 'function':
   1876                     signature = _make_signature(jm)
   1877                 else:
   1878                     signature = ''

/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=3, line_buffer='foo', text='foo', full_text='foo')
   2016                 origins = [matcher.__qualname__] * len(matches)
   2017                 return text, matches, origins, ()
   2018 
   2019         # Start with a clean slate of completions
   2020         matches = []
   2021         
   2022         # FIXME: we should extend our api to return a dict with 
completions for
   2023         # different types of objects.  The rlcomplete() method could 
then
   2024         # simply collapse the dict into a list for readline, but we'd 
have
   2025         # richer completion semantics in other environments.
   2026         completions = ()
   2027         if self.use_jedi:
   2028             if not full_text:
   2029                 full_text = line_buffer
   2030             completions = self._jedi_matches(
-> 2031                 cursor_pos, cursor_line, full_text)
        cursor_pos = 3
        cursor_line = 0
        full_text = 'foo'
   2032                 
   2033         if self.merge_completions:
   2034             matches = []
   2035             for matcher in self.matchers:
   2036                 try:
   2037                     matches.extend([(m, matcher.__qualname__)
   2038                                     for m in matcher(text)])
   2039                 except:
   2040                     # Show the ugly traceback if the matcher causes an
   2041                     # exception, but do NOT crash the kernel!
   2042                     sys.excepthook(*sys.exc_info())
   2043         else:
   2044             for matcher in self.matchers:
   2045                 matches = [(m, matcher.__qualname__)
   2046                             for m in matcher(text)]

/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=3, cursor_line=0, text='foo')
   1359         offset = cursor_to_position(text, cursor_line, cursor_column)
   1360         # filter output if we are completing for object members
   1361         if offset:
   1362             pre = text[offset-1]
   1363             if pre == '.':
   1364                 if self.omit__names == 2:
   1365                     completion_filter = lambda c:not 
c.name.startswith('_')
   1366                 elif self.omit__names == 1:
   1367                     completion_filter = lambda c:not 
(c.name.startswith('__') and c.name.endswith('__'))
   1368                 elif self.omit__names == 0:
   1369                     completion_filter = lambda x:x
   1370                 else:
   1371                     raise ValueError("Don't understand self.omit__names 
== {}".format(self.omit__names))
   1372 
   1373         interpreter = jedi.Interpreter(
-> 1374             text[:offset], namespaces, column=cursor_column, 
line=cursor_line + 1)
        text = 'foo'
        offset = 3
        namespaces = undefined
        global column = undefined
        cursor_column = 3
        global line = undefined
        cursor_line = 0
   1375         try_jedi = True
   1376 
   1377         try:
   1378             # find the first token in the current tree -- if it is a ' 
or " then we are in a string
   1379             completing_string = False
   1380             try:
   1381                 first_child = next(c for c in 
interpreter._get_module().tree_node.children if hasattr(c, 'value'))
   1382             except StopIteration:
   1383                 pass
   1384             else:
   1385                 # note the value may be ', ", or it may also be ''' or 
""", or
   1386                 # in some cases, """what/you/typed..., but all of these 
are
   1387                 # strings.
   1388                 completing_string = len(first_child.value) > 0 and 
first_child.value[0] in {"'", '"'}
   1389 

/srv/public/kliem/sage/local/lib/python3.7/site-packages/jedi/api/__init__.py 
in __init__(self=<class 'jedi.api.Interpreter'> instance, code='foo', 
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': 3, 'line': 1})
    711 
    712     def __init__(self, code, namespaces, **kwds):
    713         try:
    714             namespaces = [dict(n) for n in namespaces]
    715         except Exception:
    716             raise TypeError("namespaces must be a non-empty list of 
dicts.")
    717 
    718         environment = kwds.get('environment', None)
    719         if environment is None:
    720             environment = InterpreterEnvironment()
    721         else:
    722             if not isinstance(environment, InterpreterEnvironment):
    723                 raise TypeError("The environment needs to be an 
InterpreterEnvironment subclass.")
    724 
    725         super().__init__(code, environment=environment,
--> 726                          project=Project(Path.cwd()), **kwds)
        global project = <module 'jedi.api.project' from 
'/srv/public/kliem/sage/local/lib/python3.7/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': 3, 'line': 1}
    727         self.namespaces = namespaces
    728         self._inference_state.allow_descriptor_getattr = 
self._allow_descriptor_getattr_default
    729 
    730     @cache.memoize_method
    731     def _get_module_context(self):
    732         tree_module_value = ModuleValue(
    733             self._inference_state, self._module_node,
    734             file_io=KnownContentFileIO(str(self.path), self._code),
    735             string_names=('__main__',),
    736             code_lines=self._code_lines,
    737         )
    738         return interpreter.MixedModuleContext(
    739             tree_module_value,
    740             self.namespaces,
    741         )

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

***************************************************************************

History of session input:def foo(): return Integer(2)foo()??foo()foo()
*** Last line of input (may not be in above history):
foo()

Reply via email to