[GTK] build fails with python 3 if LANG and LC_TYPE are unset
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2018 10:56:31 +0000 (10:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2018 10:56:31 +0000 (10:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190258

Patch by Mike Gorse <mgorse@alum.wpi.edu> on 2018-10-05
Reviewed by Konstantin Tokarev.

* Scripts/cssmin.py: Set stdout to UTF-8 on python 3.
* Scripts/generateIntlCanonicalizeLanguage.py: Open files with
  encoding=UTF-8 on Python 3.
* yarr/generateYarrCanonicalizeUnicode: Ditto.
* yarr/generateYarrUnicodePropertyTables.py: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236870 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Scripts/cssmin.py
Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py
Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode
Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py

index 059011e..b7e0958 100644 (file)
@@ -1,3 +1,16 @@
+2018-10-05  Mike Gorse  <mgorse@alum.wpi.edu>
+
+        [GTK] build fails with python 3 if LANG and LC_TYPE are unset
+        https://bugs.webkit.org/show_bug.cgi?id=190258
+
+        Reviewed by Konstantin Tokarev.
+
+        * Scripts/cssmin.py: Set stdout to UTF-8 on python 3.
+        * Scripts/generateIntlCanonicalizeLanguage.py: Open files with
+          encoding=UTF-8 on Python 3.
+        * yarr/generateYarrCanonicalizeUnicode: Ditto.
+        * yarr/generateYarrUnicodePropertyTables.py: Ditto.
+
 2018-10-04  Mark Lam  <mark.lam@apple.com>
 
         Move start/EndOfFixedExecutableMemoryPool pointers into the FixedVMPoolExecutableAllocator object.
index c34cd08..96213ca 100644 (file)
@@ -43,7 +43,10 @@ def cssminify(css):
 
 if __name__ == "__main__":
     import sys
-    if sys.version_info[0] == 3 and sys.stdin.encoding != 'UTF-8':
+    if sys.version_info[0] >= 3:
         import io
-        sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8')
+        if sys.stdin.encoding != 'UTF-8':
+            sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8')
+        if sys.stdout.encoding != 'UTF-8':
+            sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='UTF-8')
     sys.stdout.write(cssminify(sys.stdin.read()))
index 949b0b6..71df184 100644 (file)
@@ -44,7 +44,10 @@ footer = """
 
 def openOrExit(path, mode):
     try:
-        return open(path, mode)
+        if sys.version_info.major >= 3:
+            return open(path, mode, encoding="UTF-8")
+        else:
+            return open(path, mode)
     except IOError as e:
         print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror))
         exit(1)
index b897779..95549c7 100644 (file)
@@ -77,7 +77,10 @@ def openOrExit(path, mode):
         dirname = os.path.dirname(path)
         if not os.path.isdir(dirname):
             os.makedirs(dirname)
-        return open(path, mode)
+        if sys.version_info.major >= 3:
+            return open(path, mode, encoding="UTF-8")
+        else:
+            return open(path, mode)
     except IOError as e:
         print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror))
         exit(1)
index ceb5c8f..90f6732 100644 (file)
@@ -90,7 +90,10 @@ aliases = None
 
 def openOrExit(path, mode):
     try:
-        return open(path, mode)
+        if sys.version_info.major >= 3:
+            return open(path, mode, encoding="UTF-8")
+        else:
+            return open(path, mode)
     except IOError as e:
         print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror))
         exit(1)