From 35185495e3f70f900b542bf95d744f51e5c5cb92 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 15 Feb 2013 17:12:14 +0100 Subject: [PATCH] Fixed #17066 -- Prevented TypeError in GeoIP.__del__ When garbaging GeoIP instances, it happens that GeoIP_delete is already None. Thanks mitar for the report and stefanw for tests. --- django/contrib/gis/geoip/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py index 944240c811..4b8b6e1ed3 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -125,6 +125,8 @@ class GeoIP(object): def __del__(self): # Cleaning any GeoIP file handles lying around. + if GeoIP_delete is None: + return if self._country: GeoIP_delete(self._country) if self._city: GeoIP_delete(self._city)