[PATCH 3 of 8] url: remove is-comparisons with non-singletons
Dan Villiom Podlaski Christiansen
danchr at gmail.com
Tue Nov 16 14:36:14 CST 2010
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1289939758 -3600
# Branch stable
# Node ID 72e7c8769e4bb6cbfec1e796fd06e3416da51b26
# Parent b5093e797e19679cc8e7b01a7fd41feba94c6c27
url: remove is-comparisons with non-singletons.
There are two types of is-comparisons in this file:
The first one is unnessecary as _GLOBAL_DEFAULT_TIMEOUT is an
unspecialized object, and thus has no notion of equality other than
its identity.
The second one, in the auth handlers, seem unnecessary as well. The
urllib2.Request type does not provide an equality implementation, so
regular comparison should fall back to the exact same semantics.
[1] <http://docs.python.org/c-api/int.html#PyInt_FromLong>
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -318,7 +318,7 @@ if has_https:
sock = None
try:
sock = socket.socket(af, socktype, proto)
- if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
+ if timeout != _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
@@ -593,7 +593,7 @@ class httpdigestauthhandler(urllib2.HTTP
def http_error_auth_reqed(self, auth_header, host, req, headers):
# Reset the retry counter once for each request.
- if req is not self.retried_req:
+ if req != self.retried_req:
self.retried_req = req
self.retried = 0
# In python < 2.5 AbstractDigestAuthHandler raises a ValueError if
@@ -621,7 +621,7 @@ class httpbasicauthhandler(urllib2.HTTPB
def http_error_auth_reqed(self, auth_header, host, req, headers):
# Reset the retry counter once for each request.
- if req is not self.retried_req:
+ if req != self.retried_req:
self.retried_req = req
self.retried = 0
return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
More information about the Mercurial-devel
mailing list