Patch util.py for python2.4

Mads Kiilerich mads at kiilerich.com
Fri Aug 6 22:43:38 UTC 2010


  Sol Jerome wrote, On 08/06/2010 04:57 PM:
> The following patch allows the use of python2.4 with a standalone
> hashlib rather than assuming that python2.5 is in use when hashlib is
> imported successfully.

Can you please clarify what problem this patch solves?

Mercurial currently assumes that if hashlib.sha1 can be imported then it 
is fine. You are using python2.4 and has a hashlib where sha1 doesn't work?

Bonus points for adding a proper descriptive description to the patch as 
described on http://mercurial.selenic.com/wiki/ContributingChanges ;-)

/Mads


> diff -r b8b4a2417fbd mercurial/util.py
> --- a/mercurial/util.py Wed Aug 04 13:21:11 2010 -0500
> +++ b/mercurial/util.py Fri Aug 06 09:52:17 2010 -0500
> @@ -28,9 +28,10 @@
>       # This function will import sha1 from hashlib or sha (whichever is
>       # available) and overwrite itself with it on the first call.
>       # Subsequent calls will go directly to the imported function.
> -    try:
> +    import sys
> +    if sys.version_info>= (2, 5):
>           from hashlib import sha1 as _sha1
> -    except ImportError:
> +    else:
>           from sha import sha as _sha1
>       global _fastsha1, sha1
>       _fastsha1 = sha1 = _sha1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel




More information about the Mercurial-devel mailing list