Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7873 closed (fixed)

GEOSGeometry equality operator fails on None

Reported by: denis@… Owned by: jbronn
Component: GIS Version: gis
Severity: Keywords: geos equals
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

geos_eq.diff (571 bytes ) - added by jbronn 16 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by jbronn, 16 years ago

Description: modified (diff)
Keywords: equals added
Owner: changed from nobody to jbronn

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

by jbronn, 16 years ago

Attachment: geos_eq.diff added

comment:2 by jbronn, 16 years ago

Status: newassigned

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

comment:3 by jbronn, 16 years ago

milestone: 1.0 beta

comment:4 by denis@…, 16 years ago

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:
  ...

comment:5 by jbronn, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:6 by Jacob, 13 years ago

milestone: 1.0 beta

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top