Skip to content

Unicode characters in docsrting crash bpython #108

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 · 4 comments
Closed

Unicode characters in docsrting crash bpython #108

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

Comments

@ikanobori
Copy link
Contributor

Hi! Thanks for the excellent interpreter.

I found that if somebody uses unicode symbols in his/her classes and methods then BPython crashes when it tries to print the docstring.

Here's example:

#!python


# -*- coding: utf-8 -*-


class A(object):
    u'''
    some class
    '''

    def __init__(self):
        u'''constructor'''
        pass

    def work(self):
        u'''
        English comment
        '''
        return True

    def fail(self):
        u'''
        Русский текст   ==   Russian text.
        '''
        return True

You may successfully init class A and invoke method work.
But as soon as you type

A.fail(
bpython will fail with error:

#!python


Traceback (most recent call last):
  File "/opt/local/bin/bpython-2.6", line 8, in <module>
    load_entry_point('bpython==0.9.5.1', 'console_scripts', 'bpython')()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 2300, in main
    locals_)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 2166, in curses_wrapper
    return func(stdscr, *args, * *kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 2229, in main_curses
    repl.repl()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 1210, in repl
    inp = self.get_line()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 1854, in get_line
    if self.p_key(key) is None:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 1589, in p_key
    self.addstr(key)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 1687, in addstr
    self.complete()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 614, in complete
    self.list_win_visible = self._complete(tab)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 705, in _complete
    self.show_list(self.matches, self.argspec)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/bpython/cli.py", line 825, in show_list
    self.list_win.addstr('\n' + docstring_string, get_colpair('comment'))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-9: ordinal not in range(128)

Thank you.

System MacOS 10.6
bpython-2.6 is installed from macports.


@ikanobori
Copy link
Contributor Author

Fixed in <<changeset 49fbd1ac1d22>>. Thanks for reporting!


Original Comment By: Andreas Stührk

@ikanobori
Copy link
Contributor Author

Thank you :)


Original Comment By:

@ikanobori
Copy link
Contributor Author

macports contains bpython 0.9.5.1 but the bug is still present in tip so I'll confirm this one :-)


Original Comment By: Simon de Vlieger

@ikanobori
Copy link
Contributor Author

Oh dear.

I hope this will be fixed when we switch to urwid ...

spaseba :)


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