# Buggy code
def _send_output(self, message_body=None):
    self._buffer.extend((b"", b""))
    msg = self._convert_to_bytes(self._buffer)
    del self._buffer[:]
    # If msg and message_body are sent in a single send() call,
    # it will avoid performance problems caused by the interaction
    # between delayed ack and the Nagle algorithm.
    if isinstance(message_body, bytes):
        msg += message_body
        message_body = None
    self.send(msg)
    if self._expect_header_set:
        # This is our custom behavior.  If the Expect header was
        # set, it will trigger this custom behavior.
        logger.debug("Waiting for 100 Continue response.")
        # Wait for 1 second for the server to send a response.
        read, write, exc = select.select([self.sock], [], [self.sock], 1)
        if read:
            self._handle_expect_response(message_body)
            return
        else:
            # From the RFC:
            # Because of the presence of older implementations, the
            # protocol allows ambiguous situations in which a client may
            # send "Expect: 100-continue" without receiving either a 417
            # (Expectation Failed) status or a 100 (Continue) status.
            # Therefore, when a client sends this header field to an origin
            # server (possibly via a proxy) from which it has never seen a
            # 100 (Continue) status, the client SHOULD NOT wait for an
            # indefinite period before sending the request body.
            logger.debug(
                "No response seen from server, continuing to send the response body."
            )
    if message_body is not None:
        # message_body was not a string (i.e. it is a file), and
        # we must run the risk of Nagle.
        self.send(message_body)


# Traceback (TypeError)
Python 3.6.0b2 (default, Nov  1 2016, 00:18:55)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import boto3
s3 = boto3.client('s3')
s3.list_buckets()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 526, in _make_api_call
operation_model, request_dict)
File "/usr/local/lib/python3.6/site-packages/botocore/endpoint.py", line 141, in make_request
return self._send_request(request_dict, operation_model)
File "/usr/local/lib/python3.6/site-packages/botocore/endpoint.py", line 170, in _send_request
success_response, exception):
File "/usr/local/lib/python3.6/site-packages/botocore/endpoint.py", line 249, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/usr/local/lib/python3.6/site-packages/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)
File "/usr/local/lib/python3.6/site-packages/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 269, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/usr/local/lib/python3.6/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/usr/local/lib/python3.6/site-packages/botocore/endpoint.py", line 204, in _get_response
proxies=self.proxies, timeout=self.timeout)
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
TypeError: _send_request() takes 5 positional arguments but 6 were given

# Fixed code
def _send_output(self, message_body=None, *args, **kwargs):
    self._buffer.extend((b"", b""))
    msg = self._convert_to_bytes(self._buffer)
    del self._buffer[:]
    # If msg and message_body are sent in a single send() call,
    # it will avoid performance problems caused by the interaction
    # between delayed ack and the Nagle algorithm.
    if isinstance(message_body, bytes):
        msg += message_body
        message_body = None
    self.send(msg)
    if self._expect_header_set:
        # This is our custom behavior.  If the Expect header was
        # set, it will trigger this custom behavior.
        logger.debug("Waiting for 100 Continue response.")
        # Wait for 1 second for the server to send a response.
        read, write, exc = select.select([self.sock], [], [self.sock], 1)
        if read:
            self._handle_expect_response(message_body)
            return
        else:
            # From the RFC:
            # Because of the presence of older implementations, the
            # protocol allows ambiguous situations in which a client may
            # send "Expect: 100-continue" without receiving either a 417
            # (Expectation Failed) status or a 100 (Continue) status.
            # Therefore, when a client sends this header field to an origin
            # server (possibly via a proxy) from which it has never seen a
            # 100 (Continue) status, the client SHOULD NOT wait for an
            # indefinite period before sending the request body.
            logger.debug(
                "No response seen from server, continuing to send the response body."
            )
    if message_body is not None:
        # message_body was not a string (i.e. it is a file), and
        # we must run the risk of Nagle.
        self.send(message_body)