Skip to content

ValueError Crash after linebreak and entering letter #687

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
Danzelot opened this issue Jun 20, 2017 · 4 comments
Closed

ValueError Crash after linebreak and entering letter #687

Danzelot opened this issue Jun 20, 2017 · 4 comments
Labels

Comments

@Danzelot
Copy link

Danzelot commented Jun 20, 2017

I suddenly get an ValueError each time I enter a letter in a newline; even if I first enter spaces and then a letter or other symbols or digits which is possible but if I delete them and then enter a letter it crashes.
I didn't update neither my bpython nor my anaconda/python2.7 installation; only the regular Ubuntu 16.04 updates.

bpython version 0.16 on top of Python 2.7.13 /home/jd/work/miniconda3/envs/py2/bin/python
>>> help(
... 
Traceback (most recent call last):
  File "/home/jd/work/miniconda3/envs/py2/bin/bpython", line 11, in <module>
    sys.exit(main())
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsies.py", line 190, in main
    exit_value = repl.mainloop()
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsies.py", line 125, in mainloop
    self.process_event_and_paint(e)
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsies.py", line 99, in process_event_and_paint
    array, cursor_pos = self.paint()
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 1447, in paint
    if self.matches_iter.completer else None)
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 182, in paint_infobox
    if matches else [])
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 78, in matches_lines
    for i in range(0, len(matches), words_wide)]
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/curtsies/formatstring.py", line 264, in join
    for i, s in enumerate(iterable):
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 77, in <genexpr>
    for m in matches[i:i+words_wide])
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/curtsies/formatstring.py", line 628, in fmtstr
    string = FmtStr.from_str(string)
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/curtsies/formatstring.py", line 180, in from_str
    return FmtStr(Chunk(s))
  File "/home/jd/work/miniconda3/envs/py2/lib/python2.7/site-packages/curtsies/formatstring.py", line 70, in __init__
    raise ValueError("unicode string required, got %r" % string)
ValueError: unicode string required, got 'set         '

The ValueError depends on the letter entered:
For example a 'a' results in:
ValueError: unicode string required, got 'abs '

whereas a 'q' results in:
ValueError: unicode string required, got 'quit'

@rachari
Copy link

rachari commented Jul 12, 2017

I have been getting the same error for bpython version 0.16 on top of Python 2.7.5

Changing line 70 in formatstring.py from
if not isinstance(string, unicode):
to
if not isinstance(unicode(string), unicode):
gets it working.

Haven't checked if it breaks or errors out elsewhere.

This works without any changes on Python 3.x

@sebastinas
Copy link
Contributor

This is a bug in MultilineJediCompletion.

sebastinas added a commit that referenced this issue Jul 13, 2017
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
(cherry picked from commit d067b9d)
@doyard
Copy link

doyard commented Sep 13, 2017

@rachari It gets working via your solution for bpython 0.16 on top of Python 2.7.13, MacOS 10.12.6.
Thanks.

@SaravanaStorageNetwork
Copy link

I got similar error and the above helped

Changing line 70 in formatstring.py from
if not isinstance(string, unicode):
to
if not isinstance(unicode(string), unicode):
gets it working.

Traceback (most recent call last):
File "/usr/bin/bpython", line 11, in
sys.exit(main())
File "/usr/lib/python2.7/site-packages/bpython/curtsies.py", line 190, in main
exit_value = repl.mainloop()
File "/usr/lib/python2.7/site-packages/bpython/curtsies.py", line 125, in mainloop
self.process_event_and_paint(e)
File "/usr/lib/python2.7/site-packages/bpython/curtsies.py", line 99, in process_event_and_paint
array, cursor_pos = self.paint()
File "/usr/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 1447, in paint
if self.matches_iter.completer else None)
File "/usr/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 182, in paint_infobox
if matches else [])
File "/usr/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 78, in matches_lines
for i in range(0, len(matches), words_wide)]
File "/usr/lib/python2.7/site-packages/curtsies/formatstring.py", line 264, in join
for i, s in enumerate(iterable):
File "/usr/lib/python2.7/site-packages/bpython/curtsiesfrontend/replpainter.py", line 77, in
for m in matches[i:i+words_wide])
File "/usr/lib/python2.7/site-packages/curtsies/formatstring.py", line 628, in fmtstr
string = FmtStr.from_str(string)
File "/usr/lib/python2.7/site-packages/curtsies/formatstring.py", line 180, in from_str
return FmtStr(Chunk(s))
File "/usr/lib/python2.7/site-packages/curtsies/formatstring.py", line 70, in init
raise ValueError("unicode string required, got %r" % string)
ValueError: unicode string required, got 'pow

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

5 participants