The __repr__ method of the user object doesn't handle non-ascii display names
The __repr__
method for the user
object in mailmanclient/restobjects/user.py
throws a UnicodeEncodeError
in a Python 2 environment if the user's display_name contains non-ascii.
I worked around this with the following patch:
--- a/src/mailmanclient/restobjects/user.py
+++ b/src/mailmanclient/restobjects/user.py
@@ -38,7 +38,10 @@ class User(RESTObject, PreferencesMixin):
self._subscription_list_ids = None
def __repr__(self):
- return '<User "{0}" ({1})>'.format(self.display_name, self.user_id)
+ display_name = self.display_name
+ if isinstance(display_name, unicode):
+ display_name = display_name.encode('us-ascii', errors='replace')
+ return '<User "{0}" ({1})>'.format(display_name, self.user_id)
@property
def addresses(self):
but that probably isn't appropriate in a Python 3 environment.