From e7e55059027ae2f644c852e0ba60dc9307b425e1 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 16 Nov 2018 15:10:33 +0100 Subject: [PATCH] Fixed #29959 -- Cached GEOS version in WKBWriter class. Regression in f185d929fa1c0caad8c03fccde899b647d7248c6. --- django/contrib/gis/geos/prototypes/io.py | 5 +++-- docs/releases/1.11.17.txt | 4 +++- docs/releases/2.0.10.txt | 4 +++- docs/releases/2.1.4.txt | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py index 8660e190f5..4a1180ad7a 100644 --- a/django/contrib/gis/geos/prototypes/io.py +++ b/django/contrib/gis/geos/prototypes/io.py @@ -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__() @@ -235,7 +236,7 @@ class WKBWriter(IOBase): 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 @@ -246,7 +247,7 @@ class WKBWriter(IOBase): 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 diff --git a/docs/releases/1.11.17.txt b/docs/releases/1.11.17.txt index 52d86601a6..db201d0b9a 100644 --- a/docs/releases/1.11.17.txt +++ b/docs/releases/1.11.17.txt @@ -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`). diff --git a/docs/releases/2.0.10.txt b/docs/releases/2.0.10.txt index 70d74559a4..fd2e7f5ebf 100644 --- a/docs/releases/2.0.10.txt +++ b/docs/releases/2.0.10.txt @@ -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`). diff --git a/docs/releases/2.1.4.txt b/docs/releases/2.1.4.txt index 6f05a04357..82378b16a0 100644 --- a/docs/releases/2.1.4.txt +++ b/docs/releases/2.1.4.txt @@ -12,3 +12,7 @@ Bugfixes * Corrected the default password list that ``CommonPasswordValidator`` uses by lowercasing all passwords to match the format expected by the validator (:ticket:`29952`). + +* Prevented repetitive calls to ``geos_version_tuple()`` in the ``WKBWriter`` + class in an attempt to fix a random crash involving ``LooseVersion`` + (:ticket:`29959`).