Fix UnboundLocalError in MarkItDown._convert (#1038)

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`
This commit is contained in:
André Menezes
2025-02-28 07:11:27 +00:00
committed by GitHub
parent e4b419ba40
commit d0ed74fdf4

View File

@@ -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.