Patchwork [2,of,7] md5sum: assume hashlib exists now that we're 2.7 only

login
register
mail settings
Submitter Augie Fackler
Date Aug. 22, 2017, 7:08 p.m.
Message ID <6a9a8a60bced4b42a4b0.1503428930@imladris.local>
Download mbox | patch
Permalink /patch/23208/
State Superseded
Headers show

Comments

Augie Fackler - Aug. 22, 2017, 7:08 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503428230 14400
#      Tue Aug 22 14:57:10 2017 -0400
# Node ID 6a9a8a60bced4b42a4b019b2f98c97672ce7a42b
# Parent  536b3969d2242224898f574919b134df4ba190a8
md5sum: assume hashlib exists now that we're 2.7 only

Patch

diff --git a/tests/md5sum.py b/tests/md5sum.py
--- a/tests/md5sum.py
+++ b/tests/md5sum.py
@@ -8,17 +8,11 @@ 
 
 from __future__ import absolute_import
 
+import hashlib
 import os
 import sys
 
 try:
-    import hashlib
-    md5 = hashlib.md5
-except ImportError:
-    import md5
-    md5 = md5.md5
-
-try:
     import msvcrt
     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
     msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
@@ -32,7 +26,7 @@  for filename in sys.argv[1:]:
         sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
         sys.exit(1)
 
-    m = md5()
+    m = hashlib.md5()
     try:
         for data in iter(lambda: fp.read(8192), b''):
             m.update(data)