Skip to content

Commit

Permalink
[2.0.x] Fixed #29959 -- Cached GEOS version in WKBWriter class.
Browse files Browse the repository at this point in the history
Regression in f185d92.
Backport of e7e5505 from master.
  • Loading branch information
claudep authored and timgraham committed Nov 16, 2018
1 parent 6d9b1e5 commit 3cc125b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions django/contrib/gis/geos/prototypes/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class WKBWriter(IOBase):
_constructor = wkb_writer_create
ptr_type = WKB_WRITE_PTR
destructor = wkb_writer_destroy
geos_version = geos_version_tuple()

def __init__(self, dim=2):
super().__init__()
Expand All @@ -235,7 +236,7 @@ def write(self, geom):
from django.contrib.gis.geos import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t()))
if geos_version_tuple() < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
if self.geos_version < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
# Fix GEOS output for empty polygon.
# See https://trac.osgeo.org/geos/ticket/680.
wkb = wkb[:-8] + b'\0' * 4
Expand All @@ -246,7 +247,7 @@ def write_hex(self, geom):
from django.contrib.gis.geos.polygon import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t()))
if geos_version_tuple() < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
if self.geos_version < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
wkb = wkb[:-16] + b'0' * 8
return wkb

Expand Down
4 changes: 3 additions & 1 deletion docs/releases/1.11.17.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Django 1.11.17 fixes several bugs in 1.11.16.
Bugfixes
========

* ...
* Prevented repetitive calls to ``geos_version_tuple()`` in the ``WKBWriter``
class in an attempt to fix a random crash involving ``LooseVersion`` since
Django 1.11.14 (:ticket:`29959`).
4 changes: 3 additions & 1 deletion docs/releases/2.0.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Django 2.0.10 fixes several bugs in 2.0.9.
Bugfixes
========

* ...
* Prevented repetitive calls to ``geos_version_tuple()`` in the ``WKBWriter``
class in an attempt to fix a random crash involving ``LooseVersion`` since
Django 2.0.6 (:ticket:`29959`).

0 comments on commit 3cc125b

Please sign in to comment.