[gdal-dev] exceptions in bindings

Ari Jolma ari.jolma at tkk.fi
Thu Jul 24 03:31:41 EDT 2008


Hobu,

Still looking at the GetHistogram binding, one thing that puzzles me is 
the CPLErrorReset call. It is there and it is also in all the 
Operations.i bindings. In Perl that leads to it being called twice 
(which probably does no harm), because all methods are wrapped by 
cpl_exceptions.i with it:

CPLErrorReset();
$action
CPLErr eclass = CPLGetLastErrorType();
... check the eclass and possibly throw an exception

But cpl_exceptions.i does not seem to be used by Python, which has its 
python_exceptions.i. It is very similar to cpl_exceptions.i but lacks 
the CPLErrorReset() call. I don't understand the comment in 
python_exceptions.i:

"This was the cpl_exceptions.i code. But since python is the only one 
different (should support old method as well as new one) it was moved 
into this file."

Is there a particular reason for not having CPLErrorReset() in the 
%exception for Python? Does the comment mean that somebody thought of 
deleting cpl_exceptions.i?

I'm also adding the IF_ERROR_RETURN_NONE specifically for GetHistogram 
although I think it should probably be the default for Perl. The name is 
also misleading at least in the Perl case as it really means "do not 
return the error code (since we're using exceptions)".

Regards,

Ari

-- 
Prof. Ari Jolma
Geoinformatiikka / Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma



More information about the gdal-dev mailing list