[python-shapely] 01/04: New upstream version 1.6.1

Bas Couwenberg sebastic at debian.org
Sat Sep 2 10:12:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository python-shapely.

commit 742666b0cbaf98bf1d2e48b276eef636ffc7616a
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Sep 2 11:49:25 2017 +0200

    New upstream version 1.6.1
---
 CHANGES.txt              | 29 +++++++++++++++++++++++++++++
 shapely/__init__.py      |  2 +-
 shapely/geometry/base.py |  6 ++++++
 shapely/geos.py          |  4 ++--
 shapely/strtree.py       |  3 +++
 tests/test_emptiness.py  |  6 +++++-
 tests/test_strtree.py    | 19 +++++++++++++++++++
 7 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index b556b35..c00514c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,12 +1,41 @@
 Changes
 =======
 
+1.6.1 (2017-09-01)
+------------------
+
+- Avoid ``STRTree`` crashes due to dangling references (#505) by maintaining
+  references to added geometries.
+- Reduce log level to debug when reporting on calls to ctypes ``CDLL()`` that
+  don't succeed and are retried (#515).
+- Clarification: applications like GeoPandas that need an empty geometry object
+  should use ``BaseGeometry()`` instead of ``Point()`` or ``Polygon()``. An
+  ``EmptyGeometry`` class has been added in the master development branch and
+  will be available in the next non-bugfix release.
+
 1.6.0 (2017-08-21)
 ------------------
 
+Shapely 1.6.0 adds new attributes to existing geometry classes and new
+functions (``split()`` and ``polylabel()``) to the shapely.ops module.
+Exceptions are consolidated in a shapely.errors module and logging practices
+have been improved. Shapely's optional features depending on Numpy are now
+gathered into a requirements set named "vectorized" and these may be installed
+like ``pip install shapely[vectorized]``.
+
+Much of the work on 1.6.0 was aimed to improve the project's build and
+packaging scripts and to minimize run-time dependencies. Shapely now vendorizes
+packaging to use during builds only and never again invokes the geos-config
+utility at run-time.
+
+In addition to the changes listed under the alpha and beta pre-releases below,
+the following change has been made to the project:
+
 - Project documentation is now hosted at 
   https://shapely.readthedocs.io/en/latest/.
 
+Thank you all for using, promoting, and contributing to the Shapely project.
+
 1.6b5 (2017-08-18)
 ------------------
 
diff --git a/shapely/__init__.py b/shapely/__init__.py
index e4adfb8..f49459c 100644
--- a/shapely/__init__.py
+++ b/shapely/__init__.py
@@ -1 +1 @@
-__version__ = "1.6.0"
+__version__ = "1.6.1"
diff --git a/shapely/geometry/base.py b/shapely/geometry/base.py
index 7f64c78..202d923 100644
--- a/shapely/geometry/base.py
+++ b/shapely/geometry/base.py
@@ -943,6 +943,12 @@ class HeterogeneousGeometrySequence(GeometrySequence):
         return g
 
 
+class EmptyGeometry(BaseGeometry):
+    def __init__(self):
+        """Create an empty geometry."""
+        BaseGeometry.__init__(self)
+
+
 def _test():
     """Test runner"""
     import doctest
diff --git a/shapely/geos.py b/shapely/geos.py
index b9d66f6..09bf1ab 100644
--- a/shapely/geos.py
+++ b/shapely/geos.py
@@ -32,7 +32,7 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE):
             LOG.debug("Trying `CDLL(%s)`", lib)
             dll = CDLL(lib, mode=mode)
         except OSError:
-            LOG.warn("Failed `CDLL(%s)`", lib)
+            LOG.debug("Failed `CDLL(%s)`", lib)
             pass
 
     if not dll and fallbacks is not None:
@@ -42,7 +42,7 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE):
                 dll = CDLL(name, mode=mode)
             except OSError:
                 # move on to the next fallback
-                LOG.warn("Failed `CDLL(%s)`", name)
+                LOG.debug("Failed `CDLL(%s)`", name)
                 pass
 
     if dll:
diff --git a/shapely/strtree.py b/shapely/strtree.py
index 7abe685..161554d 100644
--- a/shapely/strtree.py
+++ b/shapely/strtree.py
@@ -39,6 +39,9 @@ class STRtree:
         for geom in geoms:
             lgeos.GEOSSTRtree_insert(self._tree_handle, geom._geom, ctypes.py_object(geom))
 
+        # Keep references to geoms.
+        self._geoms = list(geoms)
+
     def __del__(self):
         lgeos.GEOSSTRtree_destroy(self._tree_handle)
 
diff --git a/tests/test_emptiness.py b/tests/test_emptiness.py
index 541224e..91d5ec2 100644
--- a/tests/test_emptiness.py
+++ b/tests/test_emptiness.py
@@ -1,5 +1,5 @@
 from . import unittest
-from shapely.geometry.base import BaseGeometry
+from shapely.geometry.base import BaseGeometry, EmptyGeometry
 import shapely.geometry as sgeom
 from shapely.geometry.polygon import LinearRing
 
@@ -7,6 +7,10 @@ empty_generator = lambda: iter([])
 
 class EmptinessTestCase(unittest.TestCase):
 
+    def test_empty_class(self):
+        g = EmptyGeometry()
+        self.assertTrue(g._is_empty)
+
     def test_empty_base(self):
         g = BaseGeometry()
         self.assertTrue(g._is_empty)
diff --git a/tests/test_strtree.py b/tests/test_strtree.py
index 372a987..8eb5dcf 100644
--- a/tests/test_strtree.py
+++ b/tests/test_strtree.py
@@ -1,3 +1,5 @@
+import gc
+
 from . import unittest
 
 from shapely.strtree import STRtree
@@ -42,6 +44,23 @@ class STRTestCase(unittest.TestCase):
         self.assertEqual(len(results), 1)
         self.assertEqual(results[0], point)
 
+    def test_references(self):
+        """Don't crash due to dangling references"""
+        empty = Polygon()
+        point = Point(1, 0.5)
+        geoms = [empty, point]
+        tree = STRtree(geoms)
+        assert(tree._n_geoms == 1)
+
+        empty = None
+        point = None
+        gc.collect()
+
+        query = Polygon([(0,0),(1,1),(2,0),(0,0)])
+        results = tree.query(query)
+        self.assertEqual(len(results), 1)
+        self.assertEqual(results[0], Point(1, 0.5))
+
 
 def test_suite():
     return unittest.TestLoader().loadTestsFromTestCase(STRTestCase)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-shapely.git



More information about the Pkg-grass-devel mailing list