fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info#2134
Open
JSap0914 wants to merge 1 commit into
Open
fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info#2134JSap0914 wants to merge 1 commit into
JSap0914 wants to merge 1 commit into
Conversation
… no source info
When MarkItDown.convert_stream() is called with a ZIP stream that has no
associated URL, local_path, or filename (e.g. a raw io.BytesIO), the
ZipConverter header read:
Content from the zip file `None`:
because stream_info.url, stream_info.local_path, and stream_info.filename
were all None and Python f-strings render None as the literal string 'None'.
Fix: fall back to '(unknown)' when all three source-info fields are absent,
producing the more descriptive:
Content from the zip file `(unknown)`:
Add a regression test in test_module_misc.py that verifies the output does
not contain the literal string 'None' in this scenario.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
When
MarkItDown.convert_stream()is called with a ZIP stream that has no associated URL, local path, or filename (e.g. a rawio.BytesIO), the output header renders the literal PythonNone:This happens because
stream_info.url,stream_info.local_path, andstream_info.filenameare allNone, and Python f-strings formatNoneas the string'None'.Fix
Fall back to
'(unknown)'when all three source-info fields are absent:The header now reads:
Verification