Skip to content

UnicodeEncodeError in text._gen_at_message function #40

Description

@he2ss

Hello,

Thank you for this great lib.

I have this issue when the function _get_at_message return the text :

File "/home/hess/projects/venv/local/lib/python2.7/site-packages/mattermost_bot/dispatcher.py", line 195, in _gen_at_message
    return '@{}: {}'.format(self.get_username(), text)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 33: ordinal not in range(128)

I don't know why, but the content of "text" variable isn't encode in utf-8.
To fix this issue, text variable should be encoded in utf-8

    def _gen_at_message(self, text):
        return '@{}: {}'.format(self.get_username(), text.encode('utf-8'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions