Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a63e2d

Browse filesBrowse files
cclausstargos
authored andcommitted
build: support py3 for configure.py
PR-URL: #29106 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent b085b94 commit 0a63e2d
Copy full SHA for 0a63e2d

File tree

Expand file treeCollapse file tree

1 file changed

+16
-23
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-23
lines changed
Open diff view settings
Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+16-23Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import shlex
1212
import subprocess
1313
import shutil
14-
import string
1514
from distutils.spawn import find_executable as which
1615

1716
# If not run from node/, cd to node/.
@@ -626,18 +625,14 @@ def print_verbose(x):
626625

627626
def b(value):
628627
"""Returns the string 'true' if value is truthy, 'false' otherwise."""
629-
if value:
630-
return 'true'
631-
else:
632-
return 'false'
628+
return 'true' if value else 'false'
633629

634630
def B(value):
635631
"""Returns 1 if value is truthy, 0 otherwise."""
636-
if value:
637-
return 1
638-
else:
639-
return 0
632+
return 1 if value else 0
640633

634+
def to_utf8(s):
635+
return s if isinstance(s, str) else s.decode("utf-8")
641636

642637
def pkg_config(pkg):
643638
"""Run pkg-config on the specified package
@@ -652,7 +647,7 @@ def pkg_config(pkg):
652647
try:
653648
proc = subprocess.Popen(shlex.split(pkg_config) + args,
654649
stdout=subprocess.PIPE)
655-
val = proc.communicate()[0].strip()
650+
val = to_utf8(proc.communicate()[0]).strip()
656651
except OSError as e:
657652
if e.errno != errno.ENOENT: raise e # Unexpected error.
658653
return (None, None, None, None) # No pkg-config/pkgconf installed.
@@ -668,10 +663,10 @@ def try_check_compiler(cc, lang):
668663
except OSError:
669664
return (False, False, '', '')
670665

671-
proc.stdin.write('__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
672-
'__clang_major__ __clang_minor__ __clang_patchlevel__')
666+
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
667+
b'__clang_major__ __clang_minor__ __clang_patchlevel__')
673668

674-
values = (proc.communicate()[0].split() + ['0'] * 7)[0:7]
669+
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
675670
is_clang = values[0] == '1'
676671
gcc_version = tuple(map(int, values[1:1+3]))
677672
clang_version = tuple(map(int, values[4:4+3])) if is_clang else None
@@ -696,7 +691,7 @@ def get_version_helper(cc, regexp):
696691
consider adjusting the CC environment variable if you installed
697692
it in a non-standard prefix.''')
698693

699-
match = re.search(regexp, proc.communicate()[1])
694+
match = re.search(regexp, to_utf8(proc.communicate()[1]))
700695

701696
if match:
702697
return match.group(2)
@@ -715,7 +710,7 @@ def get_nasm_version(asm):
715710
return '0'
716711

717712
match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)",
718-
proc.communicate()[0])
713+
to_utf8(proc.communicate()[0]))
719714

720715
if match:
721716
return match.group(1)
@@ -746,7 +741,7 @@ def get_gas_version(cc):
746741
consider adjusting the CC environment variable if you installed
747742
it in a non-standard prefix.''')
748743

749-
gas_ret = proc.communicate()[1]
744+
gas_ret = to_utf8(proc.communicate()[1])
750745
match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)", gas_ret)
751746

752747
if match:
@@ -811,10 +806,8 @@ def cc_macros(cc=None):
811806
consider adjusting the CC environment variable if you installed
812807
it in a non-standard prefix.''')
813808

814-
p.stdin.write('\n')
815-
out = p.communicate()[0]
816-
817-
out = str(out).split('\n')
809+
p.stdin.write(b'\n')
810+
out = to_utf8(p.communicate()[0]).split('\n')
818811

819812
k = {}
820813
for line in out:
@@ -1294,7 +1287,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
12941287

12951288
def configure_intl(o):
12961289
def icu_download(path):
1297-
depFile = 'tools/icu/current_ver.dep';
1290+
depFile = 'tools/icu/current_ver.dep'
12981291
with open(depFile) as f:
12991292
icus = json.load(f)
13001293
# download ICU, if needed
@@ -1363,7 +1356,7 @@ def write_config(data, name):
13631356
o['variables']['icu_small'] = b(True)
13641357
locs = set(options.with_icu_locales.split(','))
13651358
locs.add('root') # must have root
1366-
o['variables']['icu_locales'] = string.join(locs,',')
1359+
o['variables']['icu_locales'] = ','.join(str(loc) for loc in locs)
13671360
# We will check a bit later if we can use the canned deps/icu-small
13681361
elif with_intl == 'full-icu':
13691362
# full ICU
@@ -1503,7 +1496,7 @@ def write_config(data, name):
15031496
elif int(icu_ver_major) < icu_versions['minimum_icu']:
15041497
error('icu4c v%s.x is too old, v%d.x or later is required.' %
15051498
(icu_ver_major, icu_versions['minimum_icu']))
1506-
icu_endianness = sys.byteorder[0];
1499+
icu_endianness = sys.byteorder[0]
15071500
o['variables']['icu_ver_major'] = icu_ver_major
15081501
o['variables']['icu_endianness'] = icu_endianness
15091502
icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.