Edgewall Software

Ticket #7458: trac-0.11.2-hashlib.patch

File trac-0.11.2-hashlib.patch, 2.0 KB (added by mad, 4 years ago)

Updated patch to get rid of deprecation warnings

  • contrib/htdigest.py

    diff -Nurp Trac-0.11.2.orig/contrib/htdigest.py Trac-0.11.2/contrib/htdigest.py
    old new import sys 
    2121from optparse import OptionParser 
    2222from getpass import getpass 
    2323 
    24 # The md5 module is deprecated in Python 2.5 
     24# The md5 module is deprecated in Python 2.6 
    2525try: 
    2626    from hashlib import md5 
    2727except ImportError: 
  • trac/util/compat.py

    diff -Nurp Trac-0.11.2.orig/trac/util/compat.py Trac-0.11.2/trac/util/compat.py
    old new except ImportError: 
    141141        return newfunc 
    142142 
    143143 
    144 # The md5 module is deprecated in Python 2.5 
     144# The md5 module is deprecated in Python 2.6 
    145145try: 
    146146    from hashlib import md5 
    147147except ImportError: 
    148148    from md5 import md5 
     149 
     150# The sha module is deprecated in Python 2.6 
     151try: 
     152    from hashlib import sha1 as sha 
     153except ImportError: 
     154    from sha import sha 
  • trac/util/__init__.py

    diff -Nurp Trac-0.11.2.orig/trac/util/__init__.py Trac-0.11.2/trac/util/__init__.py
    old new from itertools import izip 
    2828 
    2929# Imports for backward compatibility 
    3030from trac.core import TracError 
    31 from trac.util.compat import reversed, sorted, tee, md5 
     31from trac.util.compat import reversed, sorted, tee, md5, sha 
    3232from trac.util.html import escape, unescape, Markup, Deuglifier 
    3333from trac.util.text import CRLF, to_utf8, to_unicode, shorten_line, \ 
    3434                           wrap, pretty_size 
    def get_pkginfo(dist): 
    254254# -- crypto utils 
    255255 
    256256def hex_entropy(bytes=32): 
    257     import sha 
    258257    import random 
    259     return sha.new(str(random.random())).hexdigest()[:bytes] 
     258    return sha(str(random.random())).hexdigest()[:bytes] 
    260259 
    261260 
    262261# Original license for md5crypt: