Opened 4 years ago
Last modified 3 weeks ago
#5747 reopened defect
[Patch] Using of deprecated sha module in graphviz.py
| Reported by: | shurup | Owned by: | rjollos |
|---|---|---|---|
| Priority: | normal | Component: | GraphvizPlugin |
| Severity: | normal | Keywords: | patch |
| Cc: | py.hieroglyph@…, shogsbro, cboos, hasienda | Trac Release: | 1.0 |
Description
We've updated Python from 2.5 to 2.6 on our server with Trac installation. After that, we're getting Python warnings every single time graphviz plugin is used. The warning is as follows:
/usr/lib64/python2.6/site-packages/graphviz-0.7.4-py2.6.egg/graphviz/graphviz.py:23: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
The problem exists in 0.7.6dev version as well. I guess, this should be fixed.
Attachments (2)
Change History (23)
comment:1 Changed 4 years ago by bobbysmith007
comment:3 Changed 3 years ago by AdrianFritz
- Summary changed from Using of deprecated sha module in graphviz.py to [Patch] Using of deprecated sha module in graphviz.py
comment:4 Changed 3 years ago by bobbysmith007
- Keywords patch added
comment:5 Changed 3 years ago by paresh.solanki@…
This works for me too.
Can this be applied to the next version?
comment:6 Changed 3 years ago by shogsbro
It would be nice to get some of these trivial updates applied to the SVN tree.
comment:7 Changed 3 years ago by shogsbro
- Cc shogsbro added
comment:8 Changed 3 years ago by rjollos
It looks like cboos is maintaining this plugin, so you might need to talk with him.
Changed 3 years ago by itamarost
Patch to fix sha module deprecation in Python 2.6 while maintaining compatability
comment:9 Changed 3 years ago by itamarost
- Priority changed from low to normal
I have attached a GraphViz-fix-py26-sha.patch that fixes the deprecation warning in Python 2.6 without breaking compatibility (since hashlib does not exist in pre-2.5).
Basically, I simply reused the fix that was made in Trac core via the trac.util.compat module.
Hope this gets in soon...
comment:10 Changed 20 months ago by olaf.meeuwissen@…
+1 and #8938 seems to be a duplicate of this ticket
comment:11 Changed 20 months ago by rjollos
- Cc cboos added
I'd like to finally get this fixed too and get rid of the warnings in my log file. I'll go ahead and take care of committing this to the repos if cboos has no objections (or if we don't hear anything back in the standard 2 week time period).
comment:12 Changed 17 months ago by kuaima@…
+1.
It's annoying in the log to see the warning.
comment:13 Changed 17 months ago by kuaima@…
Another suggestion, only replace module sha with hashlib.sha1 works for me.
My environment pyton 2.6.7.
comment:14 Changed 17 months ago by rjollos
- Owner changed from pkropf to rjollos
I'd like to go ahead and fix this if the maintainer has no objections.
comment:15 follow-up: ↓ 19 Changed 17 months ago by rjollos
- Status changed from new to assigned
I've issued sufficient warning in comment:11 and comment:14 ... time to apply this ;)
The patch by itamarost is great, except sha1 doesn't exist doesn't exist in trac.util.compat in 0.11, and we are trying to maintain compatibility on plugins back to 0.11.
hasienda, this is a perfect candidate for the trachacks-compat class, or whatever we end up calling it. From trac-0.11-stable:
try: from hashlib import md5, sha1 except ImportError: from md5 import md5 from sha import new as sha1
comment:16 Changed 17 months ago by rjollos
(In [11263]) Refs #5747: (0.11 branch) Replaced import of deprecated sha with import of sha1 from the hashlib library. Falls back to still use sha if hashlib (since Python 2.5) is not available.
Thank you to bobbysmith007 and itamarost for useful suggestions on a solution.
This has been tested with trac0.11 and trac0.13dev [t 10966] with Python 2.6.
comment:17 Changed 17 months ago by rjollos
- Cc hasienda added
I'll leave this ticket open for a while to see if there are any issues.
hasienda, I had meant to cc you on comment:15, which you might find interesting.
comment:18 Changed 16 months ago by rjollos
- Resolution set to fixed
- Status changed from assigned to closed
comment:19 in reply to: ↑ 15 Changed 14 months ago by rjollos
Replying to rjollos:
hasienda, this is a perfect candidate for the trachacks-compat class, or whatever we end up calling it. From trac-0.11-stable:
There is a similar issue for the WorkLogPlugin in #9990.
comment:20 Changed 4 months ago by rjollos
It looks like the fix in [11263] will need to be merged over to the 1.0 branch, depending on what you decide to do with trunk going forward.
comment:21 Changed 3 weeks ago by andrex
- Resolution fixed deleted
- Status changed from closed to reopened
- Trac Release changed from 0.11 to 1.0
Reopening for Trac 1.0, since the problem hasn't been fixed yet in the 1.0 branch.


graphviz/graphviz.py
shasha.new(encoded_cmd + encoded_content).hexdigest()I made the change earlier today, and this seems to work.