diff --git a/telegram/files/inputfile.py b/telegram/files/inputfile.py index d4739c838..a82cae699 100644 --- a/telegram/files/inputfile.py +++ b/telegram/files/inputfile.py @@ -86,6 +86,10 @@ class InputFile(object): else: self.mimetype = DEFAULT_MIME_TYPE + if sys.version_info < (3,): + if isinstance(self.filename, unicode): # flake8: noqa pylint: disable=E0602 + self.filename = self.filename.encode('utf-8', 'replace') + @property def headers(self): """:obj:`dict`: Headers.""" diff --git a/tests/test_photo.py b/tests/test_photo.py index 610debf47..8647b0935 100644 --- a/tests/test_photo.py +++ b/tests/test_photo.py @@ -27,7 +27,7 @@ from telegram import Sticker, TelegramError, PhotoSize, InputFile @pytest.fixture(scope='function') def photo_file(): - f = open('tests/data/telegram.jpg', 'rb') + f = open(u'tests/data/telegram.jpg', 'rb') yield f f.close()