summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-08-10 17:36:12 +0000
committerJustin Bronn <jbronn@gmail.com>2008-08-10 17:36:12 +0000
commit5b27c3604191eb5c69197abbb98904c643ff457c (patch)
tree04629c9033a6caf8cc8112948932bd0b04d18192
parent56f1f1fa9e9536667028ce637723bf45e319e7e3 (diff)
gis: Fixed #8207; now shield 2.4 test runners from attempting to import ctypes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8289 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/gdal/__init__.py12
-rw-r--r--django/contrib/gis/models.py5
2 files changed, 10 insertions, 7 deletions
diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py
index 22f962c0e5..b318850b28 100644
--- a/django/contrib/gis/gdal/__init__.py
+++ b/django/contrib/gis/gdal/__init__.py
@@ -47,9 +47,13 @@ except:
HAS_GDAL, GEOJSON = False, False
# The envelope, error, and geomtype modules do not actually require the
-# GDAL library.
+# GDAL library, but still nead at least Python 2.4 and ctypes.
PYTHON23 = sys.version_info[0] == 2 and sys.version_info[1] == 3
if not PYTHON23:
- from django.contrib.gis.gdal.envelope import Envelope
- from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
- from django.contrib.gis.gdal.geomtype import OGRGeomType
+ try:
+ from django.contrib.gis.gdal.envelope import Envelope
+ from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException
+ from django.contrib.gis.gdal.geomtype import OGRGeomType
+ except ImportError:
+ # No ctypes, but don't raise an exception.
+ pass
diff --git a/django/contrib/gis/models.py b/django/contrib/gis/models.py
index bb068ec5df..4453dd89fc 100644
--- a/django/contrib/gis/models.py
+++ b/django/contrib/gis/models.py
@@ -214,11 +214,10 @@ if not PYTHON23 and settings.DATABASE_ENGINE == 'postgresql_psycopg2':
# Because the PostGIS version is checked when initializing the spatial
# backend a `ProgrammingError` will be raised if the PostGIS tables
# and functions are not installed. We catch here so it won't be raised when
- # running the Django test suite.
- from psycopg2 import ProgrammingError
+ # running the Django test suite. `ImportError` is also possible if no ctypes.
try:
from django.contrib.gis.db.backend.postgis.models import GeometryColumns, SpatialRefSys
- except ProgrammingError:
+ except:
_srid_info = False
elif not PYTHON23 and settings.DATABASE_ENGINE == 'oracle':
# Same thing as above, except the GEOS library is attempted to be loaded for