Mercurial > hg
comparison mercurial/url.py @ 14964:376c32a5ccdc
url: replace uses of hasattr with safehasattr or getattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 15:55:51 -0500 |
parents | e7525a555a64 |
children | d0424f39984c |
comparison
equal
deleted
inserted
replaced
14963:c035f1c53e39 | 14964:376c32a5ccdc |
---|---|
127 orgsend(self, chunk) | 127 orgsend(self, chunk) |
128 else: | 128 else: |
129 orgsend(self, data) | 129 orgsend(self, data) |
130 return _sendfile | 130 return _sendfile |
131 | 131 |
132 has_https = hasattr(urllib2, 'HTTPSHandler') | 132 has_https = util.safehasattr(urllib2, 'HTTPSHandler') |
133 if has_https: | 133 if has_https: |
134 try: | 134 try: |
135 _create_connection = socket.create_connection | 135 _create_connection = socket.create_connection |
136 except AttributeError: | 136 except AttributeError: |
137 _GLOBAL_DEFAULT_TIMEOUT = object() | 137 _GLOBAL_DEFAULT_TIMEOUT = object() |
184 return keepalive.HTTPConnection.getresponse(self) | 184 return keepalive.HTTPConnection.getresponse(self) |
185 | 185 |
186 # general transaction handler to support different ways to handle | 186 # general transaction handler to support different ways to handle |
187 # HTTPS proxying before and after Python 2.6.3. | 187 # HTTPS proxying before and after Python 2.6.3. |
188 def _generic_start_transaction(handler, h, req): | 188 def _generic_start_transaction(handler, h, req): |
189 if hasattr(req, '_tunnel_host') and req._tunnel_host: | 189 tunnel_host = getattr(req, '_tunnel_host', None) |
190 tunnel_host = req._tunnel_host | 190 if tunnel_host: |
191 if tunnel_host[:7] not in ['http://', 'https:/']: | 191 if tunnel_host[:7] not in ['http://', 'https:/']: |
192 tunnel_host = 'https://' + tunnel_host | 192 tunnel_host = 'https://' + tunnel_host |
193 new_tunnel = True | 193 new_tunnel = True |
194 else: | 194 else: |
195 tunnel_host = req.get_selector() | 195 tunnel_host = req.get_selector() |