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

Uncaught exception by repl.complete #776

Closed
BenWiederhake opened this issue Jul 15, 2019 · 0 comments
Closed

Uncaught exception by repl.complete #776

BenWiederhake opened this issue Jul 15, 2019 · 0 comments

Comments

@BenWiederhake
Copy link

BenWiederhake commented Jul 15, 2019

When generating completions, bpython has to interact with the given objects. These objects might be the product of active development, so a bug in, for example, __getattribute__ of the user code happens sometimes. bpython should stomach such errors.

Minimal reproducing example:

$ bpython3
bpython version 0.17.1 on top of Python 3.7.3 /usr/bin/python3
>>> class BadClass:
...     def __getattribute__(self, name):
...         assert False, "Let's say there is a bug here."
... 
>>> x = BadClass()
>>> x(
Traceback (most recent call last):
  File "/usr/bin/bpython3", line 11, in <module>
    load_entry_point('bpython==0.17.1', 'console_scripts', 'bpython')()
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 191, in main
    exit_value = repl.mainloop(True, paste)
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 126, in mainloop
    self.process_event_and_paint(e)
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 90, in process_event_and_paint
    self.process_event(e)
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 603, in process_event
    return self.process_key_event(e)
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 757, in process_key_event
    self.add_normal_character(e)
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 1001, in add_normal_character
    self.cursor_offset += 1
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 1594, in _set_cursor_offset
    self.update_completion()
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 1032, in update_completion
    self.list_win_visible = self.complete(tab)
  File "/usr/lib/python3/dist-packages/bpython/repl.py", line 724, in complete
    self.set_docstring()
  File "/usr/lib/python3/dist-packages/bpython/repl.py", line 688, in set_docstring
    if not self.get_args():
  File "/usr/lib/python3/dist-packages/bpython/repl.py", line 635, in get_args
    if inspect.isclass(f):
  File "/usr/lib/python3.7/inspect.py", line 78, in isclass
    return isinstance(object, type)
  File "<bpython-input-5>", line 3, in __getattribute__
AssertionError: Let's say there is a bug here.
[$? = 1]

In the above session, I typed the (, but it did not appear on screen. (Boo me, I edited that part.)

I see two ways to fix this: Either wrap the code in complete in a try … finally, or wrap all the places where user code gets called. (This might be hard to find.)

None of the other issues seem to be related.

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

1 participant