ubarsc / rios

A raster processing layer on top of GDAL
https://www.rioshome.org
GNU General Public License v3.0
14 stars 7 forks source link

suppress GDAL testsuite warning by calling gdal.UseExceptions() #65

Closed gillins closed 1 year ago

gillins commented 1 year ago

Also tidy formatting of setup.py.

Warnings come about in recent GDAL versions in preparation for GDAL 4.0.

I found just calling gdal.UseExceptions() in one place seemed to quieten the warnings for all the test*.py files, although the problem may still lurk if you specifically imported and ran one test. I'm not sure this is a common scenario.

neilflood commented 1 year ago

That's good, thank you.

You are correct, calling in one place is all that is required. The UseExceptions flag is a single global state which holds for the whole Python interpreter, so if it is called anywhere, it applies everywhere. This has always been one of its problems, and was why I made that context manager for it a while back. In this case, we really only want to call it in the main program, so that it does not apply for other people's scripts (and thus hide the warning for them). However, in this world of entry points, there is no main program, so the next best possibility is what you have done here.

Thanks again.