Opened 10 years ago

Closed 4 years ago

#4800 closed enhancement (wontfix)

Add levels for the exception handler (UseExceptions() in Python), to listen to

Reported by: dcdgis24 Owned by: hobu
Priority: normal Milestone: closed_because_of_github_migration
Component: PythonBindings Version: unspecified
Severity: normal Keywords: Python, Exception Handling
Cc:

Description

When working with GDAL in Python it would be great if the UseExceptions handler could listen to warnings and debug messages. Something like :

UseExceptions(level=CE_Warning)
UseExceptions(level=CE_Debug)

Right now, I believe it only listens to CE_Error or CE_Fatal. This is great but when I come across some errors or maybe they are warnings the handler was not raising any exception and just hiding the error. For example the following error message was hidden and did not report when UseExceptions was set:

ERROR 5: Access window out of range in RasterIO() Requested (1,15) of size 25x3 on raster of 26x17

I have a stackexchange post about the issue here : http://gis.stackexchange.com/questions/30445/is-there-a-way-to-properly-have-gdal-raise-exceptions-in-python

Thanks,

Doug

Change History (2)

comment:1 by Jukka Rahkonen, 8 years ago

The file which proves that warning and debug messages are skipped is

swig/include/python/python_exceptions.i

 /*
  ** We do not want to interfere with warnings or debug messages since
  ** they won't be translated into exceptions.
  */
  if (eclass == CE_Warning || eclass == CE_Debug ) {
    pfnPreviousHandler(eclass, code, msg );
  }

comment:2 by Even Rouault, 4 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.