Feature request #3433

GEOSException not exposed through python bindings

Added by rcoup - about 13 years ago. Updated about 13 years ago.

Status:Closed
Priority:Low
Assignee:Borys Jurgiel
Category:Python plugins
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13493

Description

If you try and parse some invalid WKT (or do a number of other bad things), GEOS will throw an error you can't catch from Python, causing the interpreter to crash.

>>> from qgis.core import [[QgsGeometry]]
>>> # WKT has a missing ')'
>>> [[QgsGeometry]].fromWkt("POLYGON((0 0, 1 0, 1 1, 0 0)")
terminate called after throwing an instance of 'GEOSException'
Aborted

ideally a developer should be able to catch it with:

>>> from qgis.core import [[QgsGeometry]], GEOSException
>>> try:
>>>    [[QgsGeometry]].fromWkt("POLYGON((0 0, 1 0, 1 1, 0 0)")
>>> except GEOSException, e:
>>>    print "uh oh, WKT error: %s" % e

History

#1 Updated by Martin Dobias about 13 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

This has been fixed in development version already (520cfc63 (SVN r14905)). It is not possible to catch the exception, you will just get None instead of a valid geometry.

Also available in: Atom PDF