-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SG-13264 Update sgsix, fix httplib2 import (#220)
* Add platform and normalize_platform to sgsix to unify platform value on linux across Python 2/3 * Change httplib import procedure to emulate direct import of the module * Add test to ensure httplib2 is importable as expected
- Loading branch information
Showing
3 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,39 @@ | ||
from .. import six | ||
|
||
# import the proper implementation into the module namespace depending on the | ||
# Define all here to keep linters happy. It should be overwritten by the code | ||
# below, but if in the future __all__ is not defined in httplib2 this will keep | ||
# things from breaking. | ||
__all__ = [] | ||
|
||
# Import the proper implementation into the module namespace depending on the | ||
# current python version. httplib2 supports python 2/3 by forking the code rather | ||
# than with a single cross-compatible module. Rather than modify third party code, | ||
# we'll just import the appropriate branch here. | ||
if six.PY3: | ||
from .python3 import * | ||
from .python3 import socks # ensure include in namespace | ||
import ssl | ||
ssl_error_classes = (ssl.SSLError, ssl.CertificateError) | ||
# Generate ssl_error_classes | ||
import ssl as __ssl | ||
ssl_error_classes = (__ssl.SSLError, __ssl.CertificateError) | ||
del __ssl | ||
|
||
# get the python3 fork of httplib2 | ||
from . import python3 as __httplib2_compat | ||
|
||
|
||
else: | ||
from .python2 import * | ||
from .python2 import socks # ensure include in namespace | ||
from .python2 import SSLHandshakeError # TODO: shouldn't rely on this. not public | ||
ssl_error_classes = (SSLHandshakeError,) | ||
# Generate ssl_error_classes | ||
from .python2 import SSLHandshakeError as __SSLHandshakeError # TODO: shouldn't rely on this. not public | ||
ssl_error_classes = (__SSLHandshakeError,) | ||
del __SSLHandshakeError | ||
|
||
# get the python2 fork of httplib2 | ||
from . import python2 as __httplib2_compat | ||
|
||
# Import all of the httplib2 module. Note that we can't use a star import because | ||
# we need to import *everything*, not just what exists in __all__. | ||
for __name in dir(__httplib2_compat): | ||
globals()[__name] = getattr(__httplib2_compat, __name) | ||
del __httplib2_compat | ||
del __name | ||
|
||
# Add ssl_error_classes to __all__ | ||
__all__.append("ssl_error_classes") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters