Python tool for converting files and office documents to Markdown.
fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info (#2134)
JSap0914149f8b21146b
diff --git a/packages/markitdown/src/markitdown/converters/_zip_converter.py b/packages/markitdown/src/markitdown/converters/_zip_converter.pyindex f87e6c89..3d388a78 100644--- a/packages/markitdown/src/markitdown/converters/_zip_converter.py+++ b/packages/markitdown/src/markitdown/converters/_zip_converter.py@@ -90,7 +90,12 @@ class ZipConverter(DocumentConverter):stream_info: StreamInfo,**kwargs: Any, # Options to pass to the converter) -> DocumentConverterResult:- file_path = stream_info.url or stream_info.local_path or stream_info.filename+ file_path = (+ stream_info.url+ or stream_info.local_path+ or stream_info.filename+ or "(unknown)"+ )md_content = f"Content from the zip file `{file_path}`:\n\n"with zipfile.ZipFile(file_stream, "r") as zipObj:diff --git a/packages/markitdown/tests/test_module_misc.py b/packages/markitdown/tests/test_module_misc.pyindex 39a8c20d..7001b42b 100644--- a/packages/markitdown/tests/test_module_misc.py+++ b/packages/markitdown/tests/test_module_misc.py@@ -5,6 +5,7 @@ import ntpathimport osimport reimport shutil+import zipfilefrom types import SimpleNamespaceimport pytestfrom unittest.mock import MagicMock@@ -785,6 +786,24 @@ def test_markitdown_llm() -> None:validate_strings(result, PPTX_TEST_STRINGS)+def test_zip_stream_no_filename_header() -> None:+ """Regression test: ZipConverter must not render the literal string 'None'+ in the output header when the stream has no associated URL, local path, or+ filename (e.g. when called via convert_stream() without stream_info)."""+ markitdown = MarkItDown()++ buf = io.BytesIO()+ with zipfile.ZipFile(buf, "w") as zf:+ zf.writestr("hello.txt", "Hello world")+ buf.seek(0)++ result = markitdown.convert_stream(+ buf, stream_info=StreamInfo(mimetype="application/zip")+ )+ assert result.markdown.startswith("Content from the zip file `(unknown)`:\n\n")+ assert "Hello world" in result.markdown++def test_ipynb_accepts_non_ascii() -> None:"""IpynbConverter.accepts() must not raise on non-ASCII binary content."""from markitdown.converters._ipynb_converter import IpynbConverter