- Notifications
You must be signed in to change notification settings - Fork1.2k
fix zipfile.py 'UserWarning: Duplicate name: docProps/core.xml'#1436
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/docx/opc/package.py Outdated
try: | ||
office_document_part = self.part_related_by(RT.CORE_PROPERTIES_OFFICEDOCUMENT) | ||
rel = self.relate_to(office_document_part, RT.CORE_PROPERTIES_OFFICEDOCUMENT) | ||
self.rels[rel].set_reltype(RT.CORE_PROPERTIES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
First see below how to create asetter
. Then change this line to
self.rels[rel].reltype=RT.CORE_PROPERTIES
src/docx/opc/rel.py Outdated
def set_reltype(self, reltype:str) -> None: | ||
self._reltype = reltype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This should be asetter
@reltype.setterdefreltype(self,value:str):self._reltype=value
rafguns commentedMay 21, 2025
Hi@cip91sk , anything I can do to help this PR along? I would add the requested changes myself but I can't (at least not in this PR) since I'm not a maintainer. |
Sorry for the delay, I missed the previous messages. I corrected with a proper setter, let me know if it's all good now! |
Some documents in _rels/.rels, for the relation the targets "docProps/core.xml", have the relationship type
http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties
instead of
http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties
In these cases, python-docx doesn't see that the core-properties are already set, it creates new ones and append a duplicate docProps/core.xml file in the zip