Browse Source

Remove lxml deprecated methods

All our supported runtimes [1] are compatible with the recommended
alternatives.

The `getchildren` method is deprecated [2] since lxml 2.0 and will be removed
in future versions, these changes switch usages to `list(elem)` as
recommended in the official documentation [2].

[1] https://governance.openstack.org/tc/reference/runtimes/victoria.html#python-runtimes-for-train
[2] https://lxml.de/api/lxml.etree._Element-class.html#getchildren

Change-Id: I5264edb93532d90703ae7b59cd71520a2cd3518a
changes/68/737468/2
Hervé Beraud 2 weeks ago
parent
commit
e91a3d73ad
3 changed files with 4 additions and 4 deletions
  1. +1
    -1
      swift/common/middleware/s3api/etree.py
  2. +2
    -2
      test/functional/s3api/test_versioning.py
  3. +1
    -1
      test/unit/common/middleware/s3api/test_versioning.py

+ 1
- 1
swift/common/middleware/s3api/etree.py View File

@@ -92,7 +92,7 @@ def tostring(tree, use_s3ns=True, xml_declaration=True):

root = Element(tree.tag, attrib=tree.attrib, nsmap=nsmap)
root.text = tree.text
root.extend(deepcopy(tree.getchildren()))
root.extend(deepcopy(list(tree)))
tree = root

return lxml.etree.tostring(tree, xml_declaration=xml_declaration,


+ 2
- 2
test/functional/s3api/test_versioning.py View File

@@ -58,7 +58,7 @@ class TestS3ApiVersioning(S3ApiBase):
'GET', 'bucket', query='versioning')
self.assertEqual(status, 200)
elem = fromstring(body)
self.assertEqual(elem.getchildren(), [])
self.assertEqual(list(elem), [])

# Enable versioning
elem = Element('VersioningConfiguration')
@@ -108,7 +108,7 @@ class TestS3ApiVersioning(S3ApiBase):
'GET', 'bucket', query='versioning')
self.assertEqual(status, 200)
elem = fromstring(body)
self.assertEqual(elem.getchildren(), [])
self.assertEqual(list(elem), [])

# Suspend versioning
elem = Element('VersioningConfiguration')


+ 1
- 1
test/unit/common/middleware/s3api/test_versioning.py View File

@@ -42,7 +42,7 @@ class TestS3ApiVersioning(S3ApiTestCase):
status, headers, body = self._versioning_GET(path)
self.assertEqual(status.split()[0], '200')
elem = fromstring(body, 'VersioningConfiguration')
self.assertEqual(elem.getchildren(), [])
self.assertEqual(list(elem), [])

def _versioning_GET_enabled(self, path):
self.swift.register('HEAD', '/v1/AUTH_test/bucket', HTTPNoContent, {


Loading…
Cancel
Save