Patch util.py for python2.4

Matt Mackall mpm at selenic.com
Tue Aug 17 14:11:53 CDT 2010


On Fri, 2010-08-06 at 19:44 -0500, Sol Jerome wrote:
> On Fri, Aug 6, 2010 at 17:43, Mads Kiilerich <mads at kiilerich.com> wrote:
> >
> > Can you please clarify what problem this patch solves?
> >
> 
> The problem this solves is available at
> http://mercurial.selenic.com/bts/issue2278. The patch I provided
> previously appears to be the cleanest/easiest way to solve the issue.
> If you try to work with the backported hashlib, you start getting
> tracebacks all over the place.

I've queued a simpler fix:

# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1282072222 18000
# Node ID c54c3d45ae2b35223739156c2349566db8d0653b
# Parent  c714abf8c0733bb280c352c09215fa359bfabc9c
util: try importing sha1 from sha first (issue2278)

This will avoid things breaking if someone installs the hashlib egg with py2.4.

diff -r c714abf8c073 -r c54c3d45ae2b mercurial/util.py
--- a/mercurial/util.py	Wed Aug 11 20:28:39 2010 +0800
+++ b/mercurial/util.py	Tue Aug 17 14:10:22 2010 -0500
@@ -29,9 +29,9 @@
     # available) and overwrite itself with it on the first call.
     # Subsequent calls will go directly to the imported function.
     try:
+        from sha import sha as _sha1
+    except ImportError:
         from hashlib import sha1 as _sha1
-    except ImportError:
-        from sha import sha as _sha1
     global _fastsha1, sha1
     _fastsha1 = sha1 = _sha1
     return _sha1(s)

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list