Commit 149f8b2
fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info (#2134)
* fix: ZipConverter emits '(unknown)' instead of 'None' when stream has 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.
* Fixed formatting.
---------
Co-authored-by: JSap0914 <JSap0914@users.noreply.github.com>
Co-authored-by: afourney <adamfo@microsoft.com>1 parent 3661853 commit 149f8b2
2 files changed
Lines changed: 25 additions & 1 deletion
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
785 | 786 | | |
786 | 787 | | |
787 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
788 | 807 | | |
789 | 808 | | |
790 | 809 | | |
| |||
0 commit comments