mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 09:49:21 +01:00
Inputfile encode filenames (#1086)
* Unitest to recreate issue #1083 * InputFile: Encode unicode filenames Fixes #1083
This commit is contained in:
parent
1ec12343f0
commit
38d6f4d9f2
2 changed files with 5 additions and 1 deletions
|
@ -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."""
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue