Bug 190258 - [GTK] build fails with python 3 if LANG and LC_TYPE are unset
Summary: [GTK] build fails with python 3 if LANG and LC_TYPE are unset
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-10-03 12:52 PDT by Mike Gorse
Modified: 2018-10-05 03:57 PDT (History)
12 users (show)

See Also:


Attachments
Proposed patch. (4.31 KB, patch)
2018-10-03 13:05 PDT, Mike Gorse
annulen: review+
Details | Formatted Diff | Diff
Updated patch. (4.37 KB, patch)
2018-10-04 16:59 PDT, Mike Gorse
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gorse 2018-10-03 12:52:02 PDT
Building the gtk port still fails using Python 3 if LANG or LC_TYPE do not specify UTF-8. I'm seeing tracebacks such as the following:
Traceback (most recent call last):
  File "/home/mgorse/src/WebKit/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py", line 197, in <module>
    registry.parse(registryFile)
  File "/home/mgorse/src/WebKit/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py", line 63, in parse
    for line in file:
  File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 866: ordinal not in range(128)
Comment 1 Mike Gorse 2018-10-03 13:05:08 PDT
Created attachment 351542 [details]
Proposed patch.

Explicitly specify UTF-8 encoding for Python 3 in some places, rather than defaulting to the encoding specified in the environment.
Comment 2 Mark Lam 2018-10-03 13:22:58 PDT
Comment on attachment 351542 [details]
Proposed patch.

LGTM but let's wait for the EWS bots to be green before committing.
Comment 3 Konstantin Tokarev 2018-10-03 13:53:03 PDT
Comment on attachment 351542 [details]
Proposed patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=351542&action=review

> Source/JavaScriptCore/Scripts/cssmin.py:51
> +        sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='UTF-8')

These lines duplicate code above
Comment 4 Mike Gorse 2018-10-03 18:21:09 PDT
(In reply to Konstantin Tokarev from comment #3)
> Comment on attachment 351542 [details]
> Proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=351542&action=review
> 
> > Source/JavaScriptCore/Scripts/cssmin.py:51
> > +        sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='UTF-8')
> 
> These lines duplicate code above

I think you're referring to this line:
         sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8')
My patch adds similar handling for sys.stdout.
Comment 5 Konstantin Tokarev 2018-10-03 18:59:49 PDT
Comment on attachment 351542 [details]
Proposed patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=351542&action=review

>>> Source/JavaScriptCore/Scripts/cssmin.py:51
>>> +        sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='UTF-8')
>> 
>> These lines duplicate code above
> 
> I think you're referring to this line:
>          sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8')
> My patch adds similar handling for sys.stdout.

Oh, sorry. Still I think it would be better to avoid duplication of 'sys.version_info[0] >= 3' and 'import io' to prevent misreads
Comment 6 Mike Gorse 2018-10-04 16:59:17 PDT
Created attachment 351643 [details]
Updated patch.

Updated cssmin.py to remove duplicated if check and import.
Comment 7 Michael Catanzaro 2018-10-05 02:02:09 PDT
If you keep the previous reviewed by line when you upload it (either by adding it manually or by applying it with 'webkit-patch apply-from-bug') then any committer would be able to commit it without waiting for Konstantin again.
Comment 8 WebKit Commit Bot 2018-10-05 03:56:39 PDT
Comment on attachment 351643 [details]
Updated patch.

Clearing flags on attachment: 351643

Committed r236870: <https://trac.webkit.org/changeset/236870>
Comment 9 WebKit Commit Bot 2018-10-05 03:56:41 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-10-05 03:57:33 PDT
<rdar://problem/45038771>