Python: make gdal.UseExceptions() default to True
It's been more than 15 years since UseExceptions was introduced with a default to False to preserve backward compatibility with the ancient GDAL Python bindings.
It is now time that those programmers who still have code depending on GDAL's behavior of not throwing need to update their code.
The biggest hurdle will be GDAL's autotest suite, that relies on not-throwing in a likely big number of places. I guess the reasonable thing to do would be to have autotest run with gdal.DontUseExceptions() by default, and convert test files one by one to make them work properly with gdal.UseExceptions()
GDAL Python scripts will likely need changes to make them work with exceptions enabled
One way to help users with the transition might be to put a check in, say, gdal.Open that prints a warning if neither gdal.UseExceptions() nor gdal.DontUseExceptions() has not been called. I think it's well documented to call gdal.UseExceptions() if exceptions are wanted. I'm not sure an expectation has been communicated that people should call gdal.DontUseExceptions() if they don't want them.
On a related note, a little while ago I added a context manager called ExceptionMgr to make it much easier to switch between the two states. #6637 That may help with the process of converting.
I would also have loved exceptions to be on by default, but it feels like a huge job to change over.
That may help with the process of converting.
It's heavily used in https://github.com/OSGeo/gdal/pull/7475
That may help with the process of converting.
It's heavily used in #7475
Ah, very good! :-)
Assigning milestone 4.0 for that one. In PR #7452, we set some grounds to make that happen