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

curtsies frontend import completion bug #263

Closed
ikanobori opened this issue Jul 4, 2014 · 2 comments
Closed

curtsies frontend import completion bug #263

ikanobori opened this issue Jul 4, 2014 · 2 comments
Labels
bug

Comments

@ikanobori
Copy link
Contributor

@ikanobori ikanobori commented Jul 4, 2014

If the following code is typed very quickly after bpython-curtsies invocation, import completion has not yet finished, and bpython crashes:
$ bpython-curtsies
>>> import os

#!python

tom-mba:~ tomb$ bpython-curtsies
>>> import o
Traceback (most recent call last):
  File "/usr/local/bin/bpython-curtsies", line 9, in <module>
    load_entry_point('bpython==mercurial', 'console_scripts', 'bpython-curtsies')()
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 51, in main
    mainloop(config, locals_, banner, interp, paste)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 88, in mainloop
    process_event(tc.get_event())
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsies.py", line 67, in process_event
    repl.process_event(e)
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 335, in process_event
    self.update_completion()
  File "/Users/tomb/Dropbox/code/bpython/bpython/curtsiesfrontend/repl.py", line 450, in update_completion
    self.list_win_visible = BpythonRepl.complete(self, tab)
  File "/Users/tomb/Dropbox/code/bpython/bpython/repl.py", line 588, in complete
    matches = importcompletion.complete(self.current_line(), cw)
  File "/Users/tomb/Dropbox/code/bpython/bpython/importcompletion.py", line 77, in complete
    for name in modules:
RuntimeError: Set changed size during iteration
tom-mba:~ tomb$

Import completion should happen in a coroutine instead of a thread, or there should be a lock around the import completion modules list that the import completion code gives up to allow keys to be pressed, or something.


@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

Fixed by PRs #35 and #34


Original Comment By:

@ikanobori
Copy link
Contributor Author

@ikanobori ikanobori commented Jul 4, 2014

I'm not sure if anything's changed, but I can't reproduce this now. The fix would preventing for name in modules from happening at the same time that it's being added to, but I can't reproduce the bug that made me think we needed this.

#!python

    matches = list()
    for name in modules:
        if not (name.startswith(cw) and name.find('.', len(cw)) == -1):
            continue
        if completing_from:
            name = name[len(tokens[1]) + 1:]
        matches.append(name)


Original Comment By:

@ikanobori ikanobori closed this Jul 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.