Merge "Fix deprecated base64.decodestring warning"

This commit is contained in:
Zuul 2018-10-19 16:52:25 +00:00 committed by Gerrit Code Review
commit 5b815eec4c
1 changed files with 2 additions and 4 deletions

View File

@ -16,12 +16,12 @@ Internal implementation of request Body validating middleware.
"""
import base64
import re
import jsonschema
from jsonschema import exceptions as jsonschema_exc
import netaddr
from oslo_serialization import base64
from oslo_utils import timeutils
from oslo_utils import uuidutils
import rfc3986
@ -58,9 +58,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.