diff options
Diffstat (limited to 'src/mailman/interfaces')
| -rw-r--r-- | src/mailman/interfaces/address.py | 24 | ||||
| -rw-r--r-- | src/mailman/interfaces/user.py | 13 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/mailman/interfaces/address.py b/src/mailman/interfaces/address.py index 6c371e1c0..cf2c50bf4 100644 --- a/src/mailman/interfaces/address.py +++ b/src/mailman/interfaces/address.py @@ -17,13 +17,14 @@ """Interface for email address related information.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'AddressAlreadyLinkedError', 'AddressError', 'AddressNotLinkedError', + 'EmailError', 'ExistingAddressError', 'IAddress', 'IEmailValidator', @@ -37,15 +38,30 @@ from mailman.interfaces.errors import MailmanError +class EmailError(MailmanError): + """A generic text email address-related error occurred.""" + + def __init__(self, email): + super(EmailError, self).__init__() + self.email = email + + def __str__(self): + # This is a workaround for Python 2.6 support. When self.email + # contains non-ascii characters, this will cause unprintable output in + # doctests. Python 2.7 can handle it but we haven't dropped support + # for 2.6 yet. + return self.email.encode('us-ascii', 'backslashreplace') + + class AddressError(MailmanError): - """A general address-related error occurred.""" + """A generic IAddress-related error occurred.""" def __init__(self, address): super(AddressError, self).__init__() self.address = address def __str__(self): - return self.address + return str(self.address) class ExistingAddressError(AddressError): @@ -60,7 +76,7 @@ class AddressNotLinkedError(AddressError): """The address is not linked to the user.""" -class InvalidEmailAddressError(AddressError): +class InvalidEmailAddressError(EmailError): """Email address is invalid.""" diff --git a/src/mailman/interfaces/user.py b/src/mailman/interfaces/user.py index aba9bcbba..8d0cbfb54 100644 --- a/src/mailman/interfaces/user.py +++ b/src/mailman/interfaces/user.py @@ -17,7 +17,7 @@ """Interface describing the basics of a user.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -28,20 +28,13 @@ __all__ = [ from zope.interface import Interface, Attribute -from mailman.interfaces.errors import MailmanError +from mailman.interfaces.address import AddressError -class UnverifiedAddressError(MailmanError): +class UnverifiedAddressError(AddressError): """Unverified address cannot be used as a user's preferred address.""" - def __init__(self, address): - super(UnverifiedAddressError, self).__init__() - self.address = address - - def __str__(self): - return self.address - class IUser(Interface): |
