Opened 13 years ago

Closed 13 years ago

#3433 closed enhancement (fixed)

GEOSException not exposed through python bindings

Reported by: rcoup Owned by: borysiasty
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Python plugins and bindings Version: 1.6.0
Keywords: geos Cc:
Must Fix for Release: No Platform: Debian
Platform Version: Awaiting user input: no

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

Change History (1)

comment:1 by wonder, 13 years ago

Milestone: Version 1.7.0
Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.