Conversation
…tronInfo.xml ElementTree parses an existing xsi:schemaLocation attribute into Clark notation rather than its literal form, so re-adding the canonical attribute in _get_root() left both present and caused ET.tostring() to emit a second, auto-generated xmlns:xsi declaration. Strip any existing XSI-namespaced attribute before re-adding the canonical one. Fixes #238
metadata_from_string() and read_xml() previously caught ParseError and returned an empty Metadata(), hiding real corruption from callers that use MetronInfo/ComicInfo/BaseMetadataHandler directly. Comic already wraps these calls and logs the exception, so this only changes behavior for direct API consumers, who now get a signal instead of silent data loss.
bpepple
deleted the
238-metroninfowrite_xml-produces-invalid-xml-with-duplicate-xmlnsxsixsischemalocation-attributes-when-merging-into-an-existing-metroninfoxml
branch
July 19, 2026 18:48
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.
Summary
MetronInfo._get_root()producing invalid XML (duplicatexmlns:xsiandxsi:schemaLocationattributes) when merging metadata into an existing MetronInfo.xml. ElementTree parses an existingxsi:schemaLocationattribute into Clark notation rather than its literal form, so re-adding the canonical attribute left both present, andET.tostring()auto-generated a secondxmlns:xsideclaration for the Clark-notation one.metadata_from_string()(MetronInfo/ComicInfo) andBaseMetadataHandler.read_xml()now raiseXmlErroron unparseable XML instead of silently swallowing the failure and returning an emptyMetadata(), which hid real corruption from callers.Behavior change
Callers that invoke
MetronInfo.metadata_from_string(),ComicInfo.metadata_from_string(), orBaseMetadataHandler.read_xml()directly with malformed XML will now see anXmlErrorraised instead of getting back an emptyMetadata(). Code that doesn't wrap these calls in atry/exceptwill need to handle this.Comicusers are unaffected:Comic._parse_metadata()already wraps these calls intry/except Exceptionand logs vialogger.exception(...), soComic.read_metadata()continues to degrade gracefully to an emptyMetadata()on parse failure — it now also logs a clearer error.Fixes #238