[Gdal-dev] gdal and python exceptions

Frank Warmerdam warmerdam at pobox.com
Tue Feb 18 09:34:52 EST 2003


Amici Alessandro wrote:
> Frank,
> 
> 
>>there is significant use of Python going on too.
> 
> 
> I am one using mainly the python bindings and I'd like to point out
> one of my wishlist items:
> 
> gdal.Open(filename) returns None in case of failure. But, raising an IOError
> exception wuold be more consistent with the python style. Similarly for
> other error conditions (i.e. GetDriverByName(), Driver.Create(), etc).
> I understand this wuold be a significant interface change, that you might
> be reluctant to implement. But please note that I end up doing:
> 
> 	im = gdal.Open(filename)
> 	if im is None:
> 		raise IOError, 'Could not open "$s"' % filename
> 
> quite often anyhow. Moreover, right now the gdal related code ends up being
> obfuscated by numerous error-handling paths needed.
> IMHO most of that could be avoided with the use of exceptions.
> 
> Frank, waht do you think? Should I file a wishlist bug?

Alessandro,

I agree this would be a desirable change ... for the OGR open function as well.
Please file as a feature request.  I don't want to make the change till I can
take the time to add the corresponding exception catching in OpenEV though.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list