mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 12:04:10 +00:00
[#3199|Console] Fix UnicodeEncodeError in addstr
The following error was encountered by user: ...deluge/ui/console/modes/basemode.py, line 290, in add_string screen.addstr(row, col, string, color) UnicodeEncodeError: 'ascii' codec can't encode character... The `add_str` method is defaulting to using the Python 2 ascii encoding with a unicode string so use the encoding passed to the function.
This commit is contained in:
parent
9e7c9fc1d3
commit
1838403e3b
@ -299,7 +299,7 @@ def add_string(
|
||||
string = string[0:remaining_chrs]
|
||||
|
||||
try:
|
||||
screen.addstr(row, col, string, color)
|
||||
screen.addstr(row, col, string.encode(encoding), color)
|
||||
except curses.error as ex:
|
||||
# Ignore exception for writing offscreen.
|
||||
pass
|
||||
|
@ -548,7 +548,7 @@ class CmdLine(BaseMode, Commander):
|
||||
# This is the last string so lets append some " " to it
|
||||
s += ' ' * (self.cols - (col + strwidth(s)) - 1)
|
||||
try:
|
||||
self.stdscr.addstr(row, col, s, color)
|
||||
self.stdscr.addstr(row, col, s.encode(self.encoding), color)
|
||||
except curses.error:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user