manolomartinez / greg

A command-line podcast aggregator
GNU General Public License v3.0
297 stars 37 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 33: ordinal not in range(128) #61

Open jbothma opened 8 years ago

jbothma commented 8 years ago
[jdb@alarmpi ~]$ greg add TEDTalks http://feeds.feedburner.com/TEDTalks_audio
Traceback (most recent call last):
  File "/home/jdb/.local/bin/greg", line 11, in <module>
    sys.exit(main())
  File "/home/jdb/.local/lib/python3.5/site-packages/greg/parser.py", line 138, in main
    function(vars(args))
  File "/home/jdb/.local/lib/python3.5/site-packages/greg/commands.py", line 39, in add
    session = c.Session(args)
  File "/home/jdb/.local/lib/python3.5/site-packages/greg/classes.py", line 45, in __init__
    self.data_dir = self.retrieve_data_directory()
  File "/home/jdb/.local/lib/python3.5/site-packages/greg/classes.py", line 85, in retrieve_data_directory
    config.read([config_filename_global, self.config_filename_user])
  File "/usr/lib/python3.5/configparser.py", line 696, in read
    self._read(fp, filename)
  File "/usr/lib/python3.5/configparser.py", line 1012, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 33: ordinal not in range(128)
[jdb@alarmpi ~]$ 
manolomartinez commented 7 years ago

Is this still an issue for you? It shouldn't.

Let me know, if you are still interested. M

glebone commented 7 years ago

Can confirm, got the same error on raspbian

talljosh commented 7 years ago

I also see this issue, running greg 0.4.7 on Ubuntu. The traceback is similar, but not identical.

josh@paravel:~$ greg infoTraceback (most recent call last):
  File "/home/josh/.local/bin/greg", line 11, in <module>
    sys.exit(main())
  File "/home/josh/.local/lib/python3.5/site-packages/greg/parser.py", line 138, in main
    function(vars(args))
  File "/home/josh/.local/lib/python3.5/site-packages/greg/commands.py", line 124, in info
    session = c.Session(args)
  File "/home/josh/.local/lib/python3.5/site-packages/greg/classes.py", line 45, in __init__
    self.data_dir = self.retrieve_data_directory()
  File "/home/josh/.local/lib/python3.5/site-packages/greg/classes.py", line 85, in retrieve_data_direc
    config.read([config_filename_global, self.config_filename_user])
  File "/usr/lib/python3.5/configparser.py", line 696, in read
    self._read(fp, filename)
  File "/usr/lib/python3.5/configparser.py", line 1012, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 33: ordinal not in range(128)
talljosh commented 7 years ago

A workaround for others who experience this error: edit ~/.local/lib/python3.5/site-packages/greg/data/greg.conf and ~/.config/greg/greg.conf, and remove/replace the accented character in the first line.

raingloom commented 7 years ago

Same error when adding http://wolf359radio.libsyn.com/rss

jheddings commented 7 years ago

Interestingly, I am running into this same problem on one computer, but not on another. Both are running macOS Sierra using Homebrew to install python3. Anything settings or libraries I should check between them?

jheddings commented 7 years ago

Okay... Found the issue on my installation. I was executing greg using screen on one computer. On the local computer everything was fine, but the screen'ed computer was failing with this error. I switched to a standard terminal and everything worked fine. Something about output redirection in screen is causing strings to be encoded as ASCII. I imagine this would also happen if greg is launched from a cron job or other process that captures the output of stdout.

I edited line 328 in classes.py to force the encoding to UTF-8, which solved the problem: print("Downloading {} -- {}".format(title, podname).encode('utf-8'))

This answer on Stack Overflow led me to the solution (especially the comment from drevicko). I imagine that anywhere strings are being converted implicitly without an explicit encoding could lead to the error.

Also, setting PYTHONIOENCODING=utf-8 works.