Modify

Opened 15 years ago

Closed 20 months ago

Last modified 20 months ago

#5747 closed defect (fixed)

[Patch] Uses deprecated sha module in graphviz.py

Reported by: Dmitry Shurupov Owned by: Jun Omae
Priority: normal Component: GraphvizPlugin
Severity: normal Keywords: patch
Cc: py.hieroglyph@…, Sigurd Hogsbro, Christian Boos, Steffen Hoffmann 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)

GraphViz-fix-py26-sha.patch (1.1 KB) - added by Itamar Oren 14 years ago.
Patch to fix sha module deprecation in Python 2.6 while maintaining compatability
GraphViz-fix-py26-sha.2.patch (1.1 KB) - added by Itamar Oren 14 years ago.
same patch, fixed mistake in import

Download all attachments as: .zip

Change History (28)

comment:1 Changed 15 years ago by Russ Tyndall

  • graphviz/graphviz.py

     
    2020import locale
    2121import os
    2222import re
    23 import sha
     23import hashlib
    2424import subprocess
    2525import sys
    2626
     
    310310        encoded_cmd = (processor + unicode(self.processor_options)) \
    311311                .encode(self.encoding)
    312312        encoded_content = content.encode(self.encoding)
    313         sha_key  = sha.new(encoded_cmd + encoded_content).hexdigest()
     313        sha_key  = hashlib.sha1(encoded_cmd + encoded_content).hexdigest()
    314314        img_name = '%s.%s.%s' % (sha_key, processor, out_format)
    315315        # cache: hash.<dot>.<png>
    316316        img_path = os.path.join(self.cache_dir, img_name)

I made the change earlier today, and this seems to work.

comment:2 Changed 15 years ago by anonymous

Cc: py.hieroglyph@… added; anonymous removed

Added cc for fix updates...

comment:3 Changed 15 years ago by Adrian Fritz

Summary: Using of deprecated sha module in graphviz.py[Patch] Using of deprecated sha module in graphviz.py

comment:4 Changed 15 years ago by Russ Tyndall

Keywords: patch added

comment:5 Changed 14 years ago by paresh.solanki@…

This works for me too.

Can this be applied to the next version?

comment:6 Changed 14 years ago by Sigurd Hogsbro

It would be nice to get some of these trivial updates applied to the SVN tree.

comment:7 Changed 14 years ago by Sigurd Hogsbro

Cc: Sigurd Hogsbro added

comment:8 Changed 14 years ago by Ryan J Ollos

It looks like cboos is maintaining this plugin, so you might need to talk with him.

Changed 14 years ago by Itamar Oren

Attachment: GraphViz-fix-py26-sha.patch added

Patch to fix sha module deprecation in Python 2.6 while maintaining compatability

comment:9 Changed 14 years ago by Itamar Oren

Priority: lownormal

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...

Changed 14 years ago by Itamar Oren

same patch, fixed mistake in import

comment:10 Changed 13 years ago by olaf.meeuwissen@…

+1 and #8938 seems to be a duplicate of this ticket

comment:11 Changed 13 years ago by Ryan J Ollos

Cc: Christian Boos 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 13 years ago by kuaima@…

+1. It's annoying in the log to see the warning.

comment:13 Changed 13 years ago by kuaima@…

Another suggestion, only replace module sha with hashlib.sha1 works for me. My environment pyton 2.6.7.

comment:14 Changed 13 years ago by Ryan J Ollos

Owner: changed from Peter Kropf to Ryan J Ollos

I'd like to go ahead and fix this if the maintainer has no objections.

comment:15 Changed 13 years ago by Ryan J Ollos

Status: newassigned

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 13 years ago by Ryan J Ollos

(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 13 years ago by Ryan J Ollos

Cc: Steffen Hoffmann 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 13 years ago by Ryan J Ollos

Resolution: fixed
Status: assignedclosed

comment:19 in reply to:  15 Changed 13 years ago by Ryan J Ollos

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 12 years ago by Ryan J Ollos

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 11 years ago by Andrew Schulman

Resolution: fixed
Status: closedreopened
Trac Release: 0.111.0

Reopening for Trac 1.0, since the problem hasn't been fixed yet in the 1.0 branch.

comment:22 Changed 11 years ago by Ryan J Ollos

If no one objects (or has a better idea), we could merge recent changes on the graphvizplugin/branches/1.0 branch back to graphvizplugin/trunk. Future development would then presumably follow the Trac's practice of making bugfixes on the branch and merging them to trunk. For [11263], we could make the change on the branch and do a record-only merge so that we don't get a conflict when merging 1.0 to the trunk.

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:23 Changed 11 years ago by Ryan J Ollos

Summary: [Patch] Using of deprecated sha module in graphviz.py[Patch] Uses deprecated sha module in graphviz.py

comment:24 Changed 5 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted
Status: reopenednew

comment:25 Changed 20 months ago by Jun Omae

Resolution: fixed
Status: newclosed

Fixed in [18525].

comment:26 Changed 20 months ago by Jun Omae

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.