Re: [gDesklets] Using hashlib instead of md5



Hi there.

Joe Sapp wrote:
> I wonder if there's a compile-time (or daemon-start time) way to
> determine the python version and then use the appropriate module and
> methods.  Compile-time could reduce the minor overhead of supporting
> both, but it isn't as flexible if the python version changes after gD is
> installed.
> 
> I support trying this first before dropping md5 support, but I wouldn't
> hesitate to drop it.  Software evolves and most (if not all) modern
> distros I imagine are up to at least Python 2.5.

OK, I hopefully found a clean way to deal with it by using try-except on
the import of the hashlib, like:

        try:
            import hashlib
            ash = hashlib.md5(name + ":").hexdigest()
        except:
            import md5
            ash = md5.new(name + ":").hexdigest()

Haven't tested it on a Python2.4 based system though.
Fix committed in rev #124.


Greetings, Bjoern


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]