Skip to content
Commits on Source (3)
......@@ -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 (1.8.2-1) UNRELEASED; urgency=medium
* Team upload.
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Tue, 20 Nov 2018 06:54:26 +0100
fiona (1.8.1-1) unstable; urgency=medium
* Team upload.
......
......@@ -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()
......
......@@ -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,10 +1341,15 @@ 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
if not session or not session.isactive:
raise FionaValueError("Session is inactive, dataset is closed or layer is unavailable.")
# Update read cursor
self._next()
......@@ -1343,7 +1358,8 @@ cdef class Iterator:
if cogr_feature == NULL:
raise StopIteration
feature = FeatureBuilder().build(
try:
return FeatureBuilder().build(
cogr_feature,
bbox=False,
encoding=self.encoding,
......@@ -1351,8 +1367,8 @@ cdef class Iterator:
ignore_fields=self.collection.ignore_fields,
ignore_geometry=self.collection.ignore_geometry,
)
finally:
_deleteOgrFeature(cogr_feature)
return feature
cdef class ItemsIterator(Iterator):
......
......@@ -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)