-
Notifications
You must be signed in to change notification settings - Fork 2.5k
googleapiclient.http: guard when importing ssl #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
googleapiclient.http: guard when importing ssl #220
Conversation
|
What situations are you in where |
|
Ah okay, I see, I read the issue. So the issue is that App Engine doesn't have the SSL module available by default. |
|
@nathanielmanistaatgoogle I am on the fence about App Engine-specific changes. WDYT? |
|
@jonparrott Thanks for looking. Perhaps we can continue the thread at #191? |
|
Nah, if @nathanielmanistaatgoogle is cool with this we can merge. :) |
|
By the way, I have ran the tests with tox for py27-oauth2client1/2 and they remain working. I also tested on App Engine, by listing a Cloud Storage bucket: |
googleapiclient/http.py
Outdated
| # Engine. | ||
| library = '' | ||
| reason = '' | ||
|
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@nathanielmanistaatgoogle FWIW ssl library available by default should hopefully happen this quarter, but no promises. |
|
With that in mind I agree the absence of the ssl module should not have compatibility. ;) |
0b32ed1 to
77f89b0
Compare
|
@nathanielmanistaatgoogle Sorry to have wounded it. Dropped the blank line and made accesses to |
| else: | ||
| self.num_errors -= 1 | ||
| if self.num_errors == 1: | ||
| raise ssl.SSLError() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
You're right, we don't run tests on App Engine, or any environment without |
|
@jonparrott: please take another look at this? I feel like where I've directed this change is correct, but also pretty radical. Any qualms? Also, any desire for a comment in the clearly weird code? Should we open an issue for removing this as soon as possible? |
|
@nathanielmanistaatgoogle This LGTM and I'm okay with it. I agree we should file a bug to remove this once ssl is on by default in GAE. |
| import uuid | ||
|
|
||
|
|
||
| try: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Fix googleapis#191 by adding a guard when importing `ssl`, and replace all direct references to `SSLError` (the sole member of `ssl` being used) with a shim, `_ssl_SSLError`. It is prefixed with a '_' to caution users against relying on the name when importing `googleclient.http`. `httplib2` also takes a similar approach (see `ssl_SSLError` in `httplib2/__init__.py`).
|
Done! Added the |
Ignore PyCharm config files
Fix #191 by adding a guard when importing
ssl, and replace all directreferences to
SSLError(the sole member ofsslbeing used) with ashim,
_ssl_SSLError. It is prefixed with a '_' to caution usersagainst relying on the name when importing
googleclient.http.httplib2also takes the same approach (seessl_SSLErrorinhttplib2/__init__.py), but instead of usingNonewhen fakingSSLError, we provide a 'real' class, so that code can continue totrigger the exception handler for
SSLErroringoogleclient.http(eg.in tests,
SSLError's are raised). If the shim_ssl_SSLErrorwereNone, an exception handler for it would not catch anything, asNoneis not a class and we could never throw anything that could be
"compatible" with
None[1][1] https://docs.python.org/2/reference/compound_stmts.html#except