[gdal-dev] Error handlers in Python bindings

Fabian Schindler fabian.schindler at eox.at
Wed Jul 11 03:15:50 PDT 2012

Hey folks,

I'd like to know how I could set a custom error handling function in the 
GDAL Python bindings?

Currently I was able to turn off error messages like so:

 >>> gdal.PushErrorHandler("CPLQuietErrorHandler")

What I want is something like this:

 >>> def f(error):
...    logger.error(error)
 >>> gdal.PushErrorHandler(f)

But I get the following error:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.6/dist-packages/osgeo/gdal.py", line 312, in 
     return _gdal.PushErrorHandler(*args)
NotImplementedError: Wrong number of arguments for overloaded function 
   Possible C/C++ prototypes are:
     PushErrorHandler(char const *)

If possible, I'd like a solution that works with 1.8.


More information about the gdal-dev mailing list