Author: jbronn
Date: 2010-04-01 11:57:23 -0500 (Thu, 01 Apr 2010)
New Revision: 12906
Modified:
django/branches/releases/1.1.X/django/contrib/gis/gdal/geometries.py
django/branches/releases/1.1.X/django/contrib/gis/gdal/tests/test_geom.py
Log:
[1.1.X] Fixed #13256 -- `OGRGeometry` no longer raises an exception when
compared to instances of different types. Thanks, ninowalker for the bug
report.
Backport of r12905 from trunk.
Modified: django/branches/releases/1.1.X/django/contrib/gis/gdal/geometries.py
===================================================================
--- django/branches/releases/1.1.X/django/contrib/gis/gdal/geometries.py
2010-04-01 16:56:55 UTC (rev 12905)
+++ django/branches/releases/1.1.X/django/contrib/gis/gdal/geometries.py
2010-04-01 16:57:23 UTC (rev 12906)
@@ -163,11 +163,14 @@
def __eq__(self, other):
"Is this Geometry equal to the other?"
- return self.equals(other)
+ if isinstance(other, OGRGeometry):
+ return self.equals(other)
+ else:
+ return False
def __ne__(self, other):
"Tests for inequality."
- return not self.equals(other)
+ return not (self == other)
def __str__(self):
"WKT is used for the string representation."
Modified:
django/branches/releases/1.1.X/django/contrib/gis/gdal/tests/test_geom.py
===================================================================
--- django/branches/releases/1.1.X/django/contrib/gis/gdal/tests/test_geom.py
2010-04-01 16:56:55 UTC (rev 12905)
+++ django/branches/releases/1.1.X/django/contrib/gis/gdal/tests/test_geom.py
2010-04-01 16:57:23 UTC (rev 12906)
@@ -461,6 +461,11 @@
self.assertEqual(3, geom[0].coord_dim)
self.assertEqual(wkt_3d, geom.wkt)
+ def test19_equivalence_regression(self):
+ "Testing equivalence methods with non-OGRGeometry instances."
+ self.assertNotEqual(None, OGRGeometry('POINT(0 0)'))
+ self.assertEqual(False, OGRGeometry('LINESTRING(0 0, 1 1)') == 3)
+
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(OGRGeomTest))
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.