Skip to content

autotest: replace gdal.OpenEx() with gdal.Open()#14764

Open
rouault wants to merge 4 commits into
OSGeo:masterfrom
rouault:autotest_openex_removal
Open

autotest: replace gdal.OpenEx() with gdal.Open()#14764
rouault wants to merge 4 commits into
OSGeo:masterfrom
rouault:autotest_openex_removal

Conversation

@rouault

@rouault rouault commented Jun 10, 2026

Copy link
Copy Markdown
Member

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

@rouault rouault force-pushed the autotest_openex_removal branch 6 times, most recently from 9e27dc4 to 79099e2 Compare June 12, 2026 02:59
rouault added 4 commits June 15, 2026 09:06
…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()
@rouault rouault force-pushed the autotest_openex_removal branch from 79099e2 to 783f2d2 Compare June 15, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants