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

Bas Couwenberg gitlab at salsa.debian.org
Fri Sep 4 05:56:45 BST 2020



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


Commits:
c556ff13 by Bas Couwenberg at 2020-09-04T06:18:23+02:00
New upstream version 1.8.15
- - - - -


16 changed files:

- CHANGES.txt
- appveyor.yml
- fiona/__init__.py
- fiona/_env.pyx
- fiona/_shim1.pxd
- fiona/_shim1.pyx
- fiona/_shim2.pxd
- fiona/_shim2.pyx
- fiona/_shim22.pxd
- fiona/_shim22.pyx
- fiona/_shim3.pxd
- fiona/_shim3.pyx
- fiona/drvsupport.py
- fiona/ogrext.pyx
- tests/test_datetime.py
- tests/test_memoryfile.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -3,6 +3,13 @@ Changes
 
 All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
 
+1.8.15 (2020-09-03)
+-------------------
+
+- Change shim functions to not return tuples (#942) as a solution for the
+  packaging problem reported in #941.
+- Raise a Python exception when VSIFOpenL fails (#937).
+
 1.8.14 (2020-08-31)
 -------------------
 


=====================================
appveyor.yml
=====================================
@@ -101,6 +101,10 @@ environment:
           GIS_INTERNALS_LIBS: "release-1911-x64-gdal-3-1-2-mapserver-7-6-1-libs.zip"
           PROJ_LIB: "C:\\gdal\\bin\\proj6\\share"
 
+matrix:
+  allow_failures:
+    - GDAL_VERSION: "1.11.4"
+
 install:
 
   - ECHO "Filesystem root:"


=====================================
fiona/__init__.py
=====================================
@@ -105,7 +105,7 @@ with fiona._loading.add_gdal_dll_directories():
 
 
 __all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
-__version__ = "1.8.14"
+__version__ = "1.8.15"
 __gdal_version__ = get_gdal_release_name()
 
 gdal_version = get_gdal_version_tuple()
@@ -227,7 +227,7 @@ def open(fp, mode='r', driver=None, schema=None, crs=None, encoding=None,
         def fp_writer(fp):
             memfile = MemoryFile()
             dataset = memfile.open(
-                driver=driver, crs=crs, schema=schema, layer=layer,
+                driver=driver, crs=crs, schema=this_schema, layer=layer,
                 encoding=encoding, enabled_drivers=enabled_drivers,
                 crs_wkt=crs_wkt, **kwargs)
             try:


=====================================
fiona/_env.pyx
=====================================
@@ -118,11 +118,15 @@ def get_proj_version_tuple():
     """
     Returns proj version tuple for gdal >= 3.0.1, otherwise None
     """
+    cdef int major
+    cdef int minor
+    cdef int patch
     gdal_version_num = get_gdal_version_num()
     if gdal_version_num < calc_gdal_version_num(3, 0, 1):
         proj_version = None
     else:
-        return get_proj_version()
+        get_proj_version(&major, &minor, &patch)
+        return (major, minor, patch)
 
 
 cdef void log_error(CPLErr err_class, int err_no, const char* msg) with gil:


=====================================
fiona/_shim1.pxd
=====================================
@@ -23,9 +23,9 @@ cdef void *get_linear_geometry(void *geom)
 cdef const char* osr_get_name(OGRSpatialReferenceH hSrs)
 cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs)
 cdef void set_proj_search_path(object path)
-cdef (int, int, int) get_proj_version()
+cdef void get_proj_version(int *, int *, int *)
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag)
-cdef (int, int, int, int, int, int, float, int)  get_field_as_datetime(void *cogr_feature, int iField)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int *, int *, int *, int *, int *, float *, int *)
 
 from fiona._shim cimport OGR_F_GetFieldAsInteger as OGR_F_GetFieldAsInteger64
 from fiona._shim cimport OGR_F_SetFieldInteger as OGR_F_SetFieldInteger64


=====================================
fiona/_shim1.pyx
=====================================
@@ -140,8 +140,11 @@ cdef void set_proj_search_path(object path):
     os.environ["PROJ_LIB"] = path
 
 
-cdef (int, int, int) get_proj_version():
-    return (-1, -1, -1)
+cdef void get_proj_version(int* major, int* minor, int* patch):
+    cdef int val = -1
+    major[0] = val
+    minor[0] = val
+    patch[0] = val
 
 
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):
@@ -150,15 +153,9 @@ cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMon
     OGR_F_SetFieldDateTime(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, nSecond, nTZFlag)
 
 
-cdef (int, int, int, int, int, int, float, int) get_field_as_datetime(void *cogr_feature, int iField):
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):
     cdef int retval
-    cdef int nYear = 0
-    cdef int nMonth = 0
-    cdef int nDay = 0
-    cdef int nHour = 0
-    cdef int nMinute = 0
-    cdef int nSecond = 0
-    cdef int nTZFlag = 0
-
-    retval = OGR_F_GetFieldAsDateTime(cogr_feature, iField, &nYear, &nMonth, &nDay, &nHour, &nMinute, &nSecond, &nTZFlag)
-    return (retval, nYear, nMonth, nDay, nHour, nMinute, float(nSecond), nTZFlag)
+    cdef int nSecond
+    retval = OGR_F_GetFieldAsDateTime(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, &nSecond, nTZFlag)
+    fSecond[0] = float(nSecond)
+    return retval


=====================================
fiona/_shim2.pxd
=====================================
@@ -16,6 +16,6 @@ cdef void *get_linear_geometry(void *geom)
 cdef const char* osr_get_name(OGRSpatialReferenceH hSrs)
 cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs)
 cdef void set_proj_search_path(object path)
-cdef (int, int, int) get_proj_version()
+cdef void get_proj_version(int *, int *, int *)
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag)
-cdef (int, int, int, int, int, int, float, int)  get_field_as_datetime(void *cogr_feature, int iField)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int *, int *, int *, int *, int *, float *, int *)


=====================================
fiona/_shim2.pyx
=====================================
@@ -140,24 +140,16 @@ cdef void set_proj_search_path(object path):
     os.environ["PROJ_LIB"] = path
 
 
-cdef (int, int, int) get_proj_version():
-    return (-1, -1, -1)
+cdef void get_proj_version(int* major, int* minor, int* patch):
+    cdef int val = -1
+    major[0] = val
+    minor[0] = val
+    patch[0] = val
 
 
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):
     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
 
 
-cdef (int, int, int, int, int, int, float, int) get_field_as_datetime(void *cogr_feature, int iField):
-    cdef int retval
-    cdef int nYear = 0
-    cdef int nMonth = 0
-    cdef int nDay = 0
-    cdef int nHour = 0
-    cdef int nMinute = 0
-    cdef float fSecond = 0.0
-    cdef int nTZFlag = 0
-
-    retval = OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond, &nTZFlag)
-
-    return (retval, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):
+    return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)


=====================================
fiona/_shim22.pxd
=====================================
@@ -16,6 +16,6 @@ cdef void *get_linear_geometry(void *geom)
 cdef const char* osr_get_name(OGRSpatialReferenceH hSrs)
 cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs)
 cdef void set_proj_search_path(object path)
-cdef (int, int, int) get_proj_version()
+cdef void get_proj_version(int *, int *, int *)
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag)
-cdef (int, int, int, int, int, int, float, int)  get_field_as_datetime(void *cogr_feature, int iField)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int *, int *, int *, int *, int *, float *, int *)


=====================================
fiona/_shim22.pyx
=====================================
@@ -150,24 +150,16 @@ cdef void set_proj_search_path(object path):
     os.environ["PROJ_LIB"] = path
 
 
-cdef (int, int, int) get_proj_version():
-    return (-1, -1, -1)
+cdef void get_proj_version(int* major, int* minor, int* patch):
+    cdef int val = -1
+    major[0] = val
+    minor[0] = val
+    patch[0] = val
 
 
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):
     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
 
 
-cdef (int, int, int, int, int, int, float, int) get_field_as_datetime(void *cogr_feature, int iField):
-    cdef int retval
-    cdef int nYear = 0
-    cdef int nMonth = 0
-    cdef int nDay = 0
-    cdef int nHour = 0
-    cdef int nMinute = 0
-    cdef float fSecond = 0.0
-    cdef int nTZFlag = 0
-
-    retval = OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond, &nTZFlag)
-
-    return (retval, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):
+    return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)


=====================================
fiona/_shim3.pxd
=====================================
@@ -16,6 +16,6 @@ cdef void *get_linear_geometry(void *geom)
 cdef const char* osr_get_name(OGRSpatialReferenceH hSrs)
 cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs)
 cdef void set_proj_search_path(object path)
-cdef (int, int, int) get_proj_version()
+cdef void get_proj_version(int *, int *, int *)
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag)
-cdef (int, int, int, int, int, int, float, int)  get_field_as_datetime(void *cogr_feature, int iField)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int *, int *, int *, int *, int *, float *, int *)


=====================================
fiona/_shim3.pyx
=====================================
@@ -165,28 +165,13 @@ cdef void set_proj_search_path(object path):
     OSRSetPROJSearchPaths(paths)
 
 
-cdef (int, int, int) get_proj_version():
-    cdef int major
-    cdef int minor
-    cdef int patch
-    OSRGetPROJVersion(&major, &minor, &patch)
-    return (major, minor, patch)
+cdef void get_proj_version(int* major, int* minor, int* patch):
+    OSRGetPROJVersion(major, minor, patch)
 
 
 cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):
     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
 
 
-cdef (int, int, int, int, int, int, float, int) get_field_as_datetime(void *cogr_feature, int iField):
-    cdef int retval
-    cdef int nYear = 0
-    cdef int nMonth = 0
-    cdef int nDay = 0
-    cdef int nHour = 0
-    cdef int nMinute = 0
-    cdef float fSecond = 0.0
-    cdef int nTZFlag = 0
-
-    retval = OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond, &nTZFlag)
-
-    return (retval, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
+cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):
+    return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)


=====================================
fiona/drvsupport.py
=====================================
@@ -344,25 +344,3 @@ def _driver_supports_milliseconds(driver):
 
     return True
 
-
-# None: field type never supports unknown timezones, (2, 0, 0): field type supports unknown timezones with GDAL 2.0.0
-_drivers_not_supporting_unknown_timezone = {
-    'datetime':
-        {'GPKG': None,
-         'GPX': (2, 4, 0)
-         }
-}
-
-
-def _driver_supports_unknown_timezones(driver, field_type):
-    """ Returns True if the driver supports timezones for field_type, False otherwise
-
-        Note: this function is not part of Fiona's public API.
-    """
-    if (field_type in _drivers_not_supporting_unknown_timezone and
-            driver in _drivers_not_supporting_unknown_timezone[field_type]):
-        if _drivers_not_supporting_unknown_timezone[field_type][driver] is None:
-            return False
-        elif get_gdal_version_num() < calc_gdal_version_num(*_drivers_not_supporting_unknown_timezone[field_type][driver]):
-            return False
-    return True


=====================================
fiona/ogrext.pyx
=====================================
@@ -167,6 +167,14 @@ cdef class FeatureBuilder:
         cdef int retval
         cdef int fieldsubtype
         cdef const char *key_c = NULL
+        # Parameters for get_field_as_datetime
+        cdef int y = 0
+        cdef int m = 0
+        cdef int d = 0
+        cdef int hh = 0
+        cdef int mm = 0
+        cdef float fss = 0.0
+        cdef int tz = 0
 
         # Skeleton of the feature to be returned.
         fid = OGR_F_GetFID(feature)
@@ -243,9 +251,8 @@ cdef class FeatureBuilder:
                 props[key] = val
 
             elif fieldtype in (FionaDateType, FionaTimeType, FionaDateTimeType):
-                retval, y, m, d, hh, mm, ss, tz = get_field_as_datetime(feature, i)
-
-                ms, ss = math.modf(ss)
+                retval = get_field_as_datetime(feature, i, &y, &m, &d, &hh, &mm, &fss, &tz)
+                ms, ss = math.modf(fss)
                 ss = int(ss)
                 ms = int(round(ms * 10**6))
 
@@ -1678,8 +1685,6 @@ cdef class MemoryFileBase:
             filename was provided.
 
         """
-        cdef VSILFILE *fp = NULL
-
         if file_or_bytes:
             if hasattr(file_or_bytes, 'read'):
                 initial_bytes = file_or_bytes.read()
@@ -1722,14 +1727,24 @@ cdef class MemoryFileBase:
 
     def _open(self):
         """Ensure that the instance has a valid VSI file handle."""
+        cdef VSILFILE *fp = NULL
         name_b = self.name.encode('utf-8')
+
         if not self.exists():
-            self._vsif = VSIFOpenL(name_b, "w")
-            VSIFCloseL(self._vsif)
+            fp = VSIFOpenL(name_b, "w")
+            if fp == NULL:
+                raise OSError("VSIFOpenL failed")
+            else:
+                VSIFCloseL(fp)
             self._vsif = NULL
 
         if self._vsif == NULL:
-            self._vsif = VSIFOpenL(name_b, self.mode.encode("utf-8"))
+            fp = VSIFOpenL(name_b, self.mode.encode("utf-8"))
+            if fp == NULL:
+                log.error("VSIFOpenL failed: name=%r, mode=%r", self.name, self.mode)
+                raise OSError("VSIFOpenL failed")
+            else:
+                self._vsif = fp
 
     def _ensure_extension(self, drivername=None):
         """Ensure that the instance's name uses a file extension supported by the driver."""


=====================================
tests/test_datetime.py
=====================================
@@ -13,7 +13,7 @@ from fiona.env import GDALVersion
 import datetime
 from fiona.drvsupport import (supported_drivers, driver_mode_mingdal, _driver_converts_field_type_silently_to_str,
                               _driver_supports_field, _driver_converts_to_str, _driver_supports_timezones,
-                              _driver_supports_milliseconds, _driver_supports_unknown_timezones)
+                              _driver_supports_milliseconds)
 import pytz
 from pytz import timezone
 
@@ -653,37 +653,6 @@ def test_driver_marked_as_silently_converts_to_str_converts_silently_to_str(tmpd
         assert get_schema_field(driver, c.schema) == 'str'
 
 
- at pytest.mark.filterwarnings('ignore:.*driver silently converts *:UserWarning')
- at pytest.mark.parametrize("driver,field_type", [(driver, field_type) for driver, field_type in
-                                               test_cases_datefield + test_cases_datefield_to_str
-                                               if not field_type == 'date'])
-def test_no_unknown_timezone(tmpdir, driver, field_type):
-    """ Some driver do not support unknown timezones (TZFlag=0) and convert datetimes silently to UTC"""
-
-    schema = get_schema(driver, field_type)
-    path = str(tmpdir.join(get_temp_filename(driver)))
-
-    if field_type == 'datetime':
-        values_in = ['2020-03-24T16:08:40']
-    elif field_type == 'time':
-        values_in = ['16:08:40']
-    records = get_records(driver, values_in)
-
-    with fiona.open(path, 'w',
-                    driver=driver,
-                    schema=schema) as c:
-        c.writerecords(records)
-
-    with fiona.open(path, 'r') as c:
-        items = [get_field(driver, f) for f in c]
-        assert len(items) == 1
-
-        if _driver_supports_unknown_timezones(driver, field_type):
-            assert "+" not in items[0], "{} contains a timezone".format(items[0])
-        else:
-            assert "+" in items[0], "{} contains no timezone".format(items[0])
-
-
 def test_read_timezone_geojson(path_test_tz_geojson):
     """Test if timezones are read correctly"""
     with fiona.open(path_test_tz_geojson) as c:


=====================================
tests/test_memoryfile.py
=====================================
@@ -1,6 +1,8 @@
 """Tests of MemoryFile and ZippedMemoryFile"""
 
+from collections import OrderedDict
 from io import BytesIO
+
 import pytest
 
 import fiona
@@ -131,3 +133,14 @@ def test_write_bytesio(profile_first_coutwildrnp_shp):
     with MemoryFile(data) as memfile:
         with memfile.open() as col:
             assert len(col) == 1
+
+
+def test_mapinfo_raises():
+    """Reported to be a crasher in #937"""
+    driver = 'MapInfo File'
+    schema = {'geometry': 'Point', 'properties': OrderedDict([('position', 'str')])}
+
+    with BytesIO() as fout:
+        with pytest.raises(OSError):
+            with fiona.open(fout, "w", driver=driver, schema=schema) as collection:
+                collection.write({"type": "Feature", "geometry": {"type": "Point", "coordinates": (0, 0)}, "properties": {"position": "x"}})



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

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/-/commit/c556ff1334278c1fbd921afe002d839fabaad09b
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/20200904/b520dc2e/attachment-0001.html>


More information about the Pkg-grass-devel mailing list