#7458 closed defect (fixed)
[patch] The md5 module is deprecated in python, use hashlib instead
Reported by: | mad | Owned by: | Remy Blank |
---|---|---|---|
Priority: | normal | Milestone: | 0.11.3 |
Component: | general | Version: | 0.11-stable |
Severity: | minor | Keywords: | patch |
Cc: | mad@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
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 (5)
Change History (21)
by , 16 years ago
Attachment: | trac-0.11-hashlib.patch added |
---|
comment:1 by , 16 years ago
This is not possible without dropping support for Python 2.4. Not going to happen for a while.
comment:2 by , 16 years ago
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()
comment:3 by , 16 years ago
the patch was wrong in some way, with it applied the login href was missing. strange…
comment:4 by , 16 years ago
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.
by , 16 years ago
Attachment: | trac-0.11-hashlib.2.patch added |
---|
Updated version with sha module replacement and fixed login href
by , 16 years ago
Attachment: | 7458-hashlib-r7376.patch added |
---|
Patch against 0.11-stable that implements the solution suggested by eblot
comment:5 by , 16 years ago
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.
comment:6 by , 16 years ago
Cc: | added |
---|
comment:7 by , 16 years ago
Milestone: | → 0.11.1 |
---|---|
Owner: | set to |
Severity: | normal → minor |
attachment:7458-hashlib-r7376.patch looks great, I'll apply it later today.
comment:8 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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 import
able directly from trac.util
though.
Patch applied in r7384.
comment:9 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I've upgraded my Trac environment to 0.11.2 today and everything is running on Python 2.6 here. I got some errors about the deprecation of module sha which i fixed myself on 0.11 as shown in my last patch… I've updated my patch to 0.11.2 and fixed the comments to blame python version 2.6 and not 2.5 which was wrong.
by , 16 years ago
Attachment: | trac-0.11.2-hashlib.patch added |
---|
Updated patch to get rid of deprecation warnings
comment:10 by , 16 years ago
Cc: | removed |
---|---|
Milestone: | 0.11.1 → 0.11.3 |
Owner: | changed from | to
Status: | reopened → new |
That's true, we should have done both at the same time. The md5
and sha
modules are actually deprecated since 2.5 (see the docs), but they only started generating a warning in 2.6.
by , 16 years ago
Attachment: | trac-0.11-hashlib-2.patch added |
---|
Fixed patch to metion the right python version
comment:11 by , 16 years ago
Please scratch my last patch and please take a look here:
http://docs.python.org/whatsnew/2.6.html
The actual deprecation is listed in the docs of Python 2.6 The hashlib module itself was just added in version 2.5
comment:12 by , 16 years ago
It's really only a detail, but look at the top of:
Anyway, I'm waiting for 0.11.2.1 to be out, then I'll fix the deprecation. Thanks for reporting the success with 2.6.
comment:13 by , 16 years ago
the two sides of the same medal ;)
to be clear, we faced no problems with trac-0.11 on python 2.6 even the actual trac-0.11 branch of bitten works like a charm here.
thanks for providing such a good environment for our development.
follow-up: 16 comment:15 by , 16 years ago
I see these warnings in Trac 0.11.4 trac-admin with Python 2.6. Should that be a separate ticket?
comment:16 by , 16 years ago
Replying to jevans:
I see these warnings in Trac 0.11.4 trac-admin with Python 2.6. Should that be a separate ticket?
Sorry, they appear to come from AccountManager.
patch to replace the usage of the depecated md5 module with hashlib