summaryrefslogtreecommitdiff
blob: 92d90c6df9b444b5a9f0a0ed5f50e4f5c5e47993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 4806955e05011c3d981e91c12a95d84ab3aa65d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Budai?= <obudai@redhat.com>
Date: Fri, 2 Oct 2020 14:24:09 +0200
Subject: [PATCH] fix compatibility with Python 3.9

getchildren() method was removed from the ElementTree and Element classes in
Python 3.9. See the release notes:

https://docs.python.org/3.9/whatsnew/3.9.html#removed
---
 S3/Exceptions.py | 2 +-
 S3/Utils.py      | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/S3/Exceptions.py b/S3/Exceptions.py
index d12c5c5..2710d82 100644
--- a/S3/Exceptions.py
+++ b/S3/Exceptions.py
@@ -126,7 +126,7 @@ class S3Error (S3Exception):
         if not error_node.tag == "Error":
             error_node = tree.find(".//Error")
         if error_node is not None:
-            for child in error_node.getchildren():
+            for child in error_node:
                 if child.text != "":
                     debug("ErrorXML: " + child.tag + ": " + repr(child.text))
                     info[child.tag] = child.text
diff --git a/S3/Utils.py b/S3/Utils.py
index b9f4fd5..1f66f6c 100644
--- a/S3/Utils.py
+++ b/S3/Utils.py
@@ -64,9 +64,9 @@ def parseNodes(nodes):
     retval = []
     for node in nodes:
         retval_item = {}
-        for child in node.getchildren():
+        for child in node:
             name = decode_from_s3(child.tag)
-            if child.getchildren():
+            if len(child):
                 retval_item[name] = parseNodes([child])
             else:
                 found_text = node.findtext(".//%s" % child.tag)
@@ -122,8 +122,8 @@ __all__.append("getListFromXml")
 
 def getDictFromTree(tree):
     ret_dict = {}
-    for child in tree.getchildren():
-        if child.getchildren():
+    for child in tree:
+        if len(child):
             ## Complex-type child. Recurse
             content = getDictFromTree(child)
         else:
-- 
2.26.3