Bug 135832 - security/py-pycrypto: Deprecation warnings when used with Python 2.6.
Summary: security/py-pycrypto: Deprecation warnings when used with Python 2.6.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-python (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-19 13:10 UTC by Keith Gaughan
Modified: 2009-07-16 14:50 UTC (History)
0 users

See Also:


Attachments
file.diff (1.41 KB, patch)
2009-06-19 13:10 UTC, Keith Gaughan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Gaughan 2009-06-19 13:10:08 UTC
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

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:
How-To-Repeat: Install security/py-pycrypto with Python 2.6, and do the following:

$ python
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2009-06-19 13:10:20 UTC
Responsible Changed
From-To: freebsd-ports-bugs->freebsd-python

freebsd-python@ wants this port PRs (via the GNATS Auto Assign Tool)
Comment 2 Li-Wen Hsu freebsd_committer freebsd_triage 2009-07-13 15:29:09 UTC
State Changed
From-To: open->feedback

I'm not sure that it's a good fix to suppress the warning in the Python 
2.6.  I think it should be there for its own reason.  Maybe marking 
security/py-pycrypto use Python 2.5 work?
Comment 3 Keith Gaughan 2009-07-15 13:59:25 UTC
The patch that I provided is actually a *backport* from the current
development version of PyCrypto (as evidenced by the link I provided to
its git repository), so it's safe to say that the PyCrypto developers
themselves consider it to be safe and good.
 
The patch doesn't actually do any warning suppression. What it does is
first try the non-deprecated method of using hashlib (which works in and
is recommended for Python 2.5 and after), and then, if that fails (i.e.
in pre-2.5 version of Python), it uses the old deprecated (see PEP-0004)
method of importing the md5 and sha modules instead.
 
Because quite a bit of code out there uses PyCrypto, requiring the use
of 2.5 would probably cause more trouble than good.

-- 
Keith Gaughan - kmgaughan@eircom.net - http://talideon.com/ - CF9F6473
With Age comes Wisdom--but sometimes Age travels alone.
Comment 4 Li-Wen Hsu freebsd_committer freebsd_triage 2009-07-15 15:39:09 UTC
State Changed
From-To: feedback->open

Feedback received.
Comment 5 dfilter service freebsd_committer freebsd_triage 2009-07-16 14:47:04 UTC
lwhsu       2009-07-16 13:46:55 UTC

  FreeBSD ports repository

  Modified files:
    security/py-pycrypto Makefile 
  Added files:
    security/py-pycrypto/files python25+.txt 
  Log:
  - Add a patch to make SHA and MD5 use hashlib if possible
  - Transfer maintainership to submitter
  
  PR:             ports/135832
  Submitted by:   Keith Gaughan <kmgaughan AT eircom.net>
  
  Revision  Changes    Path
  1.14      +9 -3      ports/security/py-pycrypto/Makefile
  1.1       +58 -0     ports/security/py-pycrypto/files/python25+.txt (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 6 Li-Wen Hsu freebsd_committer freebsd_triage 2009-07-16 14:47:44 UTC
State Changed
From-To: open->closed

Committed. Thanks!