Permalink
Browse files

gis: Fixed #8207; now shield 2.4 test runners from attempting to impo…

…rt ctypes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8289 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 56f1f1f commit 5b27c3604191eb5c69197abbb98904c643ff457c @jbronn jbronn committed Aug 10, 2008
Showing with 10 additions and 7 deletions.
  1. +8 −4 django/contrib/gis/gdal/__init__.py
  2. +2 −3 django/contrib/gis/models.py
@@ -47,9 +47,13 @@
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
@@ -214,11 +214,10 @@ def __unicode__(self):
# 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

0 comments on commit 5b27c36

Please sign in to comment.