Open
Description
The fix for this bug in googleapiclient/discovery.py
needs to be backported to v1 for Python 2 users. Since I'm unable to reopen that bug, I had to file this new one instead.
Environment details
- OS type and version:
macos Ventura 13.7.6 (22H625)
- Python version:
Python 2.7.18
- pip version:
pip 20.3.4 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)
google-api-python-client
andhttplib2
versions:pip show google-api-python-client httplib2
$ pip show google-api-python-client httplib2 | egrep "Nam|Ver|Req"
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Name: google-api-python-client
Version: 1.12.11
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: google-auth-httplib2, rsa, httplib2, six, google-auth, google-api-core, uritemplate
Required-by:
Name: httplib2
Version: 0.22.0
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: pyparsing
Required-by: oauth2client, google-auth-httplib2, google-api-python-client
Steps to reproduce
- Get a Python 2 installation or venv/virtualenv
- Install necessary libs with
pip install -U pip google-api-python-client oauth2client
- Confirm libs installed with
python -c "import googleapiclient, httplib2, oauth2client"
(no errors or output) - Create sample app (see
1046test.py
below) - Run sample app (output below in Stack trace)
Code example (1046test.py
)
from googleapiclient import discovery
from httplib2 import Http
service = discovery.build('drive', 'v3', http=Http())
service.close()
Stack trace
$ python 1046test.py
Traceback (most recent call last):
File "1046test.py", line 5, in <module>
service.close()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery.py", line 1335, in close
self._http.http.close()
AttributeError: 'Http' object has no attribute 'http'
Solution
Reuse/apply the same 5-char fix to discovery.py
but to the latest v1 discovery.py
so Python 2 users can access the same fix Python 3 users have.