Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 97838 Details for
Bug 148514
Portage should use hashlib if available
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
New patch to portage_checksum.py
portage-hashlib.patch (text/plain), 2.13 KB, created by
Aidan Thornton
on 2006-09-23 06:00:50 UTC
(
hide
)
Description:
New patch to portage_checksum.py
Filename:
MIME Type:
Creator:
Aidan Thornton
Created:
2006-09-23 06:00:50 UTC
Size:
2.13 KB
patch
obsolete
>Index: portage_checksum.py >=================================================================== >--- portage_checksum.py (revision 74) >+++ portage_checksum.py (revision 87) >@@ -22,6 +22,12 @@ > #dict of all available hash functions > hashfunc_map = {} > >+# This is only available in Python 2.5 >+try: >+ import hashlib >+except ImportError: >+ hashlib = None >+ > # We _try_ to load this module. If it fails we do the slightly slower fallback. > try: > import fchksum >@@ -32,11 +38,11 @@ > except ImportError: > import md5 > def md5hash(filename): >- return pyhash(filename, md5) >+ return pyhash(filename, md5.new) > hashfunc_map["MD5"] = md5hash > > def sha1hash(filename): >- return pyhash(filename, sha) >+ return pyhash(filename, sha.new) > hashfunc_map["SHA1"] = sha1hash > > # Keep pycrypto optional for now, there are no internal fallbacks for these >@@ -44,19 +50,33 @@ > import Crypto.Hash.SHA256 > > def sha256hash(filename): >- return pyhash(filename, Crypto.Hash.SHA256) >+ return pyhash(filename, Crypto.Hash.SHA256.new) > hashfunc_map["SHA256"] = sha256hash > except ImportError: >- pass >+ if hashlib != None: >+ def sha256hash(filename): >+ return pyhash(filename, hashlib.sha256) >+ hashfunc_map["SHA256"] = sha256hash > > try: > import Crypto.Hash.RIPEMD > > def rmd160hash(filename): >- return pyhash(filename, Crypto.Hash.RIPEMD) >+ return pyhash(filename, Crypto.Hash.RIPEMD.new) > hashfunc_map["RMD160"] = rmd160hash > except ImportError: >- pass >+ if hashlib != None: >+ # Even if hashlib is available, it's not guaranteed >+ # to support ripemd160, so check first >+ try: >+ hashlib.new('ripemd160') >+ except ValueError: >+ pass >+ else: >+ def rmd160hash(filename): >+ return pyhash(filename, lambda:hashlib.new('ripemd160')) >+ hashfunc_map["RMD160"] = rmd160hash >+ > > def getsize(filename): > size = os.stat(filename).st_size >@@ -111,12 +131,12 @@ > break > return file_is_ok,reason > >-def pyhash(filename, hashobject): >+def pyhash(filename, hashfactory): > f = open(filename, 'rb') > blocksize = HASHING_BLOCKSIZE > data = f.read(blocksize) > size = 0L >- sum = hashobject.new() >+ sum = hashfactory() > while data: > sum.update(data) > size = size + len(data)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 148514
:
97653
| 97838