# Buggy code
def sendDocument(self, chat_id, document, reply_to_message_id=None, reply_markup=None):
    """Use this method to send Lesser files.

    Args:
      chat_id:
        Unique identifier for the message recipient - User or GroupChat id.
      document:
        File to send. You can either pass a file_id as String to resend a
        file that is already on the Telegram servers, or upload a new file
        using multipart/form-data.
      reply_to_message_id:
        If the message is a reply, ID of the original message. [Optional]
      reply_markup:
        Additional interface options. A JSON-serialized object for a
        custom reply keyboard, instructions to hide keyboard or to force a
        reply from the user. [Optional]

    Returns:
      A telegram.Message instance representing the message posted.
    """

    url = "%s/sendDocument" % self.base_url

    data = {"chat_id": chat_id, "document": document}

    return url, data


# Traceback (TypeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/pickle.py", line 1370, in dump
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.7/pickle.py", line 224, in dump
self.save(obj)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 600, in save_list
self._batch_appends(iter(obj))
File "/usr/lib/python2.7/pickle.py", line 615, in _batch_appends
save(x)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 306, in save
rv = reduce(self.proto)
File "/home/leandrotoledo/workspace/python-telegram-bot/env/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle lock objects

# Fixed code
def sendDocument(self, chat_id, document, reply_to_message_id=None, reply_markup=None):
    """Use this method to send general files.

    Args:
      chat_id:
        Unique identifier for the message recipient - User or GroupChat id.
      document:
        File to send. You can either pass a file_id as String to resend a
        file that is already on the Telegram servers, or upload a new file
        using multipart/form-data.
      reply_to_message_id:
        If the message is a reply, ID of the original message. [Optional]
      reply_markup:
        Additional interface options. A JSON-serialized object for a
        custom reply keyboard, instructions to hide keyboard or to force a
        reply from the user. [Optional]

    Returns:
      A telegram.Message instance representing the message posted.
    """

    url = "%s/sendDocument" % self.base_url

    data = {"chat_id": chat_id, "document": document}

    return url, data