You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexError: pop from empty list in read_fld_char (orphaned fldChar end/separate) #172
Converting a DOCX that contains a Word field marker (w:fldChar) whose w:fldCharType is end or separate without a matching begin crashes with IndexError: pop from empty list in read_fld_char (mammoth/docx/body_xml.py). The complex-field stack is empty, so .pop() raises and the whole conversion fails.
Reproduction
A paragraph with an orphaned field end:
element=xml_element("w:p", {}, [
_run_element_with_text("some text"),
xml_element("w:r", {}, [xml_element("w:fldChar", {"w:fldCharType": "end"})]),
])
_read_and_get_document_xml_element(element) # IndexError: pop from empty list
Added test_fld_char_end_without_matching_begin_is_ignored to tests/docx/body_xml_tests.py. It fails on the current code with IndexError: pop from empty list and passes with the fix. The full tests/docx/body_xml_tests.py passes (157 tests).
Note: tests/cli_tests.py and tests/docx/files_tests.py have pre-existing failures on Windows (POSIX /tmp path expectations) that are unrelated to this change.
Yes — this is a duplicate of #168. Apologies for the noise; I searched markitdown and pdfminer but missed this repository's own issue tracker. Closing this one and moving the marginal value I have (a real-world reproduction file and a ready regression test) over to #168.
Activity
mwilliamson commentedon Sep 9, 2026
Is this not a duplicate of #168?
GokouRuri43 commentedon Sep 9, 2026
Yes — this is a duplicate of #168. Apologies for the noise; I searched markitdown and pdfminer but missed this repository's own issue tracker. Closing this one and moving the marginal value I have (a real-world reproduction file and a ready regression test) over to #168.