From 257075d4adf9ce0fae8ca1ec3c680dc071fa5a72 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 22 Apr 2017 16:41:18 +0200 Subject: [PATCH] Refs #28115 -- Avoided masking legitimate ImportErrors in geoip2 module --- django/contrib/gis/geoip2/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/geoip2/__init__.py b/django/contrib/gis/geoip2/__init__.py index b76dfa6ef8..2d7d7a7e92 100644 --- a/django/contrib/gis/geoip2/__init__.py +++ b/django/contrib/gis/geoip2/__init__.py @@ -14,8 +14,10 @@ directory corresponding to settings.GEOIP_PATH. __all__ = ['HAS_GEOIP2'] try: + import geoip2 # NOQA +except ImportError: + HAS_GEOIP2 = False +else: from .base import GeoIP2, GeoIP2Exception HAS_GEOIP2 = True __all__ += ['GeoIP2', 'GeoIP2Exception'] -except ImportError: - HAS_GEOIP2 = False