Opened 12 years ago

Closed 12 years ago

Last modified 9 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/", line 170, in __eq__
    return self.equals_exact(other)
  File "/Library/Python/2.5/site-packages/django/contrib/gis/geos/", 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 12 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 12 years ago by jbronn

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.

Changed 12 years ago by jbronn

Attachment: geos_eq.diff added

comment:2 Changed 12 years ago by jbronn

Status: newassigned

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

comment:3 Changed 12 years ago by jbronn

milestone: 1.0 beta

comment:4 Changed 12 years ago by denis@…

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 Changed 12 years ago by jbronn

Resolution: fixed
Status: assignedclosed

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

comment:6 Changed 9 years ago by Jacob

milestone: 1.0 beta

Milestone 1.0 beta deleted

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