[Git][debian-gis-team/fiona][upstream] New upstream version 1.8.2

Bas Couwenberg gitlab at salsa.debian.org
Tue Nov 20 05:58:12 GMT 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / fiona


Commits:
d8cfbc0f by Bas Couwenberg at 2018-11-20T05:54:04Z
New upstream version 1.8.2
- - - - -


4 changed files:

- CHANGES.txt
- fiona/__init__.py
- fiona/ogrext.pyx
- tests/test_collection.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -3,6 +3,15 @@ Changes
 
 All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
 
+1.8.2 (2018-11-19)
+------------------
+
+Bug fixes:
+
+- Raise FionaValueError when an iterator's __next__ is called and the session
+  is found to be missing or inactive instead of passing a null pointer to
+  OGR_L_GetNextFeature (#687).
+
 1.8.1 (2018-11-15)
 ------------------
 


=====================================
fiona/__init__.py
=====================================
@@ -101,7 +101,7 @@ import uuid
 
 
 __all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
-__version__ = "1.8.1"
+__version__ = "1.8.2"
 __gdal_version__ = get_gdal_release_name()
 
 gdal_version = get_gdal_version_tuple()


=====================================
fiona/ogrext.pyx
=====================================
@@ -43,6 +43,16 @@ from libc.stdlib cimport malloc, free
 from libc.string cimport strcmp
 from cpython cimport PyBytes_FromStringAndSize, PyBytes_AsString
 
+cdef extern from "ogr_api.h" nogil:
+
+    ctypedef void * OGRLayerH
+    ctypedef void * OGRDataSourceH
+    ctypedef void * OGRSFDriverH
+    ctypedef void * OGRFieldDefnH
+    ctypedef void * OGRFeatureDefnH
+    ctypedef void * OGRFeatureH
+    ctypedef void * OGRGeometryH
+
 
 log = logging.getLogger(__name__)
 
@@ -1331,11 +1341,16 @@ cdef class Iterator:
         self.next_index += self.step
 
     def __next__(self):
-        cdef void * cogr_feature
+        cdef OGRFeatureH cogr_feature = NULL
+        cdef OGRLayerH cogr_layer = NULL
         cdef Session session
+
         session = self.collection.session
 
-        #Update read cursor
+        if not session or not session.isactive:
+            raise FionaValueError("Session is inactive, dataset is closed or layer is unavailable.")
+
+        # Update read cursor
         self._next()
 
         # Get the next feature.
@@ -1343,16 +1358,17 @@ cdef class Iterator:
         if cogr_feature == NULL:
             raise StopIteration
 
-        feature = FeatureBuilder().build(
-            cogr_feature,
-            bbox=False,
-            encoding=self.encoding,
-            driver=self.collection.driver,
-            ignore_fields=self.collection.ignore_fields,
-            ignore_geometry=self.collection.ignore_geometry,
-        )
-        _deleteOgrFeature(cogr_feature)
-        return feature
+        try:
+            return FeatureBuilder().build(
+                cogr_feature,
+                bbox=False,
+                encoding=self.encoding,
+                driver=self.collection.driver,
+                ignore_fields=self.collection.ignore_fields,
+                ignore_geometry=self.collection.ignore_geometry,
+            )
+        finally:
+            _deleteOgrFeature(cogr_feature)
 
 
 cdef class ItemsIterator(Iterator):


=====================================
tests/test_collection.py
=====================================
@@ -874,3 +874,13 @@ def test_encoding_option_warning(tmpdir, caplog):
     ds = fiona.Collection(str(tmpdir.join("test.geojson")), "w", driver="GeoJSON", crs="epsg:4326",
             schema={"geometry": "Point", "properties": {"foo": "int"}})
     assert not caplog.text
+
+
+def test_closed_session_next(path_coutwildrnp_shp):
+    """Confirm fix for  issue #687"""
+    src = fiona.open(path_coutwildrnp_shp)
+    itr = iter(src)
+    feats = list(itr)
+    src.close()
+    with pytest.raises(FionaValueError):
+        next(itr)



View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/commit/d8cfbc0f1c4e87893856fac8fa31e099179b014d

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/commit/d8cfbc0f1c4e87893856fac8fa31e099179b014d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20181120/a035e3c5/attachment-0001.html>


More information about the Pkg-grass-devel mailing list