| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b085b94 commit 0a63e2d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ | |||
| 11 | 11 | import shlex | |
| 12 | 12 | import subprocess | |
| 13 | 13 | import shutil | |
| 14 | - import string | ||
| 15 | 14 | from distutils.spawn import find_executable as which | |
| 16 | 15 | ||
| 17 | 16 | # If not run from node/, cd to node/. | |
@@ -626,18 +625,14 @@ def print_verbose(x): | |||
| 626 | 625 | ||
| 627 | 626 | def b(value): | |
| 628 | 627 | """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' | ||
| 633 | 629 | ||
| 634 | 630 | def B(value): | |
| 635 | 631 | """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 | ||
| 640 | 633 | ||
| 634 | + def to_utf8(s): | ||
| 635 | + return s if isinstance(s, str) else s.decode("utf-8") | ||
| 641 | 636 | ||
| 642 | 637 | def pkg_config(pkg): | |
| 643 | 638 | """Run pkg-config on the specified package | |
@@ -652,7 +647,7 @@ def pkg_config(pkg): | |||
| 652 | 647 | try: | |
| 653 | 648 | proc = subprocess.Popen(shlex.split(pkg_config) + args, | |
| 654 | 649 | stdout=subprocess.PIPE) | |
| 655 | - val = proc.communicate()[0].strip() | ||
| 650 | + val = to_utf8(proc.communicate()[0]).strip() | ||
| 656 | 651 | except OSError as e: | |
| 657 | 652 | if e.errno != errno.ENOENT: raise e # Unexpected error. | |
| 658 | 653 | return (None, None, None, None) # No pkg-config/pkgconf installed. | |
@@ -668,10 +663,10 @@ def try_check_compiler(cc, lang): | |||
| 668 | 663 | except OSError: | |
| 669 | 664 | return (False, False, '', '') | |
| 670 | 665 | ||
| 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__') | ||
| 673 | 668 | ||
| 674 | - values = (proc.communicate()[0].split() + ['0'] * 7)[0:7] | ||
| 669 | + values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7] | ||
| 675 | 670 | is_clang = values[0] == '1' | |
| 676 | 671 | gcc_version = tuple(map(int, values[1:1+3])) | |
| 677 | 672 | clang_version = tuple(map(int, values[4:4+3])) if is_clang else None | |
@@ -696,7 +691,7 @@ def get_version_helper(cc, regexp): | |||
| 696 | 691 | consider adjusting the CC environment variable if you installed | |
| 697 | 692 | it in a non-standard prefix.''') | |
| 698 | 693 | ||
| 699 | - match = re.search(regexp, proc.communicate()[1]) | ||
| 694 | + match = re.search(regexp, to_utf8(proc.communicate()[1])) | ||
| 700 | 695 | ||
| 701 | 696 | if match: | |
| 702 | 697 | return match.group(2) | |
@@ -715,7 +710,7 @@ def get_nasm_version(asm): | |||
| 715 | 710 | return '0' | |
| 716 | 711 | ||
| 717 | 712 | match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)", | |
| 718 | - proc.communicate()[0]) | ||
| 713 | + to_utf8(proc.communicate()[0])) | ||
| 719 | 714 | ||
| 720 | 715 | if match: | |
| 721 | 716 | return match.group(1) | |
@@ -746,7 +741,7 @@ def get_gas_version(cc): | |||
| 746 | 741 | consider adjusting the CC environment variable if you installed | |
| 747 | 742 | it in a non-standard prefix.''') | |
| 748 | 743 | ||
| 749 | - gas_ret = proc.communicate()[1] | ||
| 744 | + gas_ret = to_utf8(proc.communicate()[1]) | ||
| 750 | 745 | match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)", gas_ret) | |
| 751 | 746 | ||
| 752 | 747 | if match: | |
@@ -811,10 +806,8 @@ def cc_macros(cc=None): | |||
| 811 | 806 | consider adjusting the CC environment variable if you installed | |
| 812 | 807 | it in a non-standard prefix.''') | |
| 813 | 808 | ||
| 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') | ||
| 818 | 811 | ||
| 819 | 812 | k = {} | |
| 820 | 813 | for line in out: | |
@@ -1294,7 +1287,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir): | |||
| 1294 | 1287 | ||
| 1295 | 1288 | def configure_intl(o): | |
| 1296 | 1289 | def icu_download(path): | |
| 1297 | - depFile = 'tools/icu/current_ver.dep'; | ||
| 1290 | + depFile = 'tools/icu/current_ver.dep' | ||
| 1298 | 1291 | with open(depFile) as f: | |
| 1299 | 1292 | icus = json.load(f) | |
| 1300 | 1293 | # download ICU, if needed | |
@@ -1363,7 +1356,7 @@ def write_config(data, name): | |||
| 1363 | 1356 | o['variables']['icu_small'] = b(True) | |
| 1364 | 1357 | locs = set(options.with_icu_locales.split(',')) | |
| 1365 | 1358 | 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) | ||
| 1367 | 1360 | # We will check a bit later if we can use the canned deps/icu-small | |
| 1368 | 1361 | elif with_intl == 'full-icu': | |
| 1369 | 1362 | # full ICU | |
@@ -1503,7 +1496,7 @@ def write_config(data, name): | |||
| 1503 | 1496 | elif int(icu_ver_major) < icu_versions['minimum_icu']: | |
| 1504 | 1497 | error('icu4c v%s.x is too old, v%d.x or later is required.' % | |
| 1505 | 1498 | (icu_ver_major, icu_versions['minimum_icu'])) | |
| 1506 | - icu_endianness = sys.byteorder[0]; | ||
| 1499 | + icu_endianness = sys.byteorder[0] | ||
| 1507 | 1500 | o['variables']['icu_ver_major'] = icu_ver_major | |
| 1508 | 1501 | o['variables']['icu_endianness'] = icu_endianness | |
| 1509 | 1502 | icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments