Skip to content

bpython crashs on large dicts as default parameter #41

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

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

bpython crashs on large dicts as default parameter #41

ikanobori opened this issue Jul 4, 2014 · 3 comments
Labels

Comments

@ikanobori
Copy link
Contributor

when bpython tries to autocomplete function arguments and a default value for an argument is a very large dictionary, bpython crashs with "error: addstr() returned ERR" (curses, too long line?).
http://paste.pocoo.org/show/124117/

i just found one case where this happens:

import cgi;
cgi.parse( <CRASH>

this function uses //os.environ// as a default value for an argument, which is //probably// very long.
in the help pages the dict is elided ("..." in the middle of the repr):

parse(fp=None, environ={'XAUTHORITY': '/home/user/.Xauthority', 'GLADE_...*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:'}, keep_blank_values=0, strict_parsing=0)

in the source code (/usr/lib/python2.6/cgi.py) it looks like this:

def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0)

(happens with latest version from bitbucket)


@ikanobori
Copy link
Contributor Author

Hi hagg,

The two issues were entirely unrelated - one was something stupid I'd done with my introduction of docstring display stuff, the other was something that had always puzzled me about cgi.parse, I didn't bother to check what its signature was and, of course, os.environ will be expanded.

Anyway, both issues are fixed in the current tip - I now parse the original source code to display the arg name if it's anything strange.

Thanks for reporting.


Original Comment By:

@ikanobori
Copy link
Contributor Author

well, not exactly the same:
{{{
Traceback (most recent call last):
File "build/bdist.linux-i686/egg/bpython/cli.py", line 2071, in main
o = curses.wrapper(main_curses, exec_args, options.interactive)
File "/usr/lib/python2.6/curses/wrapper.py", line 44, in wrapper
return func(stdscr, _args, *_kwds)
File "build/bdist.linux-i686/egg/bpython/cli.py", line 2013, in main_curses
repl.repl()
File "build/bdist.linux-i686/egg/bpython/cli.py", line 1109, in repl
inp = self.get_line()
File "build/bdist.linux-i686/egg/bpython/cli.py", line 1665, in get_line
if self.p_key() is None:
File "build/bdist.linux-i686/egg/bpython/cli.py", line 1449, in p_key
self.addstr(self.c)
File "build/bdist.linux-i686/egg/bpython/cli.py", line 1524, in addstr
self.complete()
File "build/bdist.linux-i686/egg/bpython/cli.py", line 590, in complete
self.list_win_visible = self._complete(tab)
File "build/bdist.linux-i686/egg/bpython/cli.py", line 653, in _complete
self.show_list(self.matches, self.argspec)
File "build/bdist.linux-i686/egg/bpython/cli.py", line 760, in show_list
self.list_win.addstr(docstring_string, get_colpair('comment'))
error: addstr() returned ERR
}}}

when typing
{{{
x = range(10)
x.iter(
}}}

this is triggered by printing the docstr. maybe it's not a too long line, but a too long comment. but i think this is the same bug, so i just added a comment instead of a new issue.


Original Comment By:

@ikanobori
Copy link
Contributor Author

same crash happens when typing
{{{
type(
}}}
in bpython


Original Comment By:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant