summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-11-30 12:33:58 +0100
committerClaude Paroz <claude@2xlibre.net>2016-11-30 17:49:41 +0100
commitcc9e4297019bcec9fe0fee2199aa30fb1f6e90b7 (patch)
tree8de0a88688b81a555c15fe686a407f8a7ca727ad /django
parent4464b9b9ad9da921f8b50b4e7e26bb4233e05ca0 (diff)
Fixed #27557 -- Casted GEOSGeometry only when necessary
Thanks Pete Flugstad for the report, and Tim Graham for the review.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/geos/geometry.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 1a13cdbbc8..07a22cb751 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -95,24 +95,26 @@ class GEOSGeometry(GEOSBase, ListMixin):
self.srid = srid
# Setting the class type (e.g., Point, Polygon, etc.)
- if GEOSGeometry._GEOS_CLASSES is None:
- # Lazy-loaded variable to avoid import conflicts with GEOSGeometry.
- from .linestring import LineString, LinearRing
- from .point import Point
- from .polygon import Polygon
- from .collections import (
- GeometryCollection, MultiPoint, MultiLineString, MultiPolygon)
- GEOSGeometry._GEOS_CLASSES = {
- 0: Point,
- 1: LineString,
- 2: LinearRing,
- 3: Polygon,
- 4: MultiPoint,
- 5: MultiLineString,
- 6: MultiPolygon,
- 7: GeometryCollection,
- }
- self.__class__ = GEOSGeometry._GEOS_CLASSES[self.geom_typeid]
+ if type(self) == GEOSGeometry:
+ if GEOSGeometry._GEOS_CLASSES is None:
+ # Lazy-loaded variable to avoid import conflicts with GEOSGeometry.
+ from .linestring import LineString, LinearRing
+ from .point import Point
+ from .polygon import Polygon
+ from .collections import (
+ GeometryCollection, MultiPoint, MultiLineString, MultiPolygon,
+ )
+ GEOSGeometry._GEOS_CLASSES = {
+ 0: Point,
+ 1: LineString,
+ 2: LinearRing,
+ 3: Polygon,
+ 4: MultiPoint,
+ 5: MultiLineString,
+ 6: MultiPolygon,
+ 7: GeometryCollection,
+ }
+ self.__class__ = GEOSGeometry._GEOS_CLASSES[self.geom_typeid]
# Setting the coordinate sequence for the geometry (will be None on
# geometries that do not have coordinate sequences)