Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to regular diff in case of malformed xml #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anat0lius
Copy link

Avoids crashing when comparing malformed xml files

@joh joh self-requested a review June 4, 2021 14:34
Copy link
Owner

@joh joh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, with this change we simply ignore errors and fall back to a regular diff of the original files instead. I suppose this is ok, but the user should be presented with a warning when any of the input files are malformed, warning them that the tool falls back to a regular diff...

tmp1.flush()
actual = tmp1.name
except ET.ParseError:
actual = file1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in case the XML has errors, we simply fall back to a diff of the original files?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

Copy link
Author

@anat0lius anat0lius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a warning, indeed, but then it will break the integration with other programs where you don't want or expect other kind of outputs (which is my case). I guess the good way would be to use a logger and pass a parameter to run in silence. An alternative is to just document this (logical) behavior in the README.

tmp1.flush()
actual = tmp1.name
except ET.ParseError:
actual = file1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

@anat0lius anat0lius changed the title Added handling of malformed xml files Add handling of malformed xml files Feb 17, 2022
@anat0lius anat0lius changed the title Add handling of malformed xml files Fall back to regular diff in case of malformed xml Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants