diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-12-15 23:24:16 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-12-16 01:07:31 -0800 |
commit | 6907399e125a05cc6770a49cb8923cf6f05db3cf (patch) | |
tree | c4074e8a13a1149468ad2953f0aae071536b4498 | |
parent | f09d9619bcbc0f9f1a6fa2008415e99eb0fd030b (diff) | |
download | portage-6907399e125a05cc6770a49cb8923cf6f05db3cf.tar.gz portage-6907399e125a05cc6770a49cb8923cf6f05db3cf.tar.bz2 portage-6907399e125a05cc6770a49cb8923cf6f05db3cf.zip |
getbinpkg.py: use local HTTPSConnection import
Use local import since https typically isn't needed, and this way we
can usually avoid triggering the global scope http.client ImportError
handler (like during stage1 -> stage2 builds where USE=ssl is disabled
for python).
-rw-r--r-- | pym/portage/getbinpkg.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index c8a0edc4d..b225eab7f 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -43,13 +43,11 @@ else: try: try: from http.client import HTTPConnection as http_client_HTTPConnection - from http.client import HTTPSConnection as http_client_HTTPSConnection from http.client import BadStatusLine as http_client_BadStatusLine from http.client import ResponseNotReady as http_client_ResponseNotReady from http.client import error as http_client_error except ImportError: from httplib import HTTPConnection as http_client_HTTPConnection - from httplib import HTTPSConnection as http_client_HTTPSConnection from httplib import BadStatusLine as http_client_BadStatusLine from httplib import ResponseNotReady as http_client_ResponseNotReady from httplib import error as http_client_error @@ -161,6 +159,18 @@ def create_conn(baseurl,conn=None): if not conn: if protocol == "https": + # Use local import since https typically isn't needed, and + # this way we can usually avoid triggering the global scope + # http.client ImportError handler (like during stage1 -> stage2 + # builds where USE=ssl is disabled for python). + try: + try: + from http.client import HTTPSConnection as http_client_HTTPSConnection + except ImportError: + from httplib import HTTPSConnection as http_client_HTTPSConnection + except ImportError: + raise NotImplementedError( + _("python must have ssl enabled for https support")) conn = http_client_HTTPSConnection(host) elif protocol == "http": conn = http_client_HTTPConnection(host) |