Traceback (most recent call last):
…
File "/usr/lib/python3.5/site-packages/oauth2client/util.py", line 142, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/googleapiclient/http.py", line 722, in execute
body=self.body, headers=self.headers)
File "/usr/lib/python3.5/site-packages/oauth2client/client.py", line 589, in new_request
redirections, connection_type)
File "/usr/lib/python3.5/site-packages/httplib2/__init__.py", line 1313, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/python3.5/site-packages/httplib2/__init__.py", line 1063, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/lib/python3.5/site-packages/httplib2/__init__.py", line 987, in _conn_request
conn.request(method, request_uri, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1127, in _send_request
body = body.encode('iso-8859-1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\ufffd' in position 350: ordinal not in range(256)
Seems like
MediaFileUpload(or something else deep inside) is failing to handling binary files properly on Python 3. My guess is that the contents of the file is mistakenly passed as a Unicode string (rather than as a byte-string) intohttp.client, which dies as soon as it encounters a non-Latin-1 character. This only happens whenresumable=False.Code to reproduce the problem:
Typical error:
(Using Python 3.5.0 on Arch Linux 4.2.2.)