GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 58ecc57c authored by Chun-wei Fan's avatar Chun-wei Fan

win32/ Fix replacing items in files with UTF-8 content

Some files that this script will process might have UTF-8 items in
there, which can cause problems on Python 3.x as it is more strict and
careful on unicode issues.  Fix this by:

-Doing what we did before on Python 2.x
-Open the file with encoding='utf-8' on Python 3.x
parent 0d81bb4e
......@@ -21,9 +21,15 @@ valid_actions = ['remove-prefix',
def open_file(filename, mode):
if sys.version_info[0] < 3:
return open(filename, mode=mode)
return open(filename, mode=mode, encoding='utf-8')
def replace_multi(src, dest, replace_items):
with open(src, 'r') as s:
with open(dest, 'w') as d:
with open_file(src, 'r') as s:
with open_file(dest, 'w') as d:
for line in s:
replace_dict = dict((re.escape(key), value) \
for key, value in replace_items.items())
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment