Commit bc014458 authored by antonm@chromium.org's avatar antonm@chromium.org

Use hashlib module instead of md5 if it is present.

md5 module is deprecated since Python 2.5 and we'd better off using hashlib instead.

Review URL: http://codereview.chromium.org/3026030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5143 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 10b847eb
...@@ -27,8 +27,14 @@ ...@@ -27,8 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
try:
import hashlib
md5er = hashlib.md5
except ImportError, e:
import md5
md5er = md5.new
import md5
import optparse import optparse
import os import os
from os.path import abspath, join, dirname, basename, exists from os.path import abspath, join, dirname, basename, exists
...@@ -126,7 +132,7 @@ class FileContentsCache(object): ...@@ -126,7 +132,7 @@ class FileContentsCache(object):
for file in files: for file in files:
try: try:
handle = open(file, "r") handle = open(file, "r")
file_sum = md5.new(handle.read()).digest() file_sum = md5er(handle.read()).digest()
if not file in self.sums or self.sums[file] != file_sum: if not file in self.sums or self.sums[file] != file_sum:
changed_or_new.append(file) changed_or_new.append(file)
self.sums[file] = file_sum self.sums[file] = file_sum
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment