# HG changeset patch # User Augie Fackler # Date 1311627351 18000 # Node ID 376c32a5ccdc2c775f0df82f0f140fdb558abaff # Parent c035f1c53e395a057ffb4889ab753cce8fea811c url: replace uses of hasattr with safehasattr or getattr diff -r c035f1c53e39 -r 376c32a5ccdc mercurial/url.py --- a/mercurial/url.py Mon Jul 25 15:53:22 2011 -0500 +++ b/mercurial/url.py Mon Jul 25 15:55:51 2011 -0500 @@ -129,7 +129,7 @@ orgsend(self, data) return _sendfile -has_https = hasattr(urllib2, 'HTTPSHandler') +has_https = util.safehasattr(urllib2, 'HTTPSHandler') if has_https: try: _create_connection = socket.create_connection @@ -186,8 +186,8 @@ # general transaction handler to support different ways to handle # HTTPS proxying before and after Python 2.6.3. def _generic_start_transaction(handler, h, req): - if hasattr(req, '_tunnel_host') and req._tunnel_host: - tunnel_host = req._tunnel_host + tunnel_host = getattr(req, '_tunnel_host', None) + if tunnel_host: if tunnel_host[:7] not in ['http://', 'https:/']: tunnel_host = 'https://' + tunnel_host new_tunnel = True