Django

Code

Ticket #7873 (closed: fixed)

Opened 4 months ago

Last modified 4 months ago

GEOSGeometry equality operator fails on None

Reported by: denis@poly9.com Assigned to: jbronn
Milestone: 1.0 beta Component: GIS
Version: gis Keywords: geos equals
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by jbronn)

>>> from django.contrib.gis.geos import *
>>> Point(0, 0) == None
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Python/2.5/site-packages/django/contrib/gis/geos/base.py", line 170, in __eq__
    return self.equals_exact(other)
  File "/Library/Python/2.5/site-packages/django/contrib/gis/geos/base.py", line 318, in equals_exact
    return geos_equalsexact(self.ptr, other.ptr, float(tolerance))
AttributeError: 'NoneType' object has no attribute 'ptr'
>>> 

Attachments

geos_eq.diff (0.6 kB) - added by jbronn on 07/21/08 14:54:11.

Change History

07/21/08 14:49:11 changed by jbronn

  • description changed.
  • needs_better_patch changed.
  • needs_tests changed.
  • owner changed from nobody to jbronn.
  • keywords changed from geos to geos equals.
  • needs_docs changed.

I agree that a TypeError should be raised instead -- at least an error is raised, so this is non-critical at the moment.

07/21/08 14:54:11 changed by jbronn

  • attachment geos_eq.diff added.

07/21/08 14:54:52 changed by jbronn

  • status changed from new to assigned.

On second thought, it would be more pythonic to return False instead. The attached patch does that.

07/21/08 14:55:03 changed by jbronn

  • milestone set to 1.0 beta.

07/21/08 14:56:33 changed by denis@poly9.com

Agreed about the return False.
This might be useful to check if a geometry is set. While some people will write
if not self.geom:
  ...
Others will write:
if self.geom == None:
  ...

07/21/08 21:43:48 changed by jbronn

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [8040]) gis: Fixed #7873, GEOSGeometry equivalence comparison with None should not raise an exception. Thanks, Denis.


Add/Change #7873 (GEOSGeometry equality operator fails on None)




Change Properties
Action