From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Lwux8-0003oK-3p for garchives@archives.gentoo.org; Thu, 23 Apr 2009 09:10:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D9535E03C5; Thu, 23 Apr 2009 09:10:40 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 923D8E03BA for ; Thu, 23 Apr 2009 09:10:40 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 0FD80650F7 for ; Thu, 23 Apr 2009 09:10:40 +0000 (UTC) Received: from patrick by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1Lwux5-0003e9-Ez for gentoo-commits@lists.gentoo.org; Thu, 23 Apr 2009 09:10:39 +0000 From: "Patrick Lauer (patrick)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, patrick@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in dev-python/httplib2/files: compat-2.6-0.4.0.patch X-VCS-Repository: gentoo-x86 X-VCS-Files: compat-2.6-0.4.0.patch X-VCS-Directories: dev-python/httplib2/files X-VCS-Committer: patrick X-VCS-Committer-Name: Patrick Lauer Content-Type: text/plain; charset=utf8 Message-Id: Sender: Patrick Lauer Date: Thu, 23 Apr 2009 09:10:39 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: c1f68c57-23d9-4b61-8ff8-fa7af4be002b X-Archives-Hash: 7c3f9fb01f66b402ebc7b253b6a3b5cd patrick 09/04/23 09:10:39 Added: compat-2.6-0.4.0.patch Log: Py 2.6 deprecation fix. Thanks to djc for pointing it out, thanks to Be= noit Chesneau for the patch. Fixes #267184 (Portage version: 2.2_rc31/cvs/Linux x86_64) Revision Changes Path 1.1 dev-python/httplib2/files/compat-2.6-0.4.0.patch file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-python/httplib= 2/files/compat-2.6-0.4.0.patch?rev=3D1.1&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-python/httplib= 2/files/compat-2.6-0.4.0.patch?rev=3D1.1&content-type=3Dtext/plain Index: compat-2.6-0.4.0.patch =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: httplib2/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- httplib2/__init__.py (revision 274) +++ httplib2/__init__.py (revision 275) @@ -26,7 +26,6 @@ =20 import re=20 import sys=20 -import md5 import email import email.Utils import email.Message @@ -42,7 +41,14 @@ import calendar import time import random -import sha +# remove depracated warning in python2.6 +try: + from hashlib import sha1 as _sha, md5 as _md5 +except ImportError: + import sha + import md5 + _sha =3D sha.new + _md5 =3D md5.new import hmac from gettext import gettext as _ import socket @@ -52,12 +58,27 @@ except ImportError: socks =3D None =20 +# Build the appropriate socket wrapper for ssl +try: + import ssl # python 2.6 + _ssl_wrap_socket =3D ssl.wrap_socket +except ImportError: + def _ssl_wrap_socket(sock, key_file, cert_file): + ssl_sock =3D socket.ssl(sock, key_file, cert_file) + return httplib.FakeSocket(sock, ssl_sock) + + if sys.version_info >=3D (2,3): from iri2uri import iri2uri else: def iri2uri(uri): return uri =20 +def has_timeout(timeout): # python 2.6 + if hasattr(socket, '_GLOBAL_DEFAULT_TIMEOUT'): + return (timeout is not None and timeout is not socket._GLOBAL_DE= FAULT_TIMEOUT) + return (timeout is not None) + __all__ =3D ['Http', 'Response', 'ProxyInfo', 'HttpLib2Error', 'RedirectMissingLocation', 'RedirectLimit', 'FailedToDecompressContent= ',=20 'UnimplementedDigestAuthOptionError', 'UnimplementedHmacDigestAuthOpti= onError', @@ -182,7 +203,7 @@ pass if isinstance(filename,unicode): filename=3Dfilename.encode('utf-8') - filemd5 =3D md5.new(filename).hexdigest() + filemd5 =3D _md5(filename).hexdigest() filename =3D re_url_scheme.sub("", filename) filename =3D re_slash.sub(",", filename) =20 @@ -363,11 +384,11 @@ cache.set(cachekey, text) =20 def _cnonce(): - dig =3D md5.new("%s:%s" % (time.ctime(), ["0123456789"[random.randra= nge(0, 9)] for i in range(20)])).hexdigest() + dig =3D _md5("%s:%s" % (time.ctime(), ["0123456789"[random.randrange= (0, 9)] for i in range(20)])).hexdigest() return dig[:16] =20 def _wsse_username_token(cnonce, iso_now, password): - return base64.encodestring(sha.new("%s%s%s" % (cnonce, iso_now, pass= word)).digest()).strip() + return base64.encodestring(_sha("%s%s%s" % (cnonce, iso_now, passwor= d)).digest()).strip() =20 =20 # For credentials we need two things, first=20 @@ -441,7 +462,7 @@ =20 def request(self, method, request_uri, headers, content, cnonce =3D = None): """Modify the request headers""" - H =3D lambda x: md5.new(x).hexdigest() + H =3D lambda x: _md5(x).hexdigest() KD =3D lambda s, d: H("%s:%s" % (s, d)) A2 =3D "".join([method, ":", request_uri]) self.challenge['cnonce'] =3D cnonce or _cnonce()=20 @@ -501,13 +522,13 @@ if self.challenge['pw-algorithm'] not in ['SHA-1', 'MD5']: raise UnimplementedHmacDigestAuthOptionError( _("Unsupported= value for pw-algorithm: %s." % self.challenge['pw-algorithm'])) if self.challenge['algorithm'] =3D=3D 'HMAC-MD5': - self.hashmod =3D md5 + self.hashmod =3D _md5 else: - self.hashmod =3D sha + self.hashmod =3D _sha if self.challenge['pw-algorithm'] =3D=3D 'MD5': - self.pwhashmod =3D md5 + self.pwhashmod =3D _md5 else: - self.pwhashmod =3D sha + self.pwhashmod =3D _sha self.key =3D "".join([self.credentials[0], ":", self.pwhashmod.new("".join([self.credentials[1], sel= f.challenge['salt']])).hexdigest().lower(), ":", self.challenge['realm'] @@ -604,9 +625,6 @@ =20 AUTH_SCHEME_ORDER =3D ["hmacdigest", "googlelogin", "digest", "wsse", "b= asic"] =20 -def _md5(s): - return=20 - class FileCache(object): """Uses a local directory as a store for cached files. Not really safe to use if multiple threads or processes are going to= =20 @@ -701,7 +719,7 @@ else: self.sock =3D socket.socket(af, socktype, proto) # Different from httplib: support timeouts. - if self.timeout is not None: + if has_timeout(self.timeout): self.sock.settimeout(self.timeout) # End of difference from httplib. if self.debuglevel > 0: @@ -737,11 +755,11 @@ sock.setproxy(*self.proxy_info.astuple()) else: sock =3D socket.socket(socket.AF_INET, socket.SOCK_STREAM) - if self.timeout is not None: + =20 + if has_timeout(self.timeout): sock.settimeout(self.timeout) sock.connect((self.host, self.port)) - ssl =3D socket.ssl(sock, self.key_file, self.cert_file) - self.sock =3D httplib.FakeSocket(sock, ssl) + self.sock =3D_ssl_wrap_socket(sock, self.key_file, self.cert_fil= e) =20 =20 =20