tiff: Ensure consistent error for invalid tile sizes

GDAL 3.12 now has a more specific error for incorrect tile size [1], but
for backwards compatibility, catch that and raise the same one that used
to be raised.

[1] https://github.com/OSGeo/gdal/pull/12679
This commit is contained in:
Elliott Sales de Andrade 2025-09-07 15:26:02 -04:00 committed by Alan Snow
parent c6f5db5411
commit a6bfd47fa5

View File

@ -1531,8 +1531,15 @@ cdef class DatasetWriterBase(DatasetReaderBase):
GDALCreate(drv, fname, width, height, count, gdal_dtype, options)
)
except CPLE_IllegalArgError as exc:
if "must be a multiple of 16" in str(exc): # For GDAL 3.12+.
raise RasterBlockError(
"The height and width of TIFF dataset blocks must be multiples of 16"
)
else:
raise RasterioIOError(str(exc))
except CPLE_AppDefinedError as exc:
if "Bad value" in str(exc):
if "Bad value" in str(exc): # For GDAL < 3.12.
raise RasterBlockError(
"The height and width of TIFF dataset blocks must be multiples of 16"
)