cubicweb/_exceptions.py
branch3.24
changeset 11917 c38e13988c10
parent 11767 432f87a63057
child 12342 57e06dd166d4
equal deleted inserted replaced
11909:244cd7f407b8 11917:c38e13988c10
    19 
    19 
    20 
    20 
    21 
    21 
    22 from warnings import warn
    22 from warnings import warn
    23 
    23 
    24 from six import PY3, text_type
    24 from six import PY2, text_type
    25 
    25 
    26 from logilab.common.decorators import cachedproperty
    26 from logilab.common.decorators import cachedproperty
    27 
    27 
    28 from yams import ValidationError
    28 from yams import ValidationError
    29 
    29 
    38                 return self.msg % tuple(self.args)
    38                 return self.msg % tuple(self.args)
    39             else:
    39             else:
    40                 return self.msg
    40                 return self.msg
    41         else:
    41         else:
    42             return u' '.join(text_type(arg) for arg in self.args)
    42             return u' '.join(text_type(arg) for arg in self.args)
    43     __str__ = __unicode__ if PY3 else lambda self: self.__unicode__().encode('utf-8')
    43 
       
    44     def __str__(self):
       
    45         res = self.__unicode__()
       
    46         if PY2:
       
    47             res = res.encode('utf-8')
       
    48         return res
       
    49 
    44 
    50 
    45 class ConfigurationError(CubicWebException):
    51 class ConfigurationError(CubicWebException):
    46     """a misconfiguration error"""
    52     """a misconfiguration error"""
    47 
    53 
    48 class InternalError(CubicWebException):
    54 class InternalError(CubicWebException):