We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: 'SocketIO' object has no attribute 'raw'
As raised in https://github.com/docker/compose/issues/5353 but I think it's actually a docker-py issue:
docker-composeup redis
Creating procensus_redis_1 ... 
Creating procensus_redis_1

ERROR: for procensus_redis_1  'SocketIO' object has no attribute 'raw'

ERROR: for redis  'SocketIO' object has no attribute 'raw'
```pytb
Traceback (most recent call last):
  File "/home/graingert/.virtualenvs/gitlab/bin/docker-compose", line 11, in <module>
    sys.exit(main())
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py", line 68, in main
    command()
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py", line 121, in perform_command
    handler(command, command_options)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py", line 952, in up
    start=not no_start
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/project.py", line 455, in up
    get_deps,
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py", line 70, in parallel_execute
    raise error_to_reraise
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py", line 168, in producer
    result = func(obj)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/project.py", line 441, in do
    start=start
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py", line 471, in execute_convergence_plan
    scale, detached, start
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py", line 396, in _execute_convergence_create
    "Creating",
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py", line 70, in parallel_execute
    raise error_to_reraise
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py", line 168, in producer
    result = func(obj)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py", line 394, in <lambda>
    lambda n: create_and_start(self, n),
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py", line 387, in create_and_start
    container.attach_log_stream()
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/container.py", line 177, in attach_log_stream
    self.log_stream = self.attach(stdout=True, stderr=True, stream=True)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/container.py", line 254, in attach
    return self.client.attach(self.id, *args, **kwargs)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/container.py", line 56, in attach
    response, stream, self._check_is_tty(container)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/client.py", line 368, in _read_from_socket
    socket = self._get_raw_response_socket(response)
  File "/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/client.py", line 276, in _get_raw_response_socket
    sock = response.raw._fp.fp.raw
AttributeError: 'SocketIO' object has no attribute 'raw'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/transport/unixconn.py`
Content:
```
1 import six
2 import requests.adapters
3 import socket
4 
5 from .. import constants
6 
7 if six.PY3:
8     import http.client as httplib
9 else:
10     import httplib
11 
12 try:
13     import requests.packages.urllib3 as urllib3
14 except ImportError:
15     import urllib3
16 
17 
18 RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer
19 
20 
21 class UnixHTTPResponse(httplib.HTTPResponse, object):
22     def __init__(self, sock, *args, **kwargs):
23         disable_buffering = kwargs.pop('disable_buffering', False)
24         super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)
25         if disable_buffering is True:
26             # We must first create a new pointer then close the old one
27             # to avoid closing the underlying socket.
28             new_fp = sock.makefile('rb', 0)
29             self.fp.close()
30             self.fp = new_fp
31 
32 
33 class UnixHTTPConnection(httplib.HTTPConnection, object):
34 
35     def __init__(self, base_url, unix_socket, timeout=60):
36         super(UnixHTTPConnection, self).__init__(
37             'localhost', timeout=timeout
38         )
39         self.base_url = base_url
40         self.unix_socket = unix_socket
41         self.timeout = timeout
42         self.disable_buffering = False
43 
44     def connect(self):
45         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
46         sock.settimeout(self.timeout)
47         sock.connect(self.unix_socket)
48         self.sock = sock
49 
50     def putheader(self, header, *values):
51         super(UnixHTTPConnection, self).putheader(header, *values)
52         if header == 'Connection' and 'Upgrade' in values:
53             self.disable_buffering = True
54 
55     def response_class(self, sock, *args, **kwargs):
56         if self.disable_buffering:
57             kwargs['disable_buffering'] = True
58 
59         return UnixHTTPResponse(sock, *args, **kwargs)
60 
61 
62 class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
63     def __init__(self, base_url, socket_path, timeout=60, maxsize=10):
64         super(UnixHTTPConnectionPool, self).__init__(
65             'localhost', timeout=timeout, maxsize=maxsize
66         )
67         self.base_url = base_url
68         self.socket_path = socket_path
69         self.timeout = timeout
70 
71     def _new_conn(self):
72         return UnixHTTPConnection(
73             self.base_url, self.socket_path, self.timeout
74         )
75 
76 
77 class UnixAdapter(requests.adapters.HTTPAdapter):
78 
79     __attrs__ = requests.adapters.HTTPAdapter.__attrs__ + ['pools',
80                                                            'socket_path',
81                                                            'timeout']
82 
83     def __init__(self, socket_url, timeout=60,
84                  pool_connections=constants.DEFAULT_NUM_POOLS):
85         socket_path = socket_url.replace('http+unix://', '')
86         if not socket_path.startswith('/'):
87             socket_path = '/' + socket_path
88         self.socket_path = socket_path
89         self.timeout = timeout
90         self.pools = RecentlyUsedContainer(
91             pool_connections, dispose_func=lambda p: p.close()
92         )
93         super(UnixAdapter, self).__init__()
94 
95     def get_connection(self, url, proxies=None):
96         with self.pools.lock:
97             pool = self.pools.get(url)
98             if pool:
99                 return pool
100 
101             pool = UnixHTTPConnectionPool(
102                 url, self.socket_path, self.timeout
103             )
104             self.pools[url] = pool
105 
106         return pool
107 
108     def request_url(self, request, proxies):
109         # The select_proxy utility in requests errors out when the provided URL
110         # doesn't have a hostname, like is the case when using a UNIX socket.
111         # Since proxies are an irrelevant notion in the case of UNIX sockets
112         # anyway, we simply return the path URL directly.
113         # See also: https://github.com/docker/docker-py/issues/811
114         return request.path_url
115 
116     def close(self):
117         self.pools.clear()
118
```
--- 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()

```

diff --git a/docker/transport/unixconn.py b/docker/transport/unixconn.py
--- a/docker/transport/unixconn.py
+++ b/docker/transport/unixconn.py
@@ -21,13 +21,12 @@
 class UnixHTTPResponse(httplib.HTTPResponse, object):
     def __init__(self, sock, *args, **kwargs):
         disable_buffering = kwargs.pop('disable_buffering', False)
+        if six.PY2:
+            # FIXME: We may need to disable buffering on Py3 as well,
+            # but there's no clear way to do it at the moment. See:
+            # https://github.com/docker/docker-py/issues/1799
+            kwargs['buffering'] = not disable_buffering
         super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)
-        if disable_buffering is True:
-            # We must first create a new pointer then close the old one
-            # to avoid closing the underlying socket.
-            new_fp = sock.makefile('rb', 0)
-            self.fp.close()
-            self.fp = new_fp
 
 
 class UnixHTTPConnection(httplib.HTTPConnection, object):

{"golden_diff": "diff --git a/docker/transport/unixconn.py b/docker/transport/unixconn.py\n--- a/docker/transport/unixconn.py\n+++ b/docker/transport/unixconn.py\n@@ -21,13 +21,12 @@\n class UnixHTTPResponse(httplib.HTTPResponse, object):\n     def __init__(self, sock, *args, **kwargs):\n         disable_buffering = kwargs.pop('disable_buffering', False)\n+        if six.PY2:\n+            # FIXME: We may need to disable buffering on Py3 as well,\n+            # but there's no clear way to do it at the moment. See:\n+            # https://github.com/docker/docker-py/issues/1799\n+            kwargs['buffering'] = not disable_buffering\n         super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)\n-        if disable_buffering is True:\n-            # We must first create a new pointer then close the old one\n-            # to avoid closing the underlying socket.\n-            new_fp = sock.makefile('rb', 0)\n-            self.fp.close()\n-            self.fp = new_fp\n \n \n class UnixHTTPConnection(httplib.HTTPConnection, object):\n", "issue": "AttributeError: 'SocketIO' object has no attribute 'raw'\nAs raised in https://github.com/docker/compose/issues/5353 but I think it's actually a docker-py issue:\r\ndocker-composeup redis\r\nCreating procensus_redis_1 ... \r\nCreating procensus_redis_1\r\n\r\nERROR: for procensus_redis_1  'SocketIO' object has no attribute 'raw'\r\n\r\nERROR: for redis  'SocketIO' object has no attribute 'raw'\r\n```pytb\r\nTraceback (most recent call last):\r\n  File \"/home/graingert/.virtualenvs/gitlab/bin/docker-compose\", line 11, in <module>\r\n    sys.exit(main())\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py\", line 68, in main\r\n    command()\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py\", line 121, in perform_command\r\n    handler(command, command_options)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/cli/main.py\", line 952, in up\r\n    start=not no_start\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/project.py\", line 455, in up\r\n    get_deps,\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py\", line 70, in parallel_execute\r\n    raise error_to_reraise\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py\", line 168, in producer\r\n    result = func(obj)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/project.py\", line 441, in do\r\n    start=start\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py\", line 471, in execute_convergence_plan\r\n    scale, detached, start\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py\", line 396, in _execute_convergence_create\r\n    \"Creating\",\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py\", line 70, in parallel_execute\r\n    raise error_to_reraise\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/parallel.py\", line 168, in producer\r\n    result = func(obj)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py\", line 394, in <lambda>\r\n    lambda n: create_and_start(self, n),\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/service.py\", line 387, in create_and_start\r\n    container.attach_log_stream()\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/container.py\", line 177, in attach_log_stream\r\n    self.log_stream = self.attach(stdout=True, stderr=True, stream=True)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/compose/container.py\", line 254, in attach\r\n    return self.client.attach(self.id, *args, **kwargs)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/utils/decorators.py\", line 19, in wrapped\r\n    return f(self, resource_id, *args, **kwargs)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/container.py\", line 56, in attach\r\n    response, stream, self._check_is_tty(container)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/client.py\", line 368, in _read_from_socket\r\n    socket = self._get_raw_response_socket(response)\r\n  File \"/home/graingert/.virtualenvs/gitlab/lib/python3.6/site-packages/docker/api/client.py\", line 276, in _get_raw_response_socket\r\n    sock = response.raw._fp.fp.raw\r\nAttributeError: 'SocketIO' object has no attribute 'raw'\r\n```\n", "before_files": [{"content": "import six\nimport requests.adapters\nimport socket\n\nfrom .. import constants\n\nif six.PY3:\n    import http.client as httplib\nelse:\n    import httplib\n\ntry:\n    import requests.packages.urllib3 as urllib3\nexcept ImportError:\n    import urllib3\n\n\nRecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer\n\n\nclass UnixHTTPResponse(httplib.HTTPResponse, object):\n    def __init__(self, sock, *args, **kwargs):\n        disable_buffering = kwargs.pop('disable_buffering', False)\n        super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)\n        if disable_buffering is True:\n            # We must first create a new pointer then close the old one\n            # to avoid closing the underlying socket.\n            new_fp = sock.makefile('rb', 0)\n            self.fp.close()\n            self.fp = new_fp\n\n\nclass UnixHTTPConnection(httplib.HTTPConnection, object):\n\n    def __init__(self, base_url, unix_socket, timeout=60):\n        super(UnixHTTPConnection, self).__init__(\n            'localhost', timeout=timeout\n        )\n        self.base_url = base_url\n        self.unix_socket = unix_socket\n        self.timeout = timeout\n        self.disable_buffering = False\n\n    def connect(self):\n        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n        sock.settimeout(self.timeout)\n        sock.connect(self.unix_socket)\n        self.sock = sock\n\n    def putheader(self, header, *values):\n        super(UnixHTTPConnection, self).putheader(header, *values)\n        if header == 'Connection' and 'Upgrade' in values:\n            self.disable_buffering = True\n\n    def response_class(self, sock, *args, **kwargs):\n        if self.disable_buffering:\n            kwargs['disable_buffering'] = True\n\n        return UnixHTTPResponse(sock, *args, **kwargs)\n\n\nclass UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):\n    def __init__(self, base_url, socket_path, timeout=60, maxsize=10):\n        super(UnixHTTPConnectionPool, self).__init__(\n            'localhost', timeout=timeout, maxsize=maxsize\n        )\n        self.base_url = base_url\n        self.socket_path = socket_path\n        self.timeout = timeout\n\n    def _new_conn(self):\n        return UnixHTTPConnection(\n            self.base_url, self.socket_path, self.timeout\n        )\n\n\nclass UnixAdapter(requests.adapters.HTTPAdapter):\n\n    __attrs__ = requests.adapters.HTTPAdapter.__attrs__ + ['pools',\n                                                           'socket_path',\n                                                           'timeout']\n\n    def __init__(self, socket_url, timeout=60,\n                 pool_connections=constants.DEFAULT_NUM_POOLS):\n        socket_path = socket_url.replace('http+unix://', '')\n        if not socket_path.startswith('/'):\n            socket_path = '/' + socket_path\n        self.socket_path = socket_path\n        self.timeout = timeout\n        self.pools = RecentlyUsedContainer(\n            pool_connections, dispose_func=lambda p: p.close()\n        )\n        super(UnixAdapter, self).__init__()\n\n    def get_connection(self, url, proxies=None):\n        with self.pools.lock:\n            pool = self.pools.get(url)\n            if pool:\n                return pool\n\n            pool = UnixHTTPConnectionPool(\n                url, self.socket_path, self.timeout\n            )\n            self.pools[url] = pool\n\n        return pool\n\n    def request_url(self, request, proxies):\n        # The select_proxy utility in requests errors out when the provided URL\n        # doesn't have a hostname, like is the case when using a UNIX socket.\n        # Since proxies are an irrelevant notion in the case of UNIX sockets\n        # anyway, we simply return the path URL directly.\n        # See also: https://github.com/docker/docker-py/issues/811\n        return request.path_url\n\n    def close(self):\n        self.pools.clear()\n", "path": "docker/transport/unixconn.py"}], "after_files": [{"content": "import six\nimport requests.adapters\nimport socket\n\nfrom .. import constants\n\nif six.PY3:\n    import http.client as httplib\nelse:\n    import httplib\n\ntry:\n    import requests.packages.urllib3 as urllib3\nexcept ImportError:\n    import urllib3\n\n\nRecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer\n\n\nclass UnixHTTPResponse(httplib.HTTPResponse, object):\n    def __init__(self, sock, *args, **kwargs):\n        disable_buffering = kwargs.pop('disable_buffering', False)\n        if six.PY2:\n            # FIXME: We may need to disable buffering on Py3 as well,\n            # but there's no clear way to do it at the moment. See:\n            # https://github.com/docker/docker-py/issues/1799\n            kwargs['buffering'] = not disable_buffering\n        super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)\n\n\nclass UnixHTTPConnection(httplib.HTTPConnection, object):\n\n    def __init__(self, base_url, unix_socket, timeout=60):\n        super(UnixHTTPConnection, self).__init__(\n            'localhost', timeout=timeout\n        )\n        self.base_url = base_url\n        self.unix_socket = unix_socket\n        self.timeout = timeout\n        self.disable_buffering = False\n\n    def connect(self):\n        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n        sock.settimeout(self.timeout)\n        sock.connect(self.unix_socket)\n        self.sock = sock\n\n    def putheader(self, header, *values):\n        super(UnixHTTPConnection, self).putheader(header, *values)\n        if header == 'Connection' and 'Upgrade' in values:\n            self.disable_buffering = True\n\n    def response_class(self, sock, *args, **kwargs):\n        if self.disable_buffering:\n            kwargs['disable_buffering'] = True\n\n        return UnixHTTPResponse(sock, *args, **kwargs)\n\n\nclass UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):\n    def __init__(self, base_url, socket_path, timeout=60, maxsize=10):\n        super(UnixHTTPConnectionPool, self).__init__(\n            'localhost', timeout=timeout, maxsize=maxsize\n        )\n        self.base_url = base_url\n        self.socket_path = socket_path\n        self.timeout = timeout\n\n    def _new_conn(self):\n        return UnixHTTPConnection(\n            self.base_url, self.socket_path, self.timeout\n        )\n\n\nclass UnixAdapter(requests.adapters.HTTPAdapter):\n\n    __attrs__ = requests.adapters.HTTPAdapter.__attrs__ + ['pools',\n                                                           'socket_path',\n                                                           'timeout']\n\n    def __init__(self, socket_url, timeout=60,\n                 pool_connections=constants.DEFAULT_NUM_POOLS):\n        socket_path = socket_url.replace('http+unix://', '')\n        if not socket_path.startswith('/'):\n            socket_path = '/' + socket_path\n        self.socket_path = socket_path\n        self.timeout = timeout\n        self.pools = RecentlyUsedContainer(\n            pool_connections, dispose_func=lambda p: p.close()\n        )\n        super(UnixAdapter, self).__init__()\n\n    def get_connection(self, url, proxies=None):\n        with self.pools.lock:\n            pool = self.pools.get(url)\n            if pool:\n                return pool\n\n            pool = UnixHTTPConnectionPool(\n                url, self.socket_path, self.timeout\n            )\n            self.pools[url] = pool\n\n        return pool\n\n    def request_url(self, request, proxies):\n        # The select_proxy utility in requests errors out when the provided URL\n        # doesn't have a hostname, like is the case when using a UNIX socket.\n        # Since proxies are an irrelevant notion in the case of UNIX sockets\n        # anyway, we simply return the path URL directly.\n        # See also: https://github.com/docker/docker-py/issues/811\n        return request.path_url\n\n    def close(self):\n        self.pools.clear()\n", "path": "docker/transport/unixconn.py"}]}