Description: Fix test failures with Python 3.15
 In Python 3.15, gzip.GzipFile changed its default compresslevel from 9 to 6.
 Allow DeterministicGzipFile to inherit the default compresslevel from GzipFile
 when unspecified instead of hardcoding 9.
Author: Maximiliano Curia <maxy@debian.org>
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: nibabel/nibabel/_compression.py
===================================================================
--- nibabel.orig/nibabel/_compression.py
+++ nibabel/nibabel/_compression.py
@@ -82,7 +82,7 @@ class DeterministicGzipFile(gzip.GzipFil
         self,
         filename: str | None = None,
         mode: Mode | None = None,
-        compresslevel: int = 9,
+        compresslevel: int | None = None,
         fileobj: io.FileIO | None = None,
         mtime: int = 0,
     ):
@@ -99,19 +99,22 @@ class DeterministicGzipFile(gzip.GzipFil
                 raise TypeError('Must define either fileobj or filename')
             # Cast because GzipFile.myfileobj has type io.FileIO while open returns ty.IO
             fileobj = self.myfileobj = ty.cast('io.FileIO', open(filename, modestr))
+        kwargs = {}
+        if compresslevel is not None:
+            kwargs['compresslevel'] = compresslevel
         super().__init__(
             filename='',
             mode=modestr,
-            compresslevel=compresslevel,
             fileobj=fileobj,
             mtime=mtime,
+            **kwargs,
         )
 
 
 def gzip_open(
     filename: str,
     mode: Mode = 'rb',
-    compresslevel: int = 9,
+    compresslevel: int | None = None,
     mtime: int = 0,
     keep_open: bool = False,
 ) -> gzip.GzipFile:
