From a8d57bb031642a6ea674b56ddf9cc0e5d4685c19 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Thu, 22 Jan 2009 23:53:01 +0000 Subject: [PATCH] Avoid DeprecationWarning with Python 2.6+ --- doc/THANKS | 3 +++ lib/core/convert.py | 8 ++++++-- lib/request/connect.py | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/THANKS b/doc/THANKS index 972b04f44..986377f4c 100644 --- a/doc/THANKS +++ b/doc/THANKS @@ -116,6 +116,9 @@ Sven Schluter for providing with a patch for waiting a number of seconds between each HTTP request +Uemit Seren + for reporting a minor adjustment when running with python 2.6 + Sumit Siddharth for providing me with ideas on the implementation on a couple of features diff --git a/lib/core/convert.py b/lib/core/convert.py index ca5a7de7b..d2bc50bae 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -23,9 +23,13 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ +try: + import md5 + import sha +except DeprecationWarning, _: + from hashlib import md5 + from hashlib import sha -import md5 -import sha import struct import urllib diff --git a/lib/request/connect.py b/lib/request/connect.py index bcd131c25..49f37eb77 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -25,7 +25,6 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import httplib -import md5 import re import socket import time