Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core
Commits: b698ca37 by Abhilash Raj at 2018-05-16T16:18:24Z Do not try to format bytes object. This fixes an issue where bytes object was being treated as string and using .format() on them. Apperently, .format() doesn't work but %s does. We now format a string and then encode it. - - - - - 87ee2af3 by Abhilash Raj at 2018-05-16T17:10:54Z Merge branch 'issue-360' into 'master' Do not try to format bytes object. Closes #360 See merge request mailman/mailman!391 - - - - - 2 changed files: - src/mailman/rest/helpers.py - src/mailman/rest/users.py Changes: ===================================== src/mailman/rest/helpers.py ===================================== --- a/src/mailman/rest/helpers.py +++ b/src/mailman/rest/helpers.py @@ -293,7 +293,7 @@ def accepted(response, body=None): @public -def bad_request(response, body='400 Bad Request'): +def bad_request(response, body=b'400 Bad Request'): response.status = falcon.HTTP_400 if body is not None: response.body = body ===================================== src/mailman/rest/users.py ===================================== --- a/src/mailman/rest/users.py +++ b/src/mailman/rest/users.py @@ -103,7 +103,8 @@ def create_user(api, arguments, response): user.link(address) else: bad_request( - response, 'User already exists: {}'.format(error.address)) + response, + 'User already exists: {}'.format(error.address).encode()) return None if password is None: # This will have to be reset since it cannot be retrieved. @@ -247,10 +248,12 @@ class AUser(_UserBase): validator = PatchValidator(request, ATTRIBUTES) except UnknownPATCHRequestError as error: bad_request( - response, b'Unknown attribute: {0}'.format(error.attribute)) + response, + 'Unknown attribute: {0}'.format(error.attribute).encode()) except ReadOnlyPATCHRequestError as error: bad_request( - response, b'Read-only attribute: {0}'.format(error.attribute)) + response, + 'Read-only attribute: {0}'.format(error.attribute).encode()) else: validator.update(self._user, request) no_content(response) @@ -265,10 +268,12 @@ class AUser(_UserBase): validator.update(self._user, request) except UnknownPATCHRequestError as error: bad_request( - response, b'Unknown attribute: {0}'.format(error.attribute)) + response, + 'Unknown attribute: {0}'.format(error.attribute).encode()) except ReadOnlyPATCHRequestError as error: bad_request( - response, b'Read-only attribute: {0}'.format(error.attribute)) + response, + 'Read-only attribute: {0}'.format(error.attribute).encode()) except ValueError as error: bad_request(response, str(error)) else: @@ -332,7 +337,7 @@ class AddressUser(_UserBase): user = user_manager.get_user_by_id(user_id) if user is None: bad_request(response, 'No user with ID {}'.format( - self.api.from_uuid(user_id))) + self.api.from_uuid(user_id)).encode()) return okay(response) else: @@ -367,7 +372,8 @@ class AddressUser(_UserBase): user_id = arguments['user_id'] user = user_manager.get_user_by_id(user_id) if user is None: - not_found(response, b'No user with ID {}'.format(user_id)) + not_found(response, + 'No user with ID {}'.format(user_id).encode()) return okay(response) else: View it on GitLab: https://gitlab.com/mailman/mailman/compare/7707566beeeb04e35d72467c50274a28125fa2aa...87ee2af38d0a221657c1e5a085b87ba614e3fdfb -- View it on GitLab: https://gitlab.com/mailman/mailman/compare/7707566beeeb04e35d72467c50274a28125fa2aa...87ee2af38d0a221657c1e5a085b87ba614e3fdfb You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org