[gimp-help] tools: fix crash with older version of libxml2
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-help] tools: fix crash with older version of libxml2
- Date: Mon, 7 Jun 2021 21:00:45 +0000 (UTC)
commit 5fb3e1ea6b3aca0ff58dd61c3a0d134127616c25
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Jun 7 16:57:57 2021 -0400
tools: fix crash with older version of libxml2
The DamnedLies translation website relies on an older version
of libxml2 which apparently doesn't have an interator for
XmlAttr which means our pot files do not get regenerated
and our translations get stuck.
Let's work around this by using an alternative loop that
doesn't use an iterator.
Hopefully this is the only problem, but we will find out
after we commit this.
tools/xml2po/__init__.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/tools/xml2po/__init__.py b/tools/xml2po/__init__.py
index 82fd020fa..735090acd 100644
--- a/tools/xml2po/__init__.py
+++ b/tools/xml2po/__init__.py
@@ -529,9 +529,23 @@ class XMLDocument(object):
# Translate attributes if needed
if node.properties and self.app.current_mode.getTreatedAttributes():
- for p in node.properties:
+ # DamnedLies has an older python3 libxml2 without an iterator for XmlAttr, try to work around it
+ # Version using iterator
+ #for p in node.properties:
+ # if p.name in self.app.current_mode.getTreatedAttributes():
+ # self.processAttribute(node, p)
+
+ # ugly hack to iterate node.properties without iterator
+ p = node.properties
+ while p:
+ prev = p
if p.name in self.app.current_mode.getTreatedAttributes():
self.processAttribute(node, p)
+ p = node.properties.next
+ # It looks like we can't count on p.last
+ # Apparently last node in list points to itself (prev)
+ if p == prev:
+ break
outtxt = ''
if restart:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]