autotest: replace gdal.OpenEx() with gdal.Open()#14764
Open
rouault wants to merge 4 commits into
Open
Conversation
9e27dc4 to
79099e2
Compare
elpaso
approved these changes
Jun 12, 2026
…enEx()
The naming of gdal.OpenEx() felt always a bit awkward. The signatures of the 2
methods were compatible in that gdal.ReadOnly == gdal.OF_READONLY and
gdal.Update == gdal.OF_UPDATE.
Another advantage is that you can now gdal.Open() both a raster or a
vector.
There are 2 (hopefully to be considered minor?) changes of behavior
associated with that change:
1. :py:func:`gdal.Open` used to open only datasets in raster mode, or fail.
If no ``flags`` parameter is passed (or none of ``gdal.OF_RASTER``,
``gdal.OF_VECTOR``, ``gdal.OF_MULTIDIM_RASTER`` is set), all of them are
set to allow any GDAL-recognized dataset to be opened. This is a change of
behavior for GDAL < 3.14 users of :py:func:`Open` where this method
behaved as setting only ``gdal.OF_RASTER``. If opening vector or
multidimensional raster datasets with :py:func:`Open` is not desired,
``gdal.OF_RASTER`` must be explicitly passed.
2. Another change is related to error handling.
Before that PR:
- gdal.Open() was indirectly calling GDALOpenEx() with
GDAL_OF_VERBOSE_ERROR set
- gdal.OpenEx() in gdal.UseException() mode was also setting
GDAL_OF_VERBOSE_ERROR, even if the open_flags parameter did not set
it.
- gdal.OpenEx() in gdal.DontUseExceptions() mode was *not* setting
automatially GDAL_OF_VERBOSE_ERROR
To minimize disruption for existing gdal.Open() users that relied on
GDAL_OF_VERBOSE_ERROR being set, the new unified gdal.Open/gdal.OpenEx
also always set it.
The only backward incompabible change is for users of gdal.OpenEx() that
used the gdal.DontUseExceptions() mode and didn't pass GDAL_OF_VERBOSE_ERROR.
They can get back past behavior by setting the new gdal.OF_SILENT_ERROR
constant. It is hoped that this change only causes minor disruption.
This commit only contains the minimum changes to make regression test
suite pass. If accepted, all gdal.OpenEx() uses will be renamed to
gdal.Open()
79099e2 to
783f2d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuation of PR #14763 with the result of
find ../autotest/ -name "*.py" -exec sed -i "s/gdal.OpenEx/gdal.Open/g" {} \;, and test_basic_test_11() extended to check that gdal.Open() and gdal.OpenEx() behave the same