Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jbothma opened this issue Aug 28, 2016 · 7 comments

Comments

@jbothma
Copy link

jbothma commented Aug 28, 2016

[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
Copy link
Owner

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

Let me know, if you are still interested.
M

@glebone
Copy link

glebone commented Nov 21, 2016

Can confirm, got the same error on raspbian

@talljosh
Copy link

talljosh commented Mar 2, 2017

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
Copy link

talljosh commented Mar 2, 2017

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
Copy link

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

@jheddings
Copy link

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
Copy link

jheddings commented May 23, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants