We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Project inference is broken under Python 3.5.1
Project inference takes place in [_determine_default_project()](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/_helpers.py#L189), which hands off to [_compute_engine_id()](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/_helpers.py#L151). That returns the correct value -- but as `bytes`. The `Client` class checks if the project value is a `str` (using `six.string_types`) and raises an error because it is not (that code is [here](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/client.py#L144)).


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gcloud/client.py`
Content:
```
1 # Copyright 2015 Google Inc. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 """Base classes for client used to interact with Google Cloud APIs."""
16 
17 import six
18 
19 from gcloud._helpers import _determine_default_project
20 from gcloud.connection import Connection
21 from gcloud.credentials import get_credentials
22 from gcloud.credentials import get_for_service_account_json
23 from gcloud.credentials import get_for_service_account_p12
24 
25 
26 class _ClientFactoryMixin(object):
27     """Mixin to allow factories that create credentials.
28 
29     .. note::
30 
31         This class is virtual.
32     """
33 
34     @classmethod
35     def from_service_account_json(cls, json_credentials_path, *args, **kwargs):
36         """Factory to retrieve JSON credentials while creating client.
37 
38         :type json_credentials_path: string
39         :param json_credentials_path: The path to a private key file (this file
40                                       was given to you when you created the
41                                       service account). This file must contain
42                                       a JSON object with a private key and
43                                       other credentials information (downloaded
44                                       from the Google APIs console).
45 
46         :type args: tuple
47         :param args: Remaining positional arguments to pass to constructor.
48 
49         :type kwargs: dict
50         :param kwargs: Remaining keyword arguments to pass to constructor.
51 
52         :rtype: :class:`gcloud.pubsub.client.Client`
53         :returns: The client created with the retrieved JSON credentials.
54         :raises: :class:`TypeError` if there is a conflict with the kwargs
55                  and the credentials created by the factory.
56         """
57         if 'credentials' in kwargs:
58             raise TypeError('credentials must not be in keyword arguments')
59         credentials = get_for_service_account_json(json_credentials_path)
60         kwargs['credentials'] = credentials
61         return cls(*args, **kwargs)
62 
63     @classmethod
64     def from_service_account_p12(cls, client_email, private_key_path,
65                                  *args, **kwargs):
66         """Factory to retrieve P12 credentials while creating client.
67 
68         .. note::
69           Unless you have an explicit reason to use a PKCS12 key for your
70           service account, we recommend using a JSON key.
71 
72         :type client_email: string
73         :param client_email: The e-mail attached to the service account.
74 
75         :type private_key_path: string
76         :param private_key_path: The path to a private key file (this file was
77                                  given to you when you created the service
78                                  account). This file must be in P12 format.
79 
80         :type args: tuple
81         :param args: Remaining positional arguments to pass to constructor.
82 
83         :type kwargs: dict
84         :param kwargs: Remaining keyword arguments to pass to constructor.
85 
86         :rtype: :class:`gcloud.client.Client`
87         :returns: The client created with the retrieved P12 credentials.
88         :raises: :class:`TypeError` if there is a conflict with the kwargs
89                  and the credentials created by the factory.
90         """
91         if 'credentials' in kwargs:
92             raise TypeError('credentials must not be in keyword arguments')
93         credentials = get_for_service_account_p12(client_email,
94                                                   private_key_path)
95         kwargs['credentials'] = credentials
96         return cls(*args, **kwargs)
97 
98 
99 class Client(_ClientFactoryMixin):
100     """Client to bundle configuration needed for API requests.
101 
102     Assumes that the associated ``_connection_class`` only accepts
103     ``http`` and ``credentials`` in its constructor.
104 
105     :type credentials: :class:`oauth2client.client.OAuth2Credentials` or
106                        :class:`NoneType`
107     :param credentials: The OAuth2 Credentials to use for the connection
108                         owned by this client. If not passed (and if no ``http``
109                         object is passed), falls back to the default inferred
110                         from the environment.
111 
112     :type http: :class:`httplib2.Http` or class that defines ``request()``.
113     :param http: An optional HTTP object to make requests. If not passed, an
114                  ``http`` object is created that is bound to the
115                  ``credentials`` for the current object.
116     """
117 
118     _connection_class = Connection
119 
120     def __init__(self, credentials=None, http=None):
121         if credentials is None and http is None:
122             credentials = get_credentials()
123         self.connection = self._connection_class(
124             credentials=credentials, http=http)
125 
126 
127 class _ClientProjectMixin(object):
128     """Mixin to allow setting the project on the client.
129 
130     :type project: string
131     :param project: the project which the client acts on behalf of. If not
132                     passed falls back to the default inferred from the
133                     environment.
134 
135     :raises: :class:`ValueError` if the project is neither passed in nor
136              set in the environment.
137     """
138 
139     def __init__(self, project=None):
140         project = _determine_default_project(project)
141         if project is None:
142             raise ValueError('Project was not passed and could not be '
143                              'determined from the environment.')
144         if not isinstance(project, six.string_types):
145             raise ValueError('Project must be a string.')
146         self.project = project
147 
148 
149 class JSONClient(Client, _ClientProjectMixin):
150     """Client to for Google JSON-based API.
151 
152     Assumes such APIs use the ``project`` and the client needs to store this
153     value.
154 
155     :type project: string
156     :param project: the project which the client acts on behalf of. If not
157                     passed falls back to the default inferred from the
158                     environment.
159 
160     :type credentials: :class:`oauth2client.client.OAuth2Credentials` or
161                        :class:`NoneType`
162     :param credentials: The OAuth2 Credentials to use for the connection
163                         owned by this client. If not passed (and if no ``http``
164                         object is passed), falls back to the default inferred
165                         from the environment.
166 
167     :type http: :class:`httplib2.Http` or class that defines ``request()``.
168     :param http: An optional HTTP object to make requests. If not passed, an
169                  ``http`` object is created that is bound to the
170                  ``credentials`` for the current object.
171 
172     :raises: :class:`ValueError` if the project is neither passed in nor
173              set in the environment.
174     """
175 
176     def __init__(self, project=None, credentials=None, http=None):
177         _ClientProjectMixin.__init__(self, project=project)
178         Client.__init__(self, credentials=credentials, http=http)
179
```
--- 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/gcloud/client.py b/gcloud/client.py
--- a/gcloud/client.py
+++ b/gcloud/client.py
@@ -141,6 +141,8 @@
         if project is None:
             raise ValueError('Project was not passed and could not be '
                              'determined from the environment.')
+        if isinstance(project, six.binary_type):
+            project = project.decode('utf-8')
         if not isinstance(project, six.string_types):
             raise ValueError('Project must be a string.')
         self.project = project

{"golden_diff": "diff --git a/gcloud/client.py b/gcloud/client.py\n--- a/gcloud/client.py\n+++ b/gcloud/client.py\n@@ -141,6 +141,8 @@\n         if project is None:\n             raise ValueError('Project was not passed and could not be '\n                              'determined from the environment.')\n+        if isinstance(project, six.binary_type):\n+            project = project.decode('utf-8')\n         if not isinstance(project, six.string_types):\n             raise ValueError('Project must be a string.')\n         self.project = project\n", "issue": "Project inference is broken under Python 3.5.1\nProject inference takes place in [_determine_default_project()](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/_helpers.py#L189), which hands off to [_compute_engine_id()](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/_helpers.py#L151). That returns the correct value -- but as `bytes`. The `Client` class checks if the project value is a `str` (using `six.string_types`) and raises an error because it is not (that code is [here](https://github.com/GoogleCloudPlatform/gcloud-python/blob/91be6938b26ba9198082f457ae37fba81b8f5ea0/gcloud/client.py#L144)).\n\n", "before_files": [{"content": "# Copyright 2015 Google Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Base classes for client used to interact with Google Cloud APIs.\"\"\"\n\nimport six\n\nfrom gcloud._helpers import _determine_default_project\nfrom gcloud.connection import Connection\nfrom gcloud.credentials import get_credentials\nfrom gcloud.credentials import get_for_service_account_json\nfrom gcloud.credentials import get_for_service_account_p12\n\n\nclass _ClientFactoryMixin(object):\n    \"\"\"Mixin to allow factories that create credentials.\n\n    .. note::\n\n        This class is virtual.\n    \"\"\"\n\n    @classmethod\n    def from_service_account_json(cls, json_credentials_path, *args, **kwargs):\n        \"\"\"Factory to retrieve JSON credentials while creating client.\n\n        :type json_credentials_path: string\n        :param json_credentials_path: The path to a private key file (this file\n                                      was given to you when you created the\n                                      service account). This file must contain\n                                      a JSON object with a private key and\n                                      other credentials information (downloaded\n                                      from the Google APIs console).\n\n        :type args: tuple\n        :param args: Remaining positional arguments to pass to constructor.\n\n        :type kwargs: dict\n        :param kwargs: Remaining keyword arguments to pass to constructor.\n\n        :rtype: :class:`gcloud.pubsub.client.Client`\n        :returns: The client created with the retrieved JSON credentials.\n        :raises: :class:`TypeError` if there is a conflict with the kwargs\n                 and the credentials created by the factory.\n        \"\"\"\n        if 'credentials' in kwargs:\n            raise TypeError('credentials must not be in keyword arguments')\n        credentials = get_for_service_account_json(json_credentials_path)\n        kwargs['credentials'] = credentials\n        return cls(*args, **kwargs)\n\n    @classmethod\n    def from_service_account_p12(cls, client_email, private_key_path,\n                                 *args, **kwargs):\n        \"\"\"Factory to retrieve P12 credentials while creating client.\n\n        .. note::\n          Unless you have an explicit reason to use a PKCS12 key for your\n          service account, we recommend using a JSON key.\n\n        :type client_email: string\n        :param client_email: The e-mail attached to the service account.\n\n        :type private_key_path: string\n        :param private_key_path: The path to a private key file (this file was\n                                 given to you when you created the service\n                                 account). This file must be in P12 format.\n\n        :type args: tuple\n        :param args: Remaining positional arguments to pass to constructor.\n\n        :type kwargs: dict\n        :param kwargs: Remaining keyword arguments to pass to constructor.\n\n        :rtype: :class:`gcloud.client.Client`\n        :returns: The client created with the retrieved P12 credentials.\n        :raises: :class:`TypeError` if there is a conflict with the kwargs\n                 and the credentials created by the factory.\n        \"\"\"\n        if 'credentials' in kwargs:\n            raise TypeError('credentials must not be in keyword arguments')\n        credentials = get_for_service_account_p12(client_email,\n                                                  private_key_path)\n        kwargs['credentials'] = credentials\n        return cls(*args, **kwargs)\n\n\nclass Client(_ClientFactoryMixin):\n    \"\"\"Client to bundle configuration needed for API requests.\n\n    Assumes that the associated ``_connection_class`` only accepts\n    ``http`` and ``credentials`` in its constructor.\n\n    :type credentials: :class:`oauth2client.client.OAuth2Credentials` or\n                       :class:`NoneType`\n    :param credentials: The OAuth2 Credentials to use for the connection\n                        owned by this client. If not passed (and if no ``http``\n                        object is passed), falls back to the default inferred\n                        from the environment.\n\n    :type http: :class:`httplib2.Http` or class that defines ``request()``.\n    :param http: An optional HTTP object to make requests. If not passed, an\n                 ``http`` object is created that is bound to the\n                 ``credentials`` for the current object.\n    \"\"\"\n\n    _connection_class = Connection\n\n    def __init__(self, credentials=None, http=None):\n        if credentials is None and http is None:\n            credentials = get_credentials()\n        self.connection = self._connection_class(\n            credentials=credentials, http=http)\n\n\nclass _ClientProjectMixin(object):\n    \"\"\"Mixin to allow setting the project on the client.\n\n    :type project: string\n    :param project: the project which the client acts on behalf of. If not\n                    passed falls back to the default inferred from the\n                    environment.\n\n    :raises: :class:`ValueError` if the project is neither passed in nor\n             set in the environment.\n    \"\"\"\n\n    def __init__(self, project=None):\n        project = _determine_default_project(project)\n        if project is None:\n            raise ValueError('Project was not passed and could not be '\n                             'determined from the environment.')\n        if not isinstance(project, six.string_types):\n            raise ValueError('Project must be a string.')\n        self.project = project\n\n\nclass JSONClient(Client, _ClientProjectMixin):\n    \"\"\"Client to for Google JSON-based API.\n\n    Assumes such APIs use the ``project`` and the client needs to store this\n    value.\n\n    :type project: string\n    :param project: the project which the client acts on behalf of. If not\n                    passed falls back to the default inferred from the\n                    environment.\n\n    :type credentials: :class:`oauth2client.client.OAuth2Credentials` or\n                       :class:`NoneType`\n    :param credentials: The OAuth2 Credentials to use for the connection\n                        owned by this client. If not passed (and if no ``http``\n                        object is passed), falls back to the default inferred\n                        from the environment.\n\n    :type http: :class:`httplib2.Http` or class that defines ``request()``.\n    :param http: An optional HTTP object to make requests. If not passed, an\n                 ``http`` object is created that is bound to the\n                 ``credentials`` for the current object.\n\n    :raises: :class:`ValueError` if the project is neither passed in nor\n             set in the environment.\n    \"\"\"\n\n    def __init__(self, project=None, credentials=None, http=None):\n        _ClientProjectMixin.__init__(self, project=project)\n        Client.__init__(self, credentials=credentials, http=http)\n", "path": "gcloud/client.py"}], "after_files": [{"content": "# Copyright 2015 Google Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Base classes for client used to interact with Google Cloud APIs.\"\"\"\n\nimport six\n\nfrom gcloud._helpers import _determine_default_project\nfrom gcloud.connection import Connection\nfrom gcloud.credentials import get_credentials\nfrom gcloud.credentials import get_for_service_account_json\nfrom gcloud.credentials import get_for_service_account_p12\n\n\nclass _ClientFactoryMixin(object):\n    \"\"\"Mixin to allow factories that create credentials.\n\n    .. note::\n\n        This class is virtual.\n    \"\"\"\n\n    @classmethod\n    def from_service_account_json(cls, json_credentials_path, *args, **kwargs):\n        \"\"\"Factory to retrieve JSON credentials while creating client.\n\n        :type json_credentials_path: string\n        :param json_credentials_path: The path to a private key file (this file\n                                      was given to you when you created the\n                                      service account). This file must contain\n                                      a JSON object with a private key and\n                                      other credentials information (downloaded\n                                      from the Google APIs console).\n\n        :type args: tuple\n        :param args: Remaining positional arguments to pass to constructor.\n\n        :type kwargs: dict\n        :param kwargs: Remaining keyword arguments to pass to constructor.\n\n        :rtype: :class:`gcloud.pubsub.client.Client`\n        :returns: The client created with the retrieved JSON credentials.\n        :raises: :class:`TypeError` if there is a conflict with the kwargs\n                 and the credentials created by the factory.\n        \"\"\"\n        if 'credentials' in kwargs:\n            raise TypeError('credentials must not be in keyword arguments')\n        credentials = get_for_service_account_json(json_credentials_path)\n        kwargs['credentials'] = credentials\n        return cls(*args, **kwargs)\n\n    @classmethod\n    def from_service_account_p12(cls, client_email, private_key_path,\n                                 *args, **kwargs):\n        \"\"\"Factory to retrieve P12 credentials while creating client.\n\n        .. note::\n          Unless you have an explicit reason to use a PKCS12 key for your\n          service account, we recommend using a JSON key.\n\n        :type client_email: string\n        :param client_email: The e-mail attached to the service account.\n\n        :type private_key_path: string\n        :param private_key_path: The path to a private key file (this file was\n                                 given to you when you created the service\n                                 account). This file must be in P12 format.\n\n        :type args: tuple\n        :param args: Remaining positional arguments to pass to constructor.\n\n        :type kwargs: dict\n        :param kwargs: Remaining keyword arguments to pass to constructor.\n\n        :rtype: :class:`gcloud.client.Client`\n        :returns: The client created with the retrieved P12 credentials.\n        :raises: :class:`TypeError` if there is a conflict with the kwargs\n                 and the credentials created by the factory.\n        \"\"\"\n        if 'credentials' in kwargs:\n            raise TypeError('credentials must not be in keyword arguments')\n        credentials = get_for_service_account_p12(client_email,\n                                                  private_key_path)\n        kwargs['credentials'] = credentials\n        return cls(*args, **kwargs)\n\n\nclass Client(_ClientFactoryMixin):\n    \"\"\"Client to bundle configuration needed for API requests.\n\n    Assumes that the associated ``_connection_class`` only accepts\n    ``http`` and ``credentials`` in its constructor.\n\n    :type credentials: :class:`oauth2client.client.OAuth2Credentials` or\n                       :class:`NoneType`\n    :param credentials: The OAuth2 Credentials to use for the connection\n                        owned by this client. If not passed (and if no ``http``\n                        object is passed), falls back to the default inferred\n                        from the environment.\n\n    :type http: :class:`httplib2.Http` or class that defines ``request()``.\n    :param http: An optional HTTP object to make requests. If not passed, an\n                 ``http`` object is created that is bound to the\n                 ``credentials`` for the current object.\n    \"\"\"\n\n    _connection_class = Connection\n\n    def __init__(self, credentials=None, http=None):\n        if credentials is None and http is None:\n            credentials = get_credentials()\n        self.connection = self._connection_class(\n            credentials=credentials, http=http)\n\n\nclass _ClientProjectMixin(object):\n    \"\"\"Mixin to allow setting the project on the client.\n\n    :type project: string\n    :param project: the project which the client acts on behalf of. If not\n                    passed falls back to the default inferred from the\n                    environment.\n\n    :raises: :class:`ValueError` if the project is neither passed in nor\n             set in the environment.\n    \"\"\"\n\n    def __init__(self, project=None):\n        project = _determine_default_project(project)\n        if project is None:\n            raise ValueError('Project was not passed and could not be '\n                             'determined from the environment.')\n        if isinstance(project, six.binary_type):\n            project = project.decode('utf-8')\n        if not isinstance(project, six.string_types):\n            raise ValueError('Project must be a string.')\n        self.project = project\n\n\nclass JSONClient(Client, _ClientProjectMixin):\n    \"\"\"Client to for Google JSON-based API.\n\n    Assumes such APIs use the ``project`` and the client needs to store this\n    value.\n\n    :type project: string\n    :param project: the project which the client acts on behalf of. If not\n                    passed falls back to the default inferred from the\n                    environment.\n\n    :type credentials: :class:`oauth2client.client.OAuth2Credentials` or\n                       :class:`NoneType`\n    :param credentials: The OAuth2 Credentials to use for the connection\n                        owned by this client. If not passed (and if no ``http``\n                        object is passed), falls back to the default inferred\n                        from the environment.\n\n    :type http: :class:`httplib2.Http` or class that defines ``request()``.\n    :param http: An optional HTTP object to make requests. If not passed, an\n                 ``http`` object is created that is bound to the\n                 ``credentials`` for the current object.\n\n    :raises: :class:`ValueError` if the project is neither passed in nor\n             set in the environment.\n    \"\"\"\n\n    def __init__(self, project=None, credentials=None, http=None):\n        _ClientProjectMixin.__init__(self, project=project)\n        Client.__init__(self, credentials=credentials, http=http)\n", "path": "gcloud/client.py"}]}