File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,9 @@ def _load_unix(self, model_path: Path) -> Any:
190190 """Load model on Unix-like systems."""
191191 try :
192192 return fasttext .load_model (str (model_path ))
193+ except MemoryError as e :
194+ # Let MemoryError propagate up to be handled by _get_model
195+ raise e
193196 except Exception as e :
194197 raise DetectError (f"fast-langdetect: Failed to load model: { e } " )
195198
@@ -317,7 +320,7 @@ def _get_model(self, low_memory: bool = True) -> Any:
317320 )
318321 self ._models [cache_key ] = model
319322 return model
320- except Exception as e :
323+ except MemoryError as e :
321324 if low_memory is not True and self .config .allow_fallback :
322325 logger .info ("fast-langdetect: Falling back to low-memory model..." )
323326 return self ._get_model (low_memory = True )
You can’t perform that action at this time.
0 commit comments