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
=== modified file 'modules/cscvs/dircompare/dirsums.py'
--- modules/cscvs/dircompare/dirsums.py 2007-05-08 08:29:23 +0000
+++ modules/cscvs/dircompare/dirsums.py 2010-04-14 01:53:16 +0000
@@ -15,7 +15,7 @@
15# This code was taken from hct.15# This code was taken from hct.
1616
17import os17import os
18import md518import hashlib
1919
20from cscvs.dircompare import tree20from cscvs.dircompare import tree
2121
@@ -41,7 +41,7 @@
41 else:41 else:
42 f = open(path, "r")42 f = open(path, "r")
43 try:43 try:
44 return md5.new(f.read()).hexdigest()44 return hashlib.md5(f.read()).hexdigest()
45 finally:45 finally:
46 f.close()46 f.close()
4747
4848
=== modified file 'modules/cscvs/dircompare/path.py'
--- modules/cscvs/dircompare/path.py 2007-05-08 08:55:32 +0000
+++ modules/cscvs/dircompare/path.py 2010-04-14 01:53:16 +0000
@@ -15,7 +15,7 @@
1515
16import os16import os
17import re17import re
18import md518import hashlib
19import stat19import stat
20import urlparse20import urlparse
2121
@@ -258,7 +258,7 @@
258 def md5sum(self):258 def md5sum(self):
259 """Cache and return MD5 digest for path."""259 """Cache and return MD5 digest for path."""
260 if self.isfile:260 if self.isfile:
261 return md5.new(open(self).read()).hexdigest()261 return hashlib.md5(open(self).read()).hexdigest()
262 else:262 else:
263 return None263 return None
264264
265265
=== modified file 'modules/cscvs/dircompare/tests/test_dirsums.py'
--- modules/cscvs/dircompare/tests/test_dirsums.py 2007-05-08 08:29:23 +0000
+++ modules/cscvs/dircompare/tests/test_dirsums.py 2010-04-14 01:53:16 +0000
@@ -10,7 +10,7 @@
10# These tests were taken from hct.10# These tests were taken from hct.
1111
12import os12import os
13import md513import hashlib
1414
15from tests import TestUtil15from tests import TestUtil
1616
@@ -33,7 +33,7 @@
33 """file_sum returns correct MD5 of file."""33 """file_sum returns correct MD5 of file."""
34 from cscvs.dircompare.dirsums import file_sum34 from cscvs.dircompare.dirsums import file_sum
35 self.assertEquals(file_sum(os.path.join(self.dir, "file")),35 self.assertEquals(file_sum(os.path.join(self.dir, "file")),
36 md5.new(self.STR).hexdigest())36 hashlib.md5(self.STR).hexdigest())
3737
38 def testSymlink(self):38 def testSymlink(self):
39 """file_sum returns symlink destination instead of sum."""39 """file_sum returns symlink destination instead of sum."""
@@ -102,8 +102,8 @@
102 """calculate contains the right MD5 sum for files."""102 """calculate contains the right MD5 sum for files."""
103 from cscvs.dircompare.dirsums import calculate103 from cscvs.dircompare.dirsums import calculate
104 sums = calculate(self.dir, source=["file", "dir/file"])104 sums = calculate(self.dir, source=["file", "dir/file"])
105 self.assertEquals(sums["file"], md5.new(self.STR1).hexdigest())105 self.assertEquals(sums["file"], hashlib.md5(self.STR1).hexdigest())
106 self.assertEquals(sums["dir/file"], md5.new(self.STR2).hexdigest())106 self.assertEquals(sums["dir/file"], hashlib.md5(self.STR2).hexdigest())
107107
108 def testInodes(self):108 def testInodes(self):
109 """calculate contains the inode information for files."""109 """calculate contains the inode information for files."""
110110
=== modified file 'modules/cscvs/dircompare/tests/test_path.py'
--- modules/cscvs/dircompare/tests/test_path.py 2008-09-15 17:33:30 +0000
+++ modules/cscvs/dircompare/tests/test_path.py 2010-04-14 01:53:16 +0000
@@ -344,9 +344,9 @@
344 tmpfile = self.tempname()344 tmpfile = self.tempname()
345 self.write("This is a file.\n", tmpfile)345 self.write("This is a file.\n", tmpfile)
346 from cscvs.dircompare.path import Path346 from cscvs.dircompare.path import Path
347 import md5347 import hashlib
348 self.assertEquals(Path(tmpfile).md5sum,348 self.assertEquals(Path(tmpfile).md5sum,
349 md5.new(open(tmpfile).read()).hexdigest())349 hashlib.md5(open(tmpfile).read()).hexdigest())
350350
351 def testNotExist(self):351 def testNotExist(self):
352 """Path.md5sum returns None for a non-existant file."""352 """Path.md5sum returns None for a non-existant file."""

Subscribers

People subscribed via source and target branches