rjw57 / yt

Experiments with the YouTube API
MIT License
83 stars 25 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte #10

Open KristianKarl-zz opened 11 years ago

KristianKarl-zz commented 11 years ago

When searching using Swedish characters, yt crashes.

1) Start yt 2) Press s, and enter search string Södertälje, press enter

Expected result: A list if videos

Actual result: A stack trace...

[krikar@krikar-thinkpad yt]$ yt
Traceback (most recent call last):
  File "/usr/bin/yt", line 9, in <module>
    load_entry_point('whitey==0.3', 'console_scripts', 'yt')()
  File "/usr/lib/python2.7/site-packages/whitey-0.3-py2.7.egg/yt/__init__.py", line 31, in main
    ui.run()
  File "/usr/lib/python2.7/site-packages/whitey-0.3-py2.7.egg/yt/__init__.py", line 84, in run
    curses.wrapper(self._curses_main)
  File "/usr/lib64/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python2.7/site-packages/whitey-0.3-py2.7.egg/yt/__init__.py", line 128, in _curses_main
    self._run_pager()
  File "/usr/lib/python2.7/site-packages/whitey-0.3-py2.7.egg/yt/__init__.py", line 219, in _run_pager
    self._update_screen()
  File "/usr/lib/python2.7/site-packages/whitey-0.3-py2.7.egg/yt/__init__.py", line 191, in _update_screen
    self._status_bar.addstr(0, 0, truncate(self._status, w-1).encode(self._code))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 28: ordinal not in range(128)

Installed yt using Github Master branch, latest commit f1ab093017c5d030aac8e6c0d04e82558f04d915

CalumJEadie commented 11 years ago

Thank you for the thorough and structured issue.

I'm not going to be able to look into this for a little while however will keep it open and hope to address it in the future. If you get a chance to look into it we would really appreciate the contribution.

From the stack trace it looks like it is specific to curses rather than the YouTube API.

Calum

parkerlreed commented 10 years ago

The reason for this is not using a UTF-8 locale. Changing your system locale to something like en_US.UTF-8 fixes this error.

Platway commented 10 years ago

I met a similar problem white trying to search with a keyword in Chinese, using the latest Whitey-0.4

dyguan372 commented 5 years ago

I update it to python 3, which solves these encoding problems. The forked version is in https://github.com/dyguan372/yt.