mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add message property to IPA's errors and warnings under Python 3
Python 3 removes the "message" attribute from exceptions, in favor of just calling str(). Add it back for IPA's own exception types. Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
committed by
Tomas Babej
parent
905d81f500
commit
b71fd2d3c9
@@ -102,6 +102,8 @@ current block assignments:
|
||||
- **5100 - 5999** *Reserved for future use*
|
||||
"""
|
||||
|
||||
import six
|
||||
|
||||
from ipalib.text import ngettext as ungettext
|
||||
from ipalib import messages
|
||||
from ipaplatform.paths import paths
|
||||
@@ -124,6 +126,11 @@ class PrivateError(Exception):
|
||||
setattr(self, key, value)
|
||||
Exception.__init__(self, self.msg)
|
||||
|
||||
if six.PY3:
|
||||
@property
|
||||
def message(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
class SubprocessError(PrivateError):
|
||||
"""
|
||||
@@ -251,6 +258,11 @@ class PublicError(Exception):
|
||||
rval = 1
|
||||
format = None
|
||||
|
||||
if six.PY3:
|
||||
@property
|
||||
def message(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
class VersionError(PublicError):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user