[fiona] 01/03: Imported Upstream version 1.7.5
Johan Van de Wauw
johanvdw-guest at moszumanska.debian.org
Wed Mar 22 10:58:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
johanvdw-guest pushed a commit to branch master
in repository fiona.
commit cf09128d3dd2cf6cf8fa9bfc83b7310be411eb01
Author: Johan Van de Wauw <johan.vandewauw at gmail.com>
Date: Wed Mar 22 08:14:23 2017 +0100
Imported Upstream version 1.7.5
---
CHANGES.txt | 11 ++++++++++
fiona/__init__.py | 2 +-
fiona/ogrext2.pxd | 7 ++++--
fiona/ogrext2.pyx | 65 ++++++++++++++++++++-----------------------------------
tests/test_vfs.py | 6 ++---
5 files changed, 43 insertions(+), 48 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 1bc4476..ea759be 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,17 @@ Changes
All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
+1.7.5 (2017-03-20)
+------------------
+
+Bug fixes:
+
+- Opening a data file in read (the default) mode with `fiona.open()` using the
+ the `driver` or `drivers` keyword arguments (to specify certain format
+ drivers) would sometimes cause a crash on Windows due to improperly
+ terminated lists of strings (#428). The fix: Fiona's buggy `string_list()`
+ has been replaced by GDAL's `CSLAddString()`.
+
1.7.4 (2017-02-20)
------------------
diff --git a/fiona/__init__.py b/fiona/__init__.py
index fca185b..2ea320f 100644
--- a/fiona/__init__.py
+++ b/fiona/__init__.py
@@ -81,7 +81,7 @@ import uuid
__all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
-__version__ = "1.7.4"
+__version__ = "1.7.5"
__gdal_version__ = get_gdal_release_name().decode('utf-8')
log = logging.getLogger('Fiona')
diff --git a/fiona/ogrext2.pxd b/fiona/ogrext2.pxd
index 149cb9b..0a3aa29 100644
--- a/fiona/ogrext2.pxd
+++ b/fiona/ogrext2.pxd
@@ -63,9 +63,12 @@ cdef extern from "cpl_conv.h":
void CPLSetThreadLocalConfigOption (char *key, char *val)
const char *CPLGetConfigOption (char *, char *)
+
cdef extern from "cpl_string.h":
- char ** CSLSetNameValue (char **list, char *name, char *value)
- void CSLDestroy (char **list)
+ char ** CSLSetNameValue (char **list, const char *name, const char *value)
+ void CSLDestroy (char **list)
+ char ** CSLAddString(char **list, const char *string)
+
cdef extern from "cpl_vsi.h":
ctypedef struct VSILFILE:
diff --git a/fiona/ogrext2.pyx b/fiona/ogrext2.pyx
index a367d93..82eaec4 100644
--- a/fiona/ogrext2.pyx
+++ b/fiona/ogrext2.pyx
@@ -101,19 +101,6 @@ OGRERR_UNSUPPORTED_SRS = 7
OGRERR_INVALID_HANDLE = 8
-cdef char ** string_list(list_str):
- """
- Function by Stackoverflow User falsetru
- https://stackoverflow.com/questions/17511309/fast-string-array-cython
- """
- cdef char* s
- cdef char **ret = <char **>malloc(len(list_str) * sizeof(char *))
- for i in range(len(list_str)):
- s = list_str[i]
- ret[i] = s
- ret[i + 1] = NULL
- return ret
-
def _explode(coords):
"""Explode a GeoJSON geometry's coordinates object and yield
coordinate tuples. As long as the input is conforming, the type of
@@ -390,7 +377,8 @@ cdef class Session:
cdef const char *name_c = NULL
cdef void *drv = NULL
cdef void *ds = NULL
- cdef char ** drvs = NULL
+ cdef char **drvs = NULL
+
if collection.path == '-':
path = '/vsistdin/'
else:
@@ -401,13 +389,22 @@ cdef class Session:
# Presume already a UTF-8 encoded string
path_b = path
path_c = path_b
-
+
+ # TODO: eliminate this context manager in 2.0 as we have done
+ # in Rasterio 1.0.
with cpl_errs:
- drivers = []
+
+ # We have two ways of specifying drivers to try. Resolve the
+ # values into a single set of driver short names.
if collection._driver:
- drivers = [collection._driver]
+ drivers = set([collection._driver])
elif collection.enabled_drivers:
- drivers = collection.enabled_drivers
+ drivers = set(collection.enabled_drivers)
+ else:
+ drivers = None
+
+ # If there are specified drivers, make a GDAL string list
+ # of their names.
if drivers:
for name in drivers:
name_b = name.encode()
@@ -415,30 +412,14 @@ cdef class Session:
log.debug("Trying driver: %s", name)
drv = ogrext2.GDALGetDriverByName(name_c)
if drv != NULL:
- drvs = string_list([name_b])
-
- flags = ogrext2.GDAL_OF_VECTOR | ogrext2.GDAL_OF_READONLY
- log.debug("GDALOpenEx({}, {}, {})".format(path_c, flags, [name_b]))
- ds = ogrext2.GDALOpenEx(path_c,
- flags,
- drvs,
- NULL,
- NULL)
- free(drvs)
- if ds != NULL:
- self.cogr_ds = ds
- collection._driver = name
- _driver = ogrext2.GDALGetDatasetDriver(ds)
- drv_name = ogrext2.GDALGetDriverShortName(_driver)
- log.debug("Driver: {} Success".format(drv_name))
-
- break
- else:
- self.cogr_ds = ogrext2.GDALOpenEx(path_c,
- ogrext2.GDAL_OF_VECTOR | ogrext2.GDAL_OF_READONLY,
- NULL,
- NULL,
- NULL)
+ drvs = ogrext2.CSLAddString(drvs, name_c)
+
+ flags = ogrext2.GDAL_OF_VECTOR | ogrext2.GDAL_OF_READONLY
+ try:
+ self.cogr_ds = ogrext2.GDALOpenEx(
+ path_c, flags, drvs, NULL, NULL)
+ finally:
+ ogrext2.CSLDestroy(drvs)
if self.cogr_ds == NULL:
raise FionaValueError(
diff --git a/tests/test_vfs.py b/tests/test_vfs.py
index 754575b..9aa52d1 100644
--- a/tests/test_vfs.py
+++ b/tests/test_vfs.py
@@ -85,14 +85,14 @@ class ZipArchiveReadingTestAbsPath(ZipArchiveReadingTest):
vfs="zip://" + os.path.abspath("tests/data/coutwildrnp.zip"))
def test_open_repr(self):
- self.assert_(repr(self.c).startswith("<open Collection '/vsizip//"))
+ self.assert_(repr(self.c).startswith("<open Collection '/vsizip/"))
def test_closed_repr(self):
self.c.close()
- self.assert_(repr(self.c).startswith("<closed Collection '/vsizip//"))
+ self.assert_(repr(self.c).startswith("<closed Collection '/vsizip/"))
def test_path(self):
- self.assert_(self.c.path.startswith('/vsizip//'))
+ self.assert_(self.c.path.startswith('/vsizip/'))
class TarArchiveReadingTest(VsiReadingTest):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/fiona.git
More information about the Pkg-grass-devel
mailing list