From 02572bb5801506b75b3aabb52e0c4e20c1804a2f Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 23 Aug 2023 10:27:01 -0400 Subject: [PATCH] FIX: Hack around 3.12rc1 bug (python/cpython#108111) --- nibabel/openers.py | 6 ++++++ 1 file changed, 6 insertions(+) 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,