Complete.Org: Mailing Lists: Archives: offlineimap: December 2008:
Re: [PATCH] Fix md5 import error
Home

Re: [PATCH] Fix md5 import error

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Paul Hinze <paul.t.hinze@xxxxxxxxx>
Subject: Re: [PATCH] Fix md5 import error
From: Loui Chang <louipc.ist@xxxxxxxxx>
Date: Wed, 31 Dec 2008 11:26:59 -0500

> Paul Hinze <paul.t.hinze@xxxxxxxxx> 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.

Oh darn. Good thing you caught that.
Things seem to work fine with hashlib and this patch now.
I actually tested it this time.

Cheers.

> ----
> 
> From e01fdfbf62c61c31b514e826e6cc00fb98d88808 Mon Sep 17 00:00:00 2001
> From: Paul Hinze <paul.t.hinze@xxxxxxxxx>
> 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
> ---
>  offlineimap/folder/Maildir.py |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
> index d1d5077..937500f 100644
> --- a/offlineimap/folder/Maildir.py
> +++ b/offlineimap/folder/Maildir.py
> @@ -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
> -- 
> 1.5.6.3
> 
> 
> 



[Prev in Thread] Current Thread [Next in Thread]