From c86ab88e2d8e319ad918e89826afc8fb61145555 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Wed, 14 Jun 2023 14:36:20 +0300 Subject: [PATCH 1/2] Fix "descriptor '__dict__' for '_OxmlElementBase' objects doesn't apply to a 'CT_*' object" in Py3 The error is generated if the object is not a descendant of the descriptor's type --- docx/oxml/xmlchemy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docx/oxml/xmlchemy.py b/docx/oxml/xmlchemy.py index 46dbf462b..8f08a8375 100644 --- a/docx/oxml/xmlchemy.py +++ b/docx/oxml/xmlchemy.py @@ -755,5 +755,5 @@ def _nsptag(self): BaseOxmlElement = MetaOxmlElement( - 'BaseOxmlElement', (etree.ElementBase,), dict(_OxmlElementBase.__dict__) + 'BaseOxmlElement', (_OxmlElementBase,), dict(_OxmlElementBase.__dict__) ) From d2f6d636b1bd97d7c6e7bf209635835925b37607 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Wed, 14 Jun 2023 16:00:34 +0300 Subject: [PATCH 2/2] Fix breakage after __dict__ fix --- docx/oxml/xmlchemy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docx/oxml/xmlchemy.py b/docx/oxml/xmlchemy.py index 8f08a8375..b12370e4f 100644 --- a/docx/oxml/xmlchemy.py +++ b/docx/oxml/xmlchemy.py @@ -745,7 +745,7 @@ def xpath(self, xpath_str): Override of ``lxml`` _Element.xpath() method to provide standard Open XML namespace mapping (``nsmap``) in centralized location. """ - return super(BaseOxmlElement, self).xpath( + return super(_OxmlElementBase, self).xpath( xpath_str, namespaces=nsmap )