dbr / themoviedb

Python wrapper to themoviedb.org API [Not actively maintained]
https://www.themoviedb.org/documentation/api/wrappers-libraries
The Unlicense
33 stars 13 forks source link

search for particular string "in b" produces error #6

Closed rehanog closed 11 years ago

rehanog commented 11 years ago

Hi,

Thanks for a really useful program.

Got a strange bug:

>>> tmdb.search("bruges")
<Search results: [<MovieResult: In Bruges (2008-02-08)>]>

>>> tmdb.search("in bruges")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tmdb.py", line 150, in __repr__
    return "<Search results: %s>" % (list.__repr__(self))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 32: ordinal not in range(128)

For some reason any string starting "in b" causes the issue. Can't replicate the bug with any other string.

Any thoughts?

sincerely,

Rehan

dbr commented 11 years ago

The error occurs because adding in to the search finds another result, which has Piñata in the name:

>>> sr = tmdb.search("in bruges")
s>>> sr[0]
<MovieResult: In Bruges (2008-02-08)>
>>> sr[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 32: ordinal not in range(128)
>>> "%s" % sr[1]['name']
u'Curious George: Pi\xf1ata Vision and other stories'

Not exactly sure why it's breaking the repr of the Movie, but should be easily fixed, and it should be fine if you are actually using the movie objects "properly", not in the Python shell - e.g printing the name is fine:

>>> print "%s" % sr[1]['name']
Curious George: Piñata Vision and other stories
dbr commented 11 years ago

Should be fixed!