Skip to content

build: python3 support for configure - #30047

Closed
rvagg wants to merge 1 commit into
nodejs:masterfrom
rvagg:rvagg/python3-icu-utf8
Closed

build: python3 support for configure#30047
rvagg wants to merge 1 commit into
nodejs:masterfrom
rvagg:rvagg/python3-icu-utf8

Conversation

@rvagg

Copy link
Copy Markdown
Member

Discovered while messing with some infra switching things around to python3. On Linux, if you call configure directly with a python3 (not letting it find python for you) and have LC_ALL=C set, as we do in some of our infra, apparently open() defaults to ascii. This is a problem for icu version detection because there's a © at the top of deps/icu-small/source/common/unicode/uvernum.h which it reads to find major version number.

$ LC_ALL=C python3 ./configure.py
Traceback (most recent call last):
File "./configure.py", line 1660, in <module>
configure_intl(output)
File "./configure.py", line 1498, in configure_intl
for line in open(uvernum_h).readlines():
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128)

This change fixes it and makes it work for Python 2 & 3. Although I don't really know what I'm doing with the conversion back to ascii for later compatibility so someone who knows better should check.

@rvagg
rvagg requested review from cclauss and srl295October 21, 2019 11:38
@nodejs-github-botnodejs-github-bot added the build Issues and PRs related to build files or the CI. label Oct 21, 2019
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@targos

Copy link
Copy Markdown
Member

This is similar to #30023

@rvagg

Copy link
Copy Markdown
MemberAuthor

indeed it is! but in this case the return value needs to mix with non-utf8 strings and python2 borks at that, hence the str(x).

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@cclausscclauss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Minor nit: for line in open(uvernum_h).readlines(): leaves the filehandle open so the preferred approach is:

withopen(uvernum_h) asin_file:
forlineinin_file:

because the with open() as context manager will automate the filehandle close().

@rvagg

Copy link
Copy Markdown
MemberAuthor

ok, have tried that approach, ptal @cclauss

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@cclauss

Copy link
Copy Markdown
Contributor

I have already approved. For those who want to dig in...
https://www.python.org/dev/peps/pep-0538/ and https://www.python.org/dev/peps/pep-0540/

@rvagg
rvaggforce-pushed the rvagg/python3-icu-utf8 branch from 40c91e1 to 88ecfeeCompareOctober 23, 2019 00:23
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

rvagg added a commit that referenced this pull request Oct 23, 2019
PR-URL: #30047
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@rvagg

Copy link
Copy Markdown
MemberAuthor

Landed in 779d7ef

@rvaggrvagg closed this Oct 23, 2019
@rvagg
rvagg deleted the rvagg/python3-icu-utf8 branch October 23, 2019 23:29
targos pushed a commit that referenced this pull request Oct 24, 2019
PR-URL: #30047
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@targostargos mentioned this pull request Nov 5, 2019
targos pushed a commit that referenced this pull request Nov 8, 2019
PR-URL: #30047
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this pull request Nov 10, 2019
PR-URL: #30047
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@targostargos mentioned this pull request Nov 10, 2019
targos pushed a commit that referenced this pull request Nov 11, 2019
PR-URL: #30047
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildIssues and PRs related to build files or the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@rvagg@nodejs-github-bot@targos@cclauss@sam-github@devnexen@richardlau