Patch util.py for python2.4

Matt Mackall mpm at selenic.com
Tue Aug 17 17:37:34 CDT 2010


On Tue, 2010-08-17 at 16:19 -0500, Sol Jerome wrote:
> On Tue, Aug 17, 2010 at 14:11, Matt Mackall <mpm at selenic.com> wrote:
> >
> > 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.
> >
> 
> This will also work. However, with that applied, we are no longer
> defaulting to hashlib on some versions of python where it works:
> 
> $ python -c "import sys; print(sys.version_info); from sha import sha
> as _sha1; import hashlib"
> (2, 6, 5, 'final', 0)
> -c:1: DeprecationWarning: the sha module is deprecated; use the
> hashlib module instead
> 
> 
> So, even with python 2.6.5 the sha import still works (which is fine
> if you choose not to use hashlib on these python installs).

Bah, you're right. I hate those DeprecationWarnings.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list