summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-09-12 22:19:44 +0500
committerSergey Fedoseev <fedoseev.sergey@gmail.com>2017-09-12 22:19:44 +0500
commitc2ecef869ce46349e79c39610cd66a576d78289e (patch)
treeeb686af7b8adddc46df9b1388456c1af076823c5
parentac756f16c5bbbe544ad82a8f3ab2eac6cccdb62e (diff)
Refs #28569 -- Fixed gis_tests.inspectapp.tests.OGRInspectTest.test_time_field.
-rw-r--r--django/contrib/gis/gdal/datasource.py5
-rw-r--r--django/contrib/gis/gdal/prototypes/ds.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index d3009c234f..720ca23e63 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -87,8 +87,9 @@ class DataSource(GDALBase):
def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, str):
- layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
- if not layer:
+ try:
+ layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
+ except GDALException:
raise IndexError('Invalid OGR layer name given: %s.' % index)
elif isinstance(index, int):
if 0 <= index < self.layer_count:
diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py
index e699654e49..030d142c1c 100644
--- a/django/contrib/gis/gdal/prototypes/ds.py
+++ b/django/contrib/gis/gdal/prototypes/ds.py
@@ -28,7 +28,7 @@ destroy_ds = void_output(lgdal.OGR_DS_Destroy, [c_void_p], errcheck=False)
release_ds = void_output(lgdal.OGRReleaseDataSource, [c_void_p])
get_ds_name = const_string_output(lgdal.OGR_DS_GetName, [c_void_p])
get_layer = voidptr_output(lgdal.OGR_DS_GetLayer, [c_void_p, c_int])
-get_layer_by_name = voidptr_output(lgdal.OGR_DS_GetLayerByName, [c_void_p, c_char_p], errcheck=False)
+get_layer_by_name = voidptr_output(lgdal.OGR_DS_GetLayerByName, [c_void_p, c_char_p])
get_layer_count = int_output(lgdal.OGR_DS_GetLayerCount, [c_void_p])
# Layer Routines