#7873 closed (fixed)
GEOSGeometry equality operator fails on None
Reported by: | 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 )
>>> 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)
Change History (7)
comment:1 by , 16 years ago
Description: | modified (diff) |
---|---|
Keywords: | equals added |
Owner: | changed from | to
by , 16 years ago
Attachment: | geos_eq.diff added |
---|
comment:2 by , 16 years ago
Status: | new → assigned |
---|
On second thought, it would be more pythonic to return False
instead. The attached patch does that.
comment:3 by , 16 years ago
milestone: | → 1.0 beta |
---|
comment:4 by , 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 , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
I agree that a
TypeError
should be raised instead -- at least an error is raised, so this is non-critical at the moment.