Ticket #21996: 21996.diff

File 21996.diff, 1.5 KB (added by Claude Paroz, 11 years ago)
  • django/contrib/gis/geoip/prototypes.py

    diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
    index 3eae261..8d78386 100644
    a b class GeoIPRecord(Structure):  
    2323                ('continent_code', c_char_p),
    2424                ]
    2525geoip_char_fields = [name for name, ctype in GeoIPRecord._fields_ if ctype is c_char_p]
     26GEOIP_DEFAULT_ENCODING = 'iso-8859-1'
    2627geoip_encodings = {
    2728    0: 'iso-8859-1',
    2829    1: 'utf8',
    def check_string(result, func, cargs):  
    100101        free(result)
    101102    else:
    102103        s = ''
    103     return s.decode()
     104    return s.decode(GEOIP_DEFAULT_ENCODING)
    104105
    105106GeoIP_database_info = lgeoip.GeoIP_database_info
    106107GeoIP_database_info.restype = geoip_char_p
    GeoIP_database_info.errcheck = check_string  
    111112def string_output(func):
    112113    def _err_check(result, func, cargs):
    113114        if result:
    114             return result.decode()
     115            return result.decode(GEOIP_DEFAULT_ENCODING)
    115116        return result
    116117    func.restype = c_char_p
    117118    func.errcheck = _err_check
  • django/contrib/gis/geoip/tests.py

    diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py
    index 8d7bdff..9631a19 100644
    a b class GeoIPTest(unittest.TestCase):  
    119119        g = GeoIP()
    120120        d = g.city("www.osnabrueck.de")
    121121        self.assertEqual('Osnabrück', d['city'])
     122        d = g.country('200.7.49.81')
     123        self.assertEqual('Curaçao', d['country_name'])
Back to Top