diff --git a/swig/include/python/gdal_python.i b/swig/include/python/gdal_python.i index fac167ee295b..67610e5cfc4e 100644 --- a/swig/include/python/gdal_python.i +++ b/swig/include/python/gdal_python.i @@ -5018,6 +5018,7 @@ class VSIFile(BytesIO): self._fp = VSIFOpenExL(self._path, self._mode, True) if self._fp is None: + self._closed = True raise OSError(VSIGetLastErrorMsg()) self._closed = False