Skip to content

bpython-urwid on python 2 can't format tracebacks that contain non-ASCII characters #701

@glyph

Description

@glyph

Steps to reproduce:

  1. pip install bpython-urwid
  2. run bpython-urwid
  3. paste é
  4. hit enter

expected result:

A traceback about é, then another Python prompt.

Actual result:

Traceback (most recent call last):
  File "./Library/Python/2.7/bin/bpython-urwid", line 11, in <module>
    sys.exit(main())
  File ".../bpython/urwid.py", line 1317, in main
    myrepl.main_loop.screen.run_wrapper(run_with_screen_before_mainloop)
  File ".../urwid/display_common.py", line 764, in run_wrapper
    return fn()
  File ".../bpython/urwid.py", line 1268, in run_with_screen_before_mainloop
    myrepl.main_loop.run()
  File ".../urwid/main_loop.py", line 278, in run
    self._run()
  File ".../urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File ".../urwid/main_loop.py", line 682, in run
    self._loop()
  File ".../urwid/main_loop.py", line 719, in _loop
    self._watch_files[fd]()
  File ".../urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File ".../urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File ".../urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File ".../urwid/main_loop.py", line 509, in process_input
    something_handled |= bool(self.unhandled_input(k))
  File ".../urwid/main_loop.py", line 555, in unhandled_input
    return self._unhandled_input(input)
  File ".../bpython/urwid.py", line 1039, in handle_input
    self.stdout_hist += inp.encode(locale.getpreferredencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

and the interpreter exits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions