Fix md5 import error
Paul Hinze <paul.t.hinze@gmail.com> on 2008-12-22 at 19:16: > I did a bit of debugging and asking around in #python and it turns out > that because Maildir.py uses a conditional import of md5 from either > hashlib or the md5 module, the md5.new() call is not always correct. > The attached patch should fix this problem. Thanks to Daniel Rall for pointing out that the attachment got stripped off my last message. Patch follows. Paul ---- From e01fdfbf62c61c31b514e826e6cc00fb98d88808 Mon Sep 17 00:00:00 2001 From: Paul Hinze <paul.t.hinze@gmail.com> Date: Mon, 22 Dec 2008 18:42:44 -0600 Subject: [PATCH] Fixing md5 import when hashlib is available Thanks to habnabit and Rhamphoryncus in #python for help debugging
This commit is contained in:
		| @@ -25,7 +25,7 @@ from threading import Lock | ||||
| try: | ||||
|     from hashlib import md5 | ||||
| except ImportError: | ||||
|     import md5 | ||||
|     from md5 import md5 | ||||
|  | ||||
| uidmatchre = re.compile(',U=(\d+)') | ||||
| flagmatchre = re.compile(':.*2,([A-Z]+)') | ||||
| @@ -84,7 +84,7 @@ class MaildirFolder(BaseFolder): | ||||
|         files = [] | ||||
|         nouidcounter = -1               # Messages without UIDs get | ||||
|                                         # negative UID numbers. | ||||
|         foldermd5 = md5.new(self.getvisiblename()).hexdigest() | ||||
|         foldermd5 = md5(self.getvisiblename()).hexdigest() | ||||
|         folderstr = ',FMD5=' + foldermd5 | ||||
|         for dirannex in ['new', 'cur']: | ||||
|             fulldirname = os.path.join(self.getfullname(), dirannex) | ||||
| @@ -177,7 +177,7 @@ class MaildirFolder(BaseFolder): | ||||
|                            os.getpid(), | ||||
|                            socket.gethostname(), | ||||
|                            uid, | ||||
|                            md5.new(self.getvisiblename()).hexdigest()) | ||||
|                            md5(self.getvisiblename()).hexdigest()) | ||||
|             if os.path.exists(os.path.join(tmpdir, messagename)): | ||||
|                 time.sleep(2) | ||||
|                 attempts += 1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Paul Hinze
					Paul Hinze