diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-12-05 19:29:10 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-12-05 19:29:10 +0000 |
| commit | 414cb49cd08d4952cf5eff51bd9e2da811c4661b (patch) | |
| tree | b237b5f402d7f7f5f80c6c93bc1c3415e9cfe146 /mammoth/docx/__init__.py | |
| parent | 3646167ab5685ea5a69de24442cf46e963bf7f41 (diff) | |
Revert "Handle XML documents that are missing a root element"
This reverts commit 659c4ffe6ade2d8132873ae3f3f3a22df38fdb37.
Diffstat (limited to 'mammoth/docx/__init__.py')
| -rw-r--r-- | mammoth/docx/__init__.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py index 0579d09..0c7241d 100644 --- a/mammoth/docx/__init__.py +++ b/mammoth/docx/__init__.py @@ -12,7 +12,7 @@ from .styles_xml import read_styles_xml_element, Styles from .notes_xml import read_endnotes_xml_element, read_footnotes_xml_element from .comments_xml import read_comments_xml_element from .files import Files -from . import body_xml, office_xml, xmlparser +from . import body_xml, office_xml from ..zips import open_zip @@ -130,17 +130,14 @@ def _read_comments(read_part_with_body, part_paths): def _read_document(read_part_with_body, notes, comments, part_paths): - try: - return read_part_with_body( - part_paths.main_document, - partial( - read_document_xml_element, - notes=notes, - comments=comments, - ), - ) - except xmlparser.NoRootElementError: - raise IOError("Main document part is missing root element. Are you sure this is a valid .docx file?") + return read_part_with_body( + part_paths.main_document, + partial( + read_document_xml_element, + notes=notes, + comments=comments, + ), + ) def _part_with_body_reader(document_path, zip_file, part_paths, external_file_access): @@ -206,10 +203,7 @@ def _read_relationships(zip_file, name): def _try_read_entry_or_default(zip_file, name, reader, default): if zip_file.exists(name): - try: - return _read_entry(zip_file, name, reader) - except xmlparser.NoRootElementError: - return default + return _read_entry(zip_file, name, reader) else: return default |
