Merge "Remove DeprecationWarning of "decodestring()""

This commit is contained in:
Zuul 2018-12-08 09:37:49 +00:00 committed by Gerrit Code Review
commit 30d0de2110

View File

@ -18,11 +18,11 @@ Internal implementation of request Body validating middleware.
""" """
import base64
import re import re
import jsonschema import jsonschema
from jsonschema import exceptions as jsonschema_exc from jsonschema import exceptions as jsonschema_exc
from oslo_serialization import base64
from oslo_utils import strutils from oslo_utils import strutils
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
@ -199,9 +199,7 @@ def _validate_base64_format(instance):
try: try:
if isinstance(instance, six.text_type): if isinstance(instance, six.text_type):
instance = instance.encode('utf-8') instance = instance.encode('utf-8')
base64.decodestring(instance) base64.decode_as_bytes(instance)
except base64.binascii.Error:
return False
except TypeError: except TypeError:
# The name must be string type. If instance isn't string type, the # The name must be string type. If instance isn't string type, the
# TypeError will be raised at here. # TypeError will be raised at here.