Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unicode characters in docsrting crash bpython #108

Copy link
Copy link

Description

@ikanobori
Issue body actions

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.


Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.