[Gdal-dev] gdal and python exceptions

Amici Alessandro alessandro_amici at telespazio.it
Tue Feb 18 04:56:45 EST 2003


> 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?


More information about the Gdal-dev mailing list