Gentoo Archives: gentoo-commits

From: "Jesus Rivero (neurogeek)" <neurogeek@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-python/pycrypto/files: pycrypto-2.0.1-2.6_hashlib.patch
Date: Sun, 01 Mar 2009 08:24:04
Message-Id: E1Ldgxu-0006OH-Ha@stork.gentoo.org
1 neurogeek 09/03/01 08:24:02
2
3 Added: pycrypto-2.0.1-2.6_hashlib.patch
4 Log:
5 Version bump. Fixes bug #246406 2.6 (deprecation warnings). Thanks to Christian Becke for the patches.
6 (Portage version: 2.2_rc20/cvs/Linux 2.6.27-gentoo-r7 i686)
7
8 Revision Changes Path
9 1.1 dev-python/pycrypto/files/pycrypto-2.0.1-2.6_hashlib.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-python/pycrypto/files/pycrypto-2.0.1-2.6_hashlib.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-python/pycrypto/files/pycrypto-2.0.1-2.6_hashlib.patch?rev=1.1&content-type=text/plain
13
14 Index: pycrypto-2.0.1-2.6_hashlib.patch
15 ===================================================================
16 #From: Dwayne C. Litzenberger <dlitz@×××××.net>
17 #Date: Sun, 14 Sep 2008 19:30:59 +0000 (-0400)
18 #Subject: Python 2.6 compatibility: When possible, use hashlib instead of the deprecated 'md5...
19 #X-Git-Url: http://gitweb.pycrypto.org/?p=crypto%2Fpycrypto-2.x.git;a=commitdiff_plain;h=d2311689910240e425741a546576129f4c9735e2
20 #
21 #Python 2.6 compatibility: When possible, use hashlib instead of the deprecated 'md5' and 'sha' modules
22 #---
23 #
24 #diff --git a/Hash/MD5.py b/Hash/MD5.py
25 #index bdbc62a..e79a85f 100644
26 --- a/Hash/MD5.py
27 +++ b/Hash/MD5.py
28 @@ -3,11 +3,21 @@
29
30 __revision__ = "$Id: pycrypto-2.0.1-2.6_hashlib.patch,v 1.1 2009/03/01 08:24:02 neurogeek Exp $"
31
32 -from md5 import *
33 +__all__ = ['new', 'digest_size']
34
35 -import md5
36 -if hasattr(md5, 'digestsize'):
37 - digest_size = digestsize
38 - del digestsize
39 -del md5
40 +try:
41 + # The md5 module is deprecated in Python 2.6, so use hashlib when possible.
42 + import hashlib
43 + def new(data=""):
44 + return hashlib.md5(data)
45 + digest_size = new().digest_size
46 +
47 +except ImportError:
48 + from md5 import *
49 +
50 + import md5
51 + if hasattr(md5, 'digestsize'):
52 + digest_size = digestsize
53 + del digestsize
54 + del md5
55
56 diff --git a/Hash/SHA.py b/Hash/SHA.py
57 index dc05502..f4128ec 100644
58 --- a/Hash/SHA.py
59 +++ b/Hash/SHA.py
60 @@ -3,9 +3,19 @@
61
62 __revision__ = "$Id: pycrypto-2.0.1-2.6_hashlib.patch,v 1.1 2009/03/01 08:24:02 neurogeek Exp $"
63
64 -from sha import *
65 -import sha
66 -if hasattr(sha, 'digestsize'):
67 - digest_size = digestsize
68 - del digestsize
69 -del sha
70 +__all__ = ['new', 'digest_size']
71 +
72 +try:
73 + # The md5 module is deprecated in Python 2.6, so use hashlib when possible.
74 + import hashlib
75 + def new(data=""):
76 + return hashlib.sha1(data)
77 + digest_size = new().digest_size
78 +
79 +except ImportError:
80 + from sha import *
81 + import sha
82 + if hasattr(sha, 'digestsize'):
83 + digest_size = digestsize
84 + del digestsize
85 + del sha
86 #From: Dwayne C. Litzenberger <dlitz@×××××.net>
87 #Date: Sun, 14 Sep 2008 21:38:52 +0000 (-0400)
88 #Subject: Python 2.6 compatibility: Use Hash.MD5 instead of Python "md5" module in the HMAC...
89 #X-Git-Url: http://gitweb.pycrypto.org/?p=crypto%2Fpycrypto-2.0.x.git;a=commitdiff_plain;h=84b793416b52311643bfd456a4544444afbfb5da
90 #
91 #Python 2.6 compatibility: Use Hash.MD5 instead of Python "md5" module in the HMAC module.
92 #---
93
94 #diff --git a/Hash/HMAC.py b/Hash/HMAC.py
95 #index b8a9229..6ed9556 100644
96 --- a/Hash/HMAC.py
97 +++ b/Hash/HMAC.py
98 @@ -33,8 +33,8 @@ class HMAC:
99 digestmod: A module supporting PEP 247. Defaults to the md5 module.
100 """
101 if digestmod == None:
102 - import md5
103 - digestmod = md5
104 + import MD5
105 + digestmod = MD5
106
107 self.digestmod = digestmod
108 self.outer = digestmod.new()