From 0d9d22ace6547a6c2f56648d898f43e15631f24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menezes?= <77670471+menezesandre@users.noreply.github.com> Date: Wed, 19 Feb 2025 16:55:45 +0000 Subject: [PATCH] Fix UnboundLocalError in MarkItDown._convert Initialize `res` at the beginning of `_convert`. If the first converter raises an exception, then the `res` variable was not initialized and we got an error when checking `if res is not None` --- packages/markitdown/src/markitdown/_markitdown.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.py index 297f554..7c8d006 100644 --- a/packages/markitdown/src/markitdown/_markitdown.py +++ b/packages/markitdown/src/markitdown/_markitdown.py @@ -312,6 +312,7 @@ class MarkItDown: def _convert( self, local_path: str, extensions: List[Union[str, None]], **kwargs ) -> DocumentConverterResult: + res: Union[None, DocumentConverterResult] = None error_trace = "" # Create a copy of the page_converters list, sorted by priority.