diff options
author | Bryan O'Sullivan <bos@lindenlab.com> | 2009-06-22 22:36:36 +0000 |
---|---|---|
committer | Bryan O'Sullivan <bos@lindenlab.com> | 2009-06-22 22:36:36 +0000 |
commit | 5f4c09fa1f4b09126e1a16e78044c64e97828530 (patch) | |
tree | 52caaf0b7bf125ba4b4840bd7705b3d3a10bd878 /indra/lib | |
parent | 8ed056fde9fe5fc9755158013a5cb8be73066e2c (diff) |
Python 2.4 and 2.6 improvements
The sets module is no longer needed with Python 2.4, and causes a
DeprecationWarning with 2.6, so drop it
The md5 module causes a DeprecationWarning with 2.6, so try to import
hashlib (its replacement) instead, else fall back
Reviewed by Poppy.
Diffstat (limited to 'indra/lib')
-rw-r--r-- | indra/lib/python/indra/base/lluuid.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/indra/lib/python/indra/base/lluuid.py b/indra/lib/python/indra/base/lluuid.py index aceea29cd2..1cdd8e915b 100644 --- a/indra/lib/python/indra/base/lluuid.py +++ b/indra/lib/python/indra/base/lluuid.py @@ -26,8 +26,14 @@ THE SOFTWARE. $/LicenseInfo$ """ -import md5, random, socket, string, time, re +import random, socket, string, time, re import uuid +try: + # Python 2.6 + from hashlib import md5 +except ImportError: + # Python 2.5 and earlier + from md5 import new as md5 def _int2binstr(i,l): s='' @@ -196,7 +202,7 @@ class UUID(object): from c++ implementation for portability reasons. Returns self. """ - m = md5.new() + m = md5() m.update(uuid.uuid1().bytes) self._bits = m.digest() return self |