Opened 15 years ago

Closed 15 years ago

#1140 closed patch (Fixed)

Console ui "add" autocomplete crashes on unicode filename

Reported by: nullie Owned by:
Priority: major Milestone: 1.3
Component: Console UI Version: 1.2.0
Keywords: Cc:

Description

Console ui crashes then I try to list options for add command autocomplete and directory contains unicode filenames, i.e.:

add /path/to/directory/with/unicode/entries/ <TAB> <TAB>

Traceback:

[ERROR   ] 23:17:28 screen:300 'ascii' codec can't decode byte 0xd0 in position 13: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/screen.py", line 298, in doRead
    self._doRead()
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/screen.py", line 337, in _doRead
    self.input, self.input_cursor = self.tab_completer(self.input, self.input_cursor, second_hit)
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/main.py", line 377, in tab_completer
    self.write(match)
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/main.py", line 268, in write
    self.screen.add_line(line, not self.batch_write)
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/screen.py", line 193, in add_line
    line_length = colors.get_line_length(line)
  File "/home/nullie/work/deluge/trunk/deluge/ui/console/colors.py", line 129, in get_line_length
    line = line.encode(encoding, "replace")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 13: ordinal not in range(128)

That happens because os.listdir in deluge/ui/console/commands/add.py:94 gets encoded string, so it returns encoded strings as result, and screen.py doesn't handle encoded strings.

I could fix this, but don't know where should I do decoding (or make screen accept encoded strings).

Attachments (1)

unicode_input.diff (2.2 KB ) - added by nullie 15 years ago.
Add unicode input support

Download all attachments as: .zip

Change History (6)

comment:1 by nullie, 15 years ago

Looks like it's broader problem, console doesn't support unicode input too

by nullie, 15 years ago

Attachment: unicode_input.diff added

Add unicode input support

comment:2 by nullie, 15 years ago

I've added a patch for unicode input support, it fixes autocompletion too. Don't know if it's correct though.

comment:3 by Calum, 15 years ago

Component: otherconsole
Milestone: 1.3.0

comment:4 by Calum, 15 years ago

Type: defectpatch

comment:5 by Damien Churchill, 15 years ago

Resolution: fixed
Status: newclosed

Applied to master, thanks!

Note: See TracTickets for help on using tickets.