From 51ba03e6cddb8de78fe3e60cddb0f6093cad0621 Mon Sep 17 00:00:00 2001 From: Theodore Chang Date: Sat, 1 Jun 2024 00:16:03 +0200 Subject: [PATCH] Safer detection --- src/msglc/reader.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/msglc/reader.py b/src/msglc/reader.py index 23c2717..1bbcd69 100644 --- a/src/msglc/reader.py +++ b/src/msglc/reader.py @@ -125,9 +125,7 @@ def _child(self, toc: dict | int): # {"p": [start_pos, end_pos]} # this is used in small objects if 2 == len(child_pos := toc["p"]) and all(isinstance(x, int) for x in child_pos): - if isinstance(data := self._read(*child_pos), bytes) and data.startswith( - b"\x80\x02cnumpy.core.multiarray" - ): + if isinstance(data := self._read(*child_pos), bytes) and b"numpy.core.multiarray" in data[:40]: return pickle.loads(data) return data