MAINT: Handle XML error when reading XmpInformation#1030
Conversation
Closes: 585
Codecov Report
@@ Coverage Diff @@
## main #1030 +/- ##
==========================================
- Coverage 89.93% 89.90% -0.04%
==========================================
Files 24 24
Lines 4482 4488 +6
Branches 916 916
==========================================
+ Hits 4031 4035 +4
- Misses 308 310 +2
Partials 143 143
Continue to review full report at Codecov.
|
|
It would be nice if |
|
I guess "None" would then be a reasonable return value? |
|
Absolutely! And thank you for maintaining PyPDF2, it looks in a way better shape. |
PyPDF2/xmp.py
Outdated
| data = self.stream.get_data() | ||
| doc_root: Document = parseString(data) | ||
| except ExpatError: | ||
| raise PdfReadError("XML in XmpInformation was invalid") |
There was a problem hiding this comment.
Consider including diagnostic information contained in the ExpactError object (line, offset, kind of XML issue)/
Example:
except ExpatError as e:
print("Got some XML error. " + str(e))
|
Thanks @MartinThoma for the fix. I added a minor comment to include more diagnostic info in the exception. Thanks for you work maintaining PyPDF2. |
|
Adding a non-strict mode (that passes the value down from the reader) touches more things than I initially thought. I think for the moment I'll leave this out. |
New Features (ENH): - Add writer.pdf_header property (getter and setter) (#1038) Performance Improvements (PI): - Remove b_ call in FloatObject.write_to_stream (#1044) - Check duplicate objects in writer._sweep_indirect_references (#207) Documentation (DOC): - How to surppress exceptions/warnings/log messages (#1037) - Remove hyphen from lossless (#1041) - Compression of content streams (#1040) - Fix inconsistent variable names in add-watermark.md (#1039) - File size reduction - Add CHANGELOG to the rendered docs (#1023) Maintenance (MAINT): - Handle XML error when reading XmpInformation (#1030) - Deduplicate Code / add mutmut config (#1022) Code Style (STY): - Use unnecessary one-line function / class attribute (#1043) - Docstring formatting (#1033) Full Changelog: 2.4.0...2.4.1
Closes #585