reverse_geocode
reverse_geocode copied to clipboard
Under Python 2.7, placenames are returned as str even though they may contain non-ASCII characters
Example:
> reverse_geocode.get([44, 7])['city']
'Puget-Th\xc3\xa9niers'
> type(reverse_geocode.get([44, 7])['city'])
str
> unicode(reverse_geocode.get([44, 7])['city'])
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-28-863149a1dee7> in <module>()
----> 1 unicode(reverse_geocode.get([44, 7])['city'])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
This means it cannot be printed in most situations, although it can by doing
> unicode(reverse_geocode.get([44, 7])['city'].decode('utf-8'))
u'Puget-Th\xe9niers'
I think the ideal behavior would be to return native unicode objects, not strs that have to be decoded. Also due to the fact this problem only occurs when non-ASCII characters are involved, it can stay hidden until the "wrong" placename comes up.
good point - PR to fix this very much welcome