nandhp / python-imdb

Python interface to IMDb plain-text data files
BSD 2-Clause "Simplified" License
41 stars 12 forks source link

ASCII-related error when using example.py #7

Closed PeterBennink closed 7 years ago

PeterBennink commented 7 years ago

When I use the example.py file, I get an error after about 25 movies:

Traceback (most recent call last):
  File "example.py", line 13, in <module>
    print u'%s has rating %s/10 (%d ratings)' % (title, r.score, r.nratings)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)

I have looked on the internet, and I know I should do something with encode('utf-8'), however, I can't seem to find the place in the code where I should add this.

nandhp commented 7 years ago

Thank you for reporting this. It was a fairly subtle problem -- the score is actually a Unicode string, which was causing the obvious solutions to your original problem to fail with a new ASCII decode error as it tried to upgrade everything back to Unicode. That took quite a while to figure out, but I've pushed a fix. Thanks again.

PeterBennink commented 7 years ago

Thank you so much, for the fast response, and for the solution!