#22126 closed Bug (duplicate)
Unicode error using GeoIP `country_name()` method
Reported by: | caumons | Owned by: | Sasha Romijn |
---|---|---|---|
Component: | GIS | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | eromijn@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The method country_name()
located at django.contrib.gis.geoip.GeoIP
returns a str
instead of unicode
string and fails when the name contains non ASCII chars.
The error I'm getting is: 'utf8' codec can't decode byte 0xe7 in position 170: invalid continuation byte
. The string that could not be encoded/decoded was: 'Cura�ao'
To reproduce it do a lookup with:
from django.contrib.gis.geoip import GeoIP GeoIP().country_name('190.185.103.13')
If instead of using the method country_name()
we use city()
the returned info is different (inconsistency?):
{'city': u'Neuquen', 'continent_code': u'SA', 'region': u'15', 'charset': 0, 'area_code': 0, 'longitude': -68.05909729003906, 'country_code3': u'ARG', 'latitude': -38.95159912109375, 'postal_code': None, 'dma_code': 0, 'country_code': u'AR', 'country_name': u'Argentina'
}
Change History (4)
comment:1 by , 11 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Triage Stage: | Unreviewed → Accepted |
follow-up: 4 comment:3 by , 11 years ago
Will this be backported to v 1.5? And... what about the country inconsistency calling country_name()
and city()
? Is this somehow related to the encoding error?
comment:4 by , 11 years ago
Replying to caumons:
Will this be backported to v 1.5?
No, 1.5 is in security-only fix mode.
And... what about the country inconsistency calling
country_name()
andcity()
? Is this somehow related to the encoding error?
I doubt this is a problem in Django, and I'm unable to reproduce it on my system.
g.country_name('190.185.103.13') u'Argentina'
This is a duplicate of #21996, which was fixed in 1.7 and backported to 1.6.