Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#22126 closed Bug (duplicate)

Unicode error using GeoIP `country_name()` method

Reported by: caumons Owned by: erikr
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 Changed 17 months ago by erikr

  • Cc eromijn@… added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to erikr
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 17 months ago by erikr

  • Resolution set to duplicate
  • Status changed from assigned to closed
  • Triage Stage changed from Unreviewed to Accepted

This is a duplicate of #21996, which was fixed in 1.7 and backported to 1.6.

comment:3 follow-up: Changed 17 months ago by caumons

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 in reply to: ↑ 3 Changed 17 months ago by claudep

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() and city()? 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'
Note: See TracTickets for help on using tickets.
Back to Top