prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Can't change filename when send document after upgrading to v11.1.0
  ### Steps to reproduce
  1. Generate a pickle file "test" (I didn't test other common files yet)
  
  2. Send this file to user
  
  `bot.send_document(chat_id=user_chat_id, document=open('./test', 'rb'), filename="test")`
  
  or
  
  `bot.send_document(chat_id=user_chat_id, document=open('./test', 'rb'))`
  
  ### Expected behaviour
  User will receive a file named **test**
  
  ### Actual behaviour
  User received a file named **application.octet-stream**
  
  ### Configuration
  **Operating System:** 
  
  Debian (Server, where I first found this issue)
  
  Ubuntu(Local, **I test on v10.1.0, everything is fine**, so I upgrade to v11.1.0, then I have the same issue as Debian Server)
  
  **Version of Python, python-telegram-bot & dependencies:**
  
  ``$ python -m telegram``
  
  *My Local Ubuntu After Upgrade:*
  python-telegram-bot 11.1.0
  certifi 2018.08.24
  future 0.16.0
  Python 3.6.6 (default, Sep 12 2018, 18:26:19)  [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
  
  The pictures shows results of python-telegram-bot v10.1.0 (the first one) and v11.1.0 (the second one) :
  
  ![screenshot from 2018-09-29 14-16-06](https://user-images.githubusercontent.com/16657782/46246951-2382a080-c3f4-11e8-9f01-b4dd90960ccd.png)
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `telegram/files/inputfile.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 # pylint: disable=W0622,E0611
  3 #
  4 # A library that provides a Python interface to the Telegram Bot API
  5 # Copyright (C) 2015-2018
  6 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
  7 #
  8 # This program is free software: you can redistribute it and/or modify
  9 # it under the terms of the GNU Lesser Public License as published by
  10 # the Free Software Foundation, either version 3 of the License, or
  11 # (at your option) any later version.
  12 #
  13 # This program is distributed in the hope that it will be useful,
  14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 # GNU Lesser Public License for more details.
  17 #
  18 # You should have received a copy of the GNU Lesser Public License
  19 # along with this program.  If not, see [http://www.gnu.org/licenses/].
  20 """This module contains an object that represents a Telegram InputFile."""
  21 
  22 import imghdr
  23 import mimetypes
  24 import os
  25 from uuid import uuid4
  26 
  27 from telegram import TelegramError
  28 
  29 DEFAULT_MIME_TYPE = 'application/octet-stream'
  30 
  31 
  32 class InputFile(object):
  33     """This object represents a Telegram InputFile.
  34 
  35     Attributes:
  36         input_file_content (:obj:`bytes`): The binaray content of the file to send.
  37         filename (:obj:`str`): Optional, Filename for the file to be sent.
  38         attach (:obj:`str`): Optional, attach id for sending multiple files.
  39 
  40     Args:
  41         obj (:obj:`File handler`): An open file descriptor.
  42         filename (:obj:`str`, optional): Filename for this InputFile.
  43         attach (:obj:`bool`, optional): Whether this should be send as one file or is part of a
  44             collection of files.
  45 
  46     Raises:
  47         TelegramError
  48 
  49     """
  50 
  51     def __init__(self, obj, filename=None, attach=None):
  52         self.filename = None
  53         self.input_file_content = obj.read()
  54         self.attach = 'attached' + uuid4().hex if attach else None
  55 
  56         if filename:
  57             self.filename = filename
  58         elif (hasattr(obj, 'name') and
  59               not isinstance(obj.name, int) and  # py3
  60               obj.name != '<fdopen>'):  # py2
  61             # on py2.7, pylint fails to understand this properly
  62             # pylint: disable=E1101
  63             self.filename = os.path.basename(obj.name)
  64 
  65         try:
  66             self.mimetype = self.is_image(self.input_file_content)
  67         except TelegramError:
  68             if self.filename:
  69                 self.mimetype = mimetypes.guess_type(
  70                     self.filename)[0] or DEFAULT_MIME_TYPE
  71             else:
  72                 self.mimetype = DEFAULT_MIME_TYPE
  73         if not self.filename or '.' not in self.filename:
  74             self.filename = self.mimetype.replace('/', '.')
  75 
  76     @property
  77     def field_tuple(self):
  78         return self.filename, self.input_file_content, self.mimetype
  79 
  80     @staticmethod
  81     def is_image(stream):
  82         """Check if the content file is an image by analyzing its headers.
  83 
  84         Args:
  85             stream (:obj:`str`): A str representing the content of a file.
  86 
  87         Returns:
  88             :obj:`str`: The str mime-type of an image.
  89 
  90         """
  91         image = imghdr.what(None, stream)
  92         if image:
  93             return 'image/%s' % image
  94 
  95         raise TelegramError('Could not parse file content')
  96 
  97     @staticmethod
  98     def is_file(obj):
  99         return hasattr(obj, 'read')
  100 
  101     def to_dict(self):
  102         if self.attach:
  103             return 'attach://' + self.attach
  104
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/telegram/files/inputfile.py b/telegram/files/inputfile.py
  --- a/telegram/files/inputfile.py
  +++ b/telegram/files/inputfile.py
  @@ -70,7 +70,7 @@
                       self.filename)[0] or DEFAULT_MIME_TYPE
               else:
                   self.mimetype = DEFAULT_MIME_TYPE
  -        if not self.filename or '.' not in self.filename:
  +        if not self.filename:
               self.filename = self.mimetype.replace('/', '.')
   
       @property
  
verification_info: {"golden_diff": "diff --git a/telegram/files/inputfile.py b/telegram/files/inputfile.py\n--- a/telegram/files/inputfile.py\n+++ b/telegram/files/inputfile.py\n@@ -70,7 +70,7 @@\n                     self.filename)[0] or DEFAULT_MIME_TYPE\n             else:\n                 self.mimetype = DEFAULT_MIME_TYPE\n-        if not self.filename or '.' not in self.filename:\n+        if not self.filename:\n             self.filename = self.mimetype.replace('/', '.')\n \n     @property\n", "issue": "Can't change filename when send document after upgrading to v11.1.0\n### Steps to reproduce\r\n1. Generate a pickle file \"test\" (I didn't test other common files yet)\r\n\r\n2. Send this file to user\r\n\r\n`bot.send_document(chat_id=user_chat_id, document=open('./test', 'rb'), filename=\"test\")`\r\n\r\nor\r\n\r\n`bot.send_document(chat_id=user_chat_id, document=open('./test', 'rb'))`\r\n\r\n### Expected behaviour\r\nUser will receive a file named **test**\r\n\r\n### Actual behaviour\r\nUser received a file named **application.octet-stream**\r\n\r\n### Configuration\r\n**Operating System:** \r\n\r\nDebian (Server, where I first found this issue)\r\n\r\nUbuntu(Local, **I test on v10.1.0, everything is fine**, so I upgrade to v11.1.0, then I have the same issue as Debian Server)\r\n\r\n**Version of Python, python-telegram-bot & dependencies:**\r\n\r\n``$ python -m telegram``\r\n\r\n*My Local Ubuntu After Upgrade:*\r\npython-telegram-bot 11.1.0\r\ncertifi 2018.08.24\r\nfuture 0.16.0\r\nPython 3.6.6 (default, Sep 12 2018, 18:26:19)  [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]\r\n\r\nThe pictures shows results of python-telegram-bot v10.1.0 (the first one) and v11.1.0 (the second one) :\r\n\r\n![screenshot from 2018-09-29 14-16-06](https://user-images.githubusercontent.com/16657782/46246951-2382a080-c3f4-11e8-9f01-b4dd90960ccd.png)\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# pylint: disable=W0622,E0611\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2018\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains an object that represents a Telegram InputFile.\"\"\"\n\nimport imghdr\nimport mimetypes\nimport os\nfrom uuid import uuid4\n\nfrom telegram import TelegramError\n\nDEFAULT_MIME_TYPE = 'application/octet-stream'\n\n\nclass InputFile(object):\n    \"\"\"This object represents a Telegram InputFile.\n\n    Attributes:\n        input_file_content (:obj:`bytes`): The binaray content of the file to send.\n        filename (:obj:`str`): Optional, Filename for the file to be sent.\n        attach (:obj:`str`): Optional, attach id for sending multiple files.\n\n    Args:\n        obj (:obj:`File handler`): An open file descriptor.\n        filename (:obj:`str`, optional): Filename for this InputFile.\n        attach (:obj:`bool`, optional): Whether this should be send as one file or is part of a\n            collection of files.\n\n    Raises:\n        TelegramError\n\n    \"\"\"\n\n    def __init__(self, obj, filename=None, attach=None):\n        self.filename = None\n        self.input_file_content = obj.read()\n        self.attach = 'attached' + uuid4().hex if attach else None\n\n        if filename:\n            self.filename = filename\n        elif (hasattr(obj, 'name') and\n              not isinstance(obj.name, int) and  # py3\n              obj.name != '<fdopen>'):  # py2\n            # on py2.7, pylint fails to understand this properly\n            # pylint: disable=E1101\n            self.filename = os.path.basename(obj.name)\n\n        try:\n            self.mimetype = self.is_image(self.input_file_content)\n        except TelegramError:\n            if self.filename:\n                self.mimetype = mimetypes.guess_type(\n                    self.filename)[0] or DEFAULT_MIME_TYPE\n            else:\n                self.mimetype = DEFAULT_MIME_TYPE\n        if not self.filename or '.' not in self.filename:\n            self.filename = self.mimetype.replace('/', '.')\n\n    @property\n    def field_tuple(self):\n        return self.filename, self.input_file_content, self.mimetype\n\n    @staticmethod\n    def is_image(stream):\n        \"\"\"Check if the content file is an image by analyzing its headers.\n\n        Args:\n            stream (:obj:`str`): A str representing the content of a file.\n\n        Returns:\n            :obj:`str`: The str mime-type of an image.\n\n        \"\"\"\n        image = imghdr.what(None, stream)\n        if image:\n            return 'image/%s' % image\n\n        raise TelegramError('Could not parse file content')\n\n    @staticmethod\n    def is_file(obj):\n        return hasattr(obj, 'read')\n\n    def to_dict(self):\n        if self.attach:\n            return 'attach://' + self.attach\n", "path": "telegram/files/inputfile.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# pylint: disable=W0622,E0611\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2018\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains an object that represents a Telegram InputFile.\"\"\"\n\nimport imghdr\nimport mimetypes\nimport os\nfrom uuid import uuid4\n\nfrom telegram import TelegramError\n\nDEFAULT_MIME_TYPE = 'application/octet-stream'\n\n\nclass InputFile(object):\n    \"\"\"This object represents a Telegram InputFile.\n\n    Attributes:\n        input_file_content (:obj:`bytes`): The binaray content of the file to send.\n        filename (:obj:`str`): Optional, Filename for the file to be sent.\n        attach (:obj:`str`): Optional, attach id for sending multiple files.\n\n    Args:\n        obj (:obj:`File handler`): An open file descriptor.\n        filename (:obj:`str`, optional): Filename for this InputFile.\n        attach (:obj:`bool`, optional): Whether this should be send as one file or is part of a\n            collection of files.\n\n    Raises:\n        TelegramError\n\n    \"\"\"\n\n    def __init__(self, obj, filename=None, attach=None):\n        self.filename = None\n        self.input_file_content = obj.read()\n        self.attach = 'attached' + uuid4().hex if attach else None\n\n        if filename:\n            self.filename = filename\n        elif (hasattr(obj, 'name') and\n              not isinstance(obj.name, int) and  # py3\n              obj.name != '<fdopen>'):  # py2\n            # on py2.7, pylint fails to understand this properly\n            # pylint: disable=E1101\n            self.filename = os.path.basename(obj.name)\n\n        try:\n            self.mimetype = self.is_image(self.input_file_content)\n        except TelegramError:\n            if self.filename:\n                self.mimetype = mimetypes.guess_type(\n                    self.filename)[0] or DEFAULT_MIME_TYPE\n            else:\n                self.mimetype = DEFAULT_MIME_TYPE\n        if not self.filename:\n            self.filename = self.mimetype.replace('/', '.')\n\n    @property\n    def field_tuple(self):\n        return self.filename, self.input_file_content, self.mimetype\n\n    @staticmethod\n    def is_image(stream):\n        \"\"\"Check if the content file is an image by analyzing its headers.\n\n        Args:\n            stream (:obj:`str`): A str representing the content of a file.\n\n        Returns:\n            :obj:`str`: The str mime-type of an image.\n\n        \"\"\"\n        image = imghdr.what(None, stream)\n        if image:\n            return 'image/%s' % image\n\n        raise TelegramError('Could not parse file content')\n\n    @staticmethod\n    def is_file(obj):\n        return hasattr(obj, 'read')\n\n    def to_dict(self):\n        if self.attach:\n            return 'attach://' + self.attach\n", "path": "telegram/files/inputfile.py"}]}