Raise Base64DecodeError instead of ConversionError when base64 decoding fails in Bytes parameters.

ticket 2962
This commit is contained in:
Jan Cholasta 2012-08-14 15:53:25 +02:00 committed by Martin Kosek
parent 2e00a9f45c
commit de63e95de3

View File

@ -109,7 +109,7 @@ from types import NoneType
from text import _ as ugettext
from plugable import ReadOnly, lock, check_name
from errors import ConversionError, RequirementError, ValidationError
from errors import PasswordMismatch
from errors import PasswordMismatch, Base64DecodeError
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
from text import Gettext, FixMe
from ipapython.dn import DN
@ -1452,8 +1452,8 @@ class Bytes(Data):
if isinstance(value, unicode):
try:
value = base64.b64decode(value)
except TypeError:
raise ConversionError(name=self.get_param_name(), index=index, error=self.type_error)
except TypeError, e:
raise Base64DecodeError(reason=str(e))
return super(Bytes, self)._convert_scalar(value, index)