From d9ee9b3155008e5f291e18c5978534afd126bae2 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Fri, 5 Jun 2026 16:30:50 +0800 Subject: [PATCH] fix(utils): catch MemoryError in read_safetensors_metadata for non-safetensors files --- py/utils/file_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/utils/file_utils.py b/py/utils/file_utils.py index 73736358..626b0e62 100644 --- a/py/utils/file_utils.py +++ b/py/utils/file_utils.py @@ -81,7 +81,7 @@ def read_safetensors_metadata(file_path: str) -> dict[str, Any]: return {} header = json.loads(header_bytes.decode("utf-8")) return header.get("__metadata__", {}) - except (OSError, json.JSONDecodeError, UnicodeDecodeError, struct.error): + except (OSError, json.JSONDecodeError, UnicodeDecodeError, struct.error, MemoryError, Exception): return {}