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

Unified Diff: recipes.py

Issue 2798393002: Work around unicode issues by re-encoding properties as utf-8 (Closed)
Patch Set: comment Created 3 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 | « recipe_modules/json/api.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipes.py
diff --git a/recipes.py b/recipes.py
index 0626c1f356f2ef24611b9eab21b59192bc8d006c..56b28028432b4108b14b38e23f932d2a64c12b24 100755
--- a/recipes.py
+++ b/recipes.py
@@ -18,11 +18,18 @@ import subprocess
import sys
import tempfile
+# This is necessary to ensure that str literals are by-default assumed to hold
+# utf-8. It also makes the implicit str(unicode(...)) act like
+# unicode(...).encode('utf-8'), rather than unicode(...).encode('ascii') .
+reload(sys)
+sys.setdefaultencoding('UTF8')
+
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, ROOT_DIR)
from recipe_engine import env
from recipe_engine import arguments_pb2
+from recipe_engine import util as recipe_util
from google.protobuf import json_format as jsonpb
@@ -232,6 +239,8 @@ def run(package_deps, args, op_args):
properties['recipe'] = args.recipe
+ properties = recipe_util.strip_unicode(properties)
+
os.environ['PYTHONUNBUFFERED'] = '1'
os.environ['PYTHONIOENCODING'] = 'UTF-8'
« no previous file with comments | « recipe_modules/json/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698