Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: upload.py

Issue 99235: Silence off the DeprecationWarning in upload.py when running python >=2.5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: upload.py
===================================================================
--- upload.py (revision 14982)
+++ upload.py (working copy)
@@ -34,7 +34,6 @@
import cookielib
import getpass
import logging
-import md5
import mimetypes
import optparse
import os
@@ -46,6 +45,14 @@
import urllib2
import urlparse
+# Work-around for md5 module deprecation warning in python 2.5+:
+try:
+ # Try to load hashlib (python 2.5+)
+ from hashlib import md5
+except ImportError:
+ # If hashlib cannot be imported, load md5.new instead.
+ from md5 import new as md5
+
try:
import readline
except ImportError:
@@ -675,7 +682,7 @@
(type, filename))
file_too_large = True
content = ""
- checksum = md5.new(content).hexdigest()
+ checksum = md5(content).hexdigest()
if options.verbose > 0 and not file_too_large:
print "Uploading %s file for %s" % (type, filename)
url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
@@ -1313,7 +1320,7 @@
base_hashes = ""
for file, info in files.iteritems():
if not info[0] is None:
- checksum = md5.new(info[0]).hexdigest()
+ checksum = md5(info[0]).hexdigest()
if base_hashes:
base_hashes += "|"
base_hashes += checksum + ":" + file
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698