From d13622f27472858e70327cf66eb11d834069ee25 Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Fri, 2 Nov 2018 15:07:05 +0700 Subject: [PATCH] Replace deprecated "decodestring" decodestring() is a deprecated alias, use decodebytes() https://docs.python.org/3.1/library/base64.html#base64.decodestring This patch helps to remove this deprecation alias by replacing "base64.decodestring" with "oslo_serialization.base64.decode_as_bytes". The same has been done for nova: https://review.openstack.org/#/c/610401/ Change-Id: Ibba785b8f9b27a74344c27dc952a8782f10fa697 --- tempest/lib/common/jsonschema_validator.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tempest/lib/common/jsonschema_validator.py b/tempest/lib/common/jsonschema_validator.py index 9a35b76217..bbf5e89bad 100644 --- a/tempest/lib/common/jsonschema_validator.py +++ b/tempest/lib/common/jsonschema_validator.py @@ -12,9 +12,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import base64 - import jsonschema +from oslo_serialization import base64 from oslo_utils import timeutils import six @@ -46,9 +45,7 @@ def _validate_base64_format(instance): try: if isinstance(instance, six.text_type): instance = instance.encode('utf-8') - base64.decodestring(instance) - except base64.binascii.Error: - return False + base64.decode_as_bytes(instance) except TypeError: # The name must be string type. If instance isn't string type, the # TypeError will be raised at here.