Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Unified Diff: tools/presubmit.py

Issue 3026030: Use hashlib module instead of md5 if it is present. (Closed)
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/presubmit.py
diff --git a/tools/presubmit.py b/tools/presubmit.py
index 04952e0b4a232e3e9cc1f3c857cccd96d576b3ef..e69c9a85ac8e3ee033779c2f2847b3061abbf226 100755
--- a/tools/presubmit.py
+++ b/tools/presubmit.py
@@ -27,8 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+try:
+ import hashlib
+ md5er = hashlib.md5
+except ImportError, e:
+ import md5
+ md5er = md5.new
+
-import md5
import optparse
import os
from os.path import abspath, join, dirname, basename, exists
@@ -126,7 +132,7 @@ class FileContentsCache(object):
for file in files:
try:
handle = open(file, "r")
- file_sum = md5.new(handle.read()).digest()
+ file_sum = md5er(handle.read()).digest()
if not file in self.sums or self.sums[file] != file_sum:
changed_or_new.append(file)
self.sums[file] = file_sum
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698