Edgewall Software

Ticket #7458 (closed defect: fixed)

Opened 5 weeks ago

Last modified 5 weeks ago

[patch] The md5 module is deprecated in python, use hashlib instead

Reported by: mad Owned by: remy.blank@…
Priority: normal Milestone: 0.11.1
Component: general Version: 0.11-stable
Severity: minor Keywords: patch
Cc: mad@…, remy.blank@…

Description

Hello,

the md5 module is deprecated, hashlib should be used instead. here is a simple patch against 0.11 to kill the warnings.

Attachments

trac-0.11-hashlib.patch (5.2 kB) - added by mad 5 weeks ago.
patch to replace the usage of the depecated md5 module with hashlib
trac-0.11-hashlib.2.patch (5.2 kB) - added by mad 5 weeks ago.
Updated version with sha module replacement and fixed login href
7458-hashlib-r7376.patch (4.4 kB) - added by Remy Blank <remy.blank@…> 5 weeks ago.
Patch against 0.11-stable that implements the solution suggested by eblot

Change History

Changed 5 weeks ago by mad

patch to replace the usage of the depecated md5 module with hashlib

Changed 5 weeks ago by nkantrowitz

This is not possible without dropping support for Python 2.4. Not going to happen for a while.

Changed 5 weeks ago by eblot

It could be implemented with compatibility for previous release of Python:

try:
    import hashlib
    md = hashlib.md5()
except ImportError:
    # for Python << 2.5
    import md5
    md = md5.new()

Changed 5 weeks ago by mad

the patch was wrong in some way, with it applied the login href was missing. strange...

Changed 5 weeks ago by Remy Blank <remy.blank@…>

Yes, the search and replace was a bit too hasty. I would guess that the substitution at line 38 of trac/web/auth.py is wrong.

Changed 5 weeks ago by mad

Updated version with sha module replacement and fixed login href

Changed 5 weeks ago by Remy Blank <remy.blank@…>

Patch against 0.11-stable that implements the solution suggested by eblot

Changed 5 weeks ago by Remy Blank <remy.blank@…>

  • keywords patch added

The patch above imports either hashlib.md5 or md5.md5 into trac.util, and all users of md5 import it from there.

The same import hack is applied separately to contrib/htdigest.py so that it doesn't have to depend on trac.util.

The patch proposed by mad also fixed trac/wiki/default-pages/TracStandalone, but I understand these pages are imported from the live Trac instance on t.e.o during the release process. So I'll patch TracStandalone with the same hack.

Changed 5 weeks ago by Remy Blank <remy.blank@…>

  • cc remy.blank@… added

Changed 5 weeks ago by cboos

  • owner set to remy.blank@…
  • severity changed from normal to minor
  • milestone set to 0.11.1

attachment:7458-hashlib-r7376.patch looks great, I'll apply it later today.

Changed 5 weeks ago by cboos

  • status changed from new to closed
  • resolution set to fixed

Applied with minor tweaking in (moved the hashlib import logic in trac.util.compat, where we usually place this sort of things). It's still importable directly from trac.util though.

Patch applied in r7384.

Add/Change #7458 ([patch] The md5 module is deprecated in python, use hashlib instead)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.