From e6f0adcbc340fe5a122536ad5bc0af332ab33cbb Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Sat, 17 Oct 2020 22:53:55 +0200 Subject: [PATCH] Python 3.9: base64.{en,de}codestring function is removed We must use base64.{en,de}codebytes instead, which has been around for a very long time already. Change-Id: I7f4d522b4b1c32c1d338aba8076b0aa89c82181b --- ironic/api/types.py | 4 ++-- ironic/tests/unit/api/test_types.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ironic/api/types.py b/ironic/api/types.py index b022e50a3a..55b26ab0eb 100644 --- a/ironic/api/types.py +++ b/ironic/api/types.py @@ -142,12 +142,12 @@ class BinaryType(UserType): def tobasetype(self, value): if value is None: return None - return base64.encodestring(value) + return base64.encodebytes(value) def frombasetype(self, value): if value is None: return None - return base64.decodestring(value) + return base64.decodebytes(value) #: The binary almost-native type diff --git a/ironic/tests/unit/api/test_types.py b/ironic/tests/unit/api/test_types.py index fb39ff2b77..d61825cf4d 100644 --- a/ironic/tests/unit/api/test_types.py +++ b/ironic/tests/unit/api/test_types.py @@ -446,13 +446,13 @@ Value: 'v3'. Value should be one of: v., v.", def test_binary_to_base(self): import base64 assert types.binary.tobasetype(None) is None - expected = base64.encodestring(b'abcdef') + expected = base64.encodebytes(b'abcdef') assert types.binary.tobasetype(b'abcdef') == expected def test_binary_from_base(self): import base64 assert types.binary.frombasetype(None) is None - encoded = base64.encodestring(b'abcdef') + encoded = base64.encodebytes(b'abcdef') assert types.binary.frombasetype(encoded) == b'abcdef' def test_wsattr_weakref_datatype(self):