Unverified Commit 52ca282e authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #17679 from mvdbeek/fix_npz_sniffer

[23.2] Assert that at least one file in npz zipfile ends with .npy
parents 93eb541e fd5fd152
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4297,8 +4297,8 @@ class Npz(CompressedArchive):

    def sniff(self, filename: str) -> bool:
        try:
            npz = np.load(filename)
            if isinstance(npz, np.lib.npyio.NpzFile):
            with np.load(filename) as npz:
                if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist):
                    return True
        except Exception:
            return False