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

Unified Diff: gclient_utils.py

Issue 10697036: Enforce utf-8 codec on all files read and write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 6 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 | tests/gclient_utils_test.py » ('j') | 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 35f8b3bf44ef69ed02c72422c73125e7f671f2c1..9ba6da50c4b7c50926ca13aa937c84d94234f72f 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -4,6 +4,7 @@
"""Generic utils."""
+import codecs
import errno
import logging
import os
@@ -76,21 +77,13 @@ class PrintableObject(object):
def FileRead(filename, mode='rU'):
- content = None
- f = open(filename, mode)
- try:
- content = f.read()
- finally:
- f.close()
- return content
+ with codecs.open(filename, mode=mode, encoding='utf-8') as f:
+ return f.read()
def FileWrite(filename, content, mode='w'):
- f = open(filename, mode)
- try:
+ with codecs.open(filename, mode=mode, encoding='utf-8') as f:
f.write(content)
- finally:
- f.close()
def rmtree(path):
« no previous file with comments | « no previous file | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698