Bug 1547730 - Fix precomplete file generation when passing in unicode strings. r=glandium
authorJustin Wood <Callek@gmail.com>
Tue, 28 May 2019 14:28:57 +0000
changeset 535547 12061a0decdbc92d7a478d34955bc8abaf22eb15
parent 535546 7d0b13ac76f222659913076ee2382645d1922354
child 535548 dbadda4e3c1cd957d3fef219e965458140b567ce
push id11522
push userffxbld-merge
push dateMon, 01 Jul 2019 09:00:55 +0000
treeherdermozilla-beta@53ea74d2bd09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1547730
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547730 - Fix precomplete file generation when passing in unicode strings. r=glandium Differential Revision: https://phabricator.services.mozilla.com/D32407
config/createprecomplete.py
--- a/config/createprecomplete.py
+++ b/config/createprecomplete.py
@@ -1,17 +1,20 @@
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
 # Creates the precomplete file containing the remove and rmdir application
 # update instructions which is used to remove files and directories that are no
 # longer present in a complete update. The current working directory is used for
 # the location to enumerate and to create the precomplete file.
 
+from __future__ import unicode_literals
+
 import os
+import io
 
 
 def get_build_entries(root_path):
     """ Iterates through the root_path, creating a list for each file and
         directory. Excludes any file paths ending with channel-prefs.js.
     """
     rel_file_path_set = set()
     rel_dir_path_set = set()
@@ -49,21 +52,21 @@ def generate_precomplete(root_path):
     # If inside a Mac bundle use the root of the bundle for the path.
     if os.path.basename(root_path) == "Resources":
         root_path = os.path.abspath(os.path.join(root_path, '../../'))
         rel_path_precomplete = "Contents/Resources/precomplete"
 
     precomplete_file_path = os.path.join(root_path, rel_path_precomplete)
     # Open the file so it exists before building the list of files and open it
     # in binary mode to prevent OS specific line endings.
-    precomplete_file = open(precomplete_file_path, "wb")
+    precomplete_file = io.open(precomplete_file_path, mode="wt", newline='\n')
     rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
     for rel_file_path in rel_file_path_list:
-        precomplete_file.writelines("remove \""+rel_file_path+"\"\n")
+        precomplete_file.write("remove \""+rel_file_path+"\"\n")
 
     for rel_dir_path in rel_dir_path_list:
-        precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")
+        precomplete_file.write("rmdir \""+rel_dir_path+"\"\n")
 
     precomplete_file.close()
 
 
 if __name__ == "__main__":
     generate_precomplete(os.getcwd())