Merge lp:~maxb/launchpad-cscvs/use-hashlib into lp:launchpad-cscvs

Proposed by Max Bowsher
Status: Merged
Approved by: Jonathan Lange
Approved revision: 431
Merged at revision: not available
Proposed branch: lp:~maxb/launchpad-cscvs/use-hashlib
Merge into: lp:launchpad-cscvs
Diff against target: 92 lines (+10/-10)
4 files modified
modules/cscvs/dircompare/dirsums.py (+2/-2)
modules/cscvs/dircompare/path.py (+2/-2)
modules/cscvs/dircompare/tests/test_dirsums.py (+4/-4)
modules/cscvs/dircompare/tests/test_path.py (+2/-2)
To merge this branch: bzr merge lp:~maxb/launchpad-cscvs/use-hashlib
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
Review via email: mp+23368@code.launchpad.net

Commit message

Use hashlib in place of md5 module, to avoid DeprecationWarnings.

Description of the change

Trivial migration from using md5 module to using hashlib module. The reason for doing this is to avoid DeprecationWarnings.

I realize cscvs is somewhat in deep maintenance mode, but it's actually easier to just fix these few DeprecationWarnings at the source, than to try to figure out how to reliably suppress them across the varied ways Launchpad processes are run.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Looks fine to me. Would you like me to merge it for you?

review: Approve
Revision history for this message
Max Bowsher (maxb) wrote :

> Looks fine to me. Would you like me to merge it for you?

Yes please.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/cscvs/dircompare/dirsums.py'
2--- modules/cscvs/dircompare/dirsums.py 2007-05-08 08:29:23 +0000
3+++ modules/cscvs/dircompare/dirsums.py 2010-04-14 01:53:16 +0000
4@@ -15,7 +15,7 @@
5 # This code was taken from hct.
6
7 import os
8-import md5
9+import hashlib
10
11 from cscvs.dircompare import tree
12
13@@ -41,7 +41,7 @@
14 else:
15 f = open(path, "r")
16 try:
17- return md5.new(f.read()).hexdigest()
18+ return hashlib.md5(f.read()).hexdigest()
19 finally:
20 f.close()
21
22
23=== modified file 'modules/cscvs/dircompare/path.py'
24--- modules/cscvs/dircompare/path.py 2007-05-08 08:55:32 +0000
25+++ modules/cscvs/dircompare/path.py 2010-04-14 01:53:16 +0000
26@@ -15,7 +15,7 @@
27
28 import os
29 import re
30-import md5
31+import hashlib
32 import stat
33 import urlparse
34
35@@ -258,7 +258,7 @@
36 def md5sum(self):
37 """Cache and return MD5 digest for path."""
38 if self.isfile:
39- return md5.new(open(self).read()).hexdigest()
40+ return hashlib.md5(open(self).read()).hexdigest()
41 else:
42 return None
43
44
45=== modified file 'modules/cscvs/dircompare/tests/test_dirsums.py'
46--- modules/cscvs/dircompare/tests/test_dirsums.py 2007-05-08 08:29:23 +0000
47+++ modules/cscvs/dircompare/tests/test_dirsums.py 2010-04-14 01:53:16 +0000
48@@ -10,7 +10,7 @@
49 # These tests were taken from hct.
50
51 import os
52-import md5
53+import hashlib
54
55 from tests import TestUtil
56
57@@ -33,7 +33,7 @@
58 """file_sum returns correct MD5 of file."""
59 from cscvs.dircompare.dirsums import file_sum
60 self.assertEquals(file_sum(os.path.join(self.dir, "file")),
61- md5.new(self.STR).hexdigest())
62+ hashlib.md5(self.STR).hexdigest())
63
64 def testSymlink(self):
65 """file_sum returns symlink destination instead of sum."""
66@@ -102,8 +102,8 @@
67 """calculate contains the right MD5 sum for files."""
68 from cscvs.dircompare.dirsums import calculate
69 sums = calculate(self.dir, source=["file", "dir/file"])
70- self.assertEquals(sums["file"], md5.new(self.STR1).hexdigest())
71- self.assertEquals(sums["dir/file"], md5.new(self.STR2).hexdigest())
72+ self.assertEquals(sums["file"], hashlib.md5(self.STR1).hexdigest())
73+ self.assertEquals(sums["dir/file"], hashlib.md5(self.STR2).hexdigest())
74
75 def testInodes(self):
76 """calculate contains the inode information for files."""
77
78=== modified file 'modules/cscvs/dircompare/tests/test_path.py'
79--- modules/cscvs/dircompare/tests/test_path.py 2008-09-15 17:33:30 +0000
80+++ modules/cscvs/dircompare/tests/test_path.py 2010-04-14 01:53:16 +0000
81@@ -344,9 +344,9 @@
82 tmpfile = self.tempname()
83 self.write("This is a file.\n", tmpfile)
84 from cscvs.dircompare.path import Path
85- import md5
86+ import hashlib
87 self.assertEquals(Path(tmpfile).md5sum,
88- md5.new(open(tmpfile).read()).hexdigest())
89+ hashlib.md5(open(tmpfile).read()).hexdigest())
90
91 def testNotExist(self):
92 """Path.md5sum returns None for a non-existant file."""

Subscribers

People subscribed via source and target branches