diff --git a/nibabel/openers.py b/nibabel/openers.py index 90c7774d1..9a024680a 100644 --- a/nibabel/openers.py +++ b/nibabel/openers.py @@ -78,6 +78,12 @@ def __init__( mtime=mtime, ) + def seek(self, pos: int, whence: int = 0, /) -> int: + # Work around bug (gh-180111) in Python 3.12rc1, where seeking without + # flushing can cause write of excess null bytes + self.flush() + return super().seek(pos, whence) + def _gzip_open( filename: str,