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

Unified Diff: gclient_utils.py

Issue 10696202: Handle non-UTF-8 encoded files in presubmit checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 5 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: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index b413a88eb8a5d9150126e057c3ed7fd67787fe02..c24be5229cc6a78c5ba8b7f80f2ae9b6e953b473 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -80,7 +80,11 @@ def FileRead(filename, mode='rU'):
with open(filename, mode=mode) as f:
# codecs.open() has different behavior than open() on python 2.6 so use
# open() and decode manually.
- return f.read().decode('utf-8')
+ s = f.read()
+ try:
+ return s.decode('utf-8')
+ except UnicodeDecodeError:
+ return s
def FileWrite(filename, content, mode='w'):
« 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