mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-26 16:38:53 +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:
|
else:
|
||||||
self.mimetype = DEFAULT_MIME_TYPE
|
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
|
@property
|
||||||
def headers(self):
|
def headers(self):
|
||||||
""":obj:`dict`: Headers."""
|
""":obj:`dict`: Headers."""
|
||||||
|
|
|
@ -27,7 +27,7 @@ from telegram import Sticker, TelegramError, PhotoSize, InputFile
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def photo_file():
|
def photo_file():
|
||||||
f = open('tests/data/telegram.jpg', 'rb')
|
f = open(u'tests/data/telegram.jpg', 'rb')
|
||||||
yield f
|
yield f
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue