From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Jun 19 12:10:08 2009 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A127D1065674 for ; Fri, 19 Jun 2009 12:10:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7B6578FC18 for ; Fri, 19 Jun 2009 12:10:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n5JCA835031404 for ; Fri, 19 Jun 2009 12:10:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n5JCA8Sf031403; Fri, 19 Jun 2009 12:10:08 GMT (envelope-from gnats) Resent-Date: Fri, 19 Jun 2009 12:10:08 GMT Resent-Message-Id: <200906191210.n5JCA8Sf031403@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith Gaughan Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8845110657EA for ; Fri, 19 Jun 2009 12:07:10 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 6B44E8FC16 for ; Fri, 19 Jun 2009 12:07:10 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n5JC79xu093364 for ; Fri, 19 Jun 2009 12:07:09 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n5JC79aM093363; Fri, 19 Jun 2009 12:07:09 GMT (envelope-from nobody) Message-Id: <200906191207.n5JC79aM093363@www.freebsd.org> Date: Fri, 19 Jun 2009 12:07:09 GMT From: Keith Gaughan To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/135832: security/py-pycrypto: Deprecation warnings when used with Python 2.6. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2009 12:10:09 -0000 >Number: 135832 >Category: ports >Synopsis: security/py-pycrypto: Deprecation warnings when used with Python 2.6. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jun 19 12:10:08 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Keith Gaughan >Release: FreeBSD 7.1 >Organization: >Environment: FreeBSD lir 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 14:37:25 UTC 2009 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: While the md5 and sha modules have been regarded as deprecated for quite some time now, it's only in Python 2.6 that importing these modules rather than using hashlib has started giving deprecation warnings. Quite a number of python ports use pycrypto, so anybody who's now using Python 2.6 will see lots of deprecations warnings concerning these two modules. The affected files in pycrypto are lib/Crypto/Hash/SHA.py and lib/Crypto/Hash/MD5.py >How-To-Repeat: Install security/py-pycrypto with Python 2.6, and do the following: $ python >Fix: A patch to modify these two modules to use hashlib if possible is attached. it patches them to be practically identical (save some differing whitespace and comments) to the same modules in the current development branch of pycrypto at http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.x.git;a=summary The patch may be safely used with Python 2.5 and after. Patch attached with submission follows: --- MD5.py.orig 2009-06-19 12:46:41.000000000 +0100 +++ MD5.py 2009-06-19 12:50:24.000000000 +0100 @@ -3,11 +3,20 @@ __revision__ = "$Id: MD5.py,v 1.4 2002/07/11 14:31:19 akuchling Exp $" -from md5 import * +__all__ = ['new', 'digest_size'] -import md5 -if hasattr(md5, 'digestsize'): - digest_size = digestsize - del digestsize -del md5 +try: + # The md5 module is deprecated in Python 2.6, so use hashlib when possible. + import hashlib + def new(data=""): + return hashlib.md5(data) + digest_size = new().digest_size + +except ImportError: + from md5 import * + import md5 + if hasattr(md5, 'digestsize'): + digest_size = digestsize + del digestsize + del md5 --- SHA.py.orig 2009-06-19 12:46:52.000000000 +0100 +++ SHA.py 2009-06-19 12:49:49.000000000 +0100 @@ -3,9 +3,20 @@ __revision__ = "$Id: SHA.py,v 1.4 2002/07/11 14:31:19 akuchling Exp $" -from sha import * -import sha -if hasattr(sha, 'digestsize'): - digest_size = digestsize - del digestsize -del sha +__all__ = ['new', 'digest_size'] + + +try: + # The md5 module is deprecated in Python 2.6, so use hashlib when possible. + import hashlib + def new(data=""): + return hashlib.sha1(data) + digest_size = new().digest_size + +except ImportError: + from sha import * + import sha + if hasattr(sha, 'digestsize'): + digest_size = digestsize + del digestsize + del sha >Release-Note: >Audit-Trail: >Unformatted: >>> import Crypto.Hash.SHA This will give the warning "/usr/local/lib/python2.6/site-packages/Crypto/Hash/SHA.py:6: DeprecationWarning: the sha module is deprecated; use the hashlib module instead"