From: Shane Carr Date: Fri, 18 Jan 2019 00:53:46 +0000 (-0800) Subject: ICU-20334 Additional python3 compatibility changes to depstest. X-Git-Tag: release-64-rc~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=335abbe3ac5302b893fe65871615a58d8dc7ac9f;p=icu ICU-20334 Additional python3 compatibility changes to depstest. Also adds python3 depstest call to .travis.yml. --- diff --git a/.travis.yml b/.travis.yml index 25487aff54e..83011799b64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ matrix: - make -j2 script: - make -j2 check - - ( cd test/depstest && ./depstest.py ../../../source/ ) + - ( cd test/depstest && python3 depstest.py ../../../source/ ) - name: "c: osx clang" language: cpp diff --git a/icu4c/source/test/depstest/dependencies.py b/icu4c/source/test/depstest/dependencies.py index f4e7a7d4751..2ef225ce382 100755 --- a/icu4c/source/test/depstest/dependencies.py +++ b/icu4c/source/test/depstest/dependencies.py @@ -71,7 +71,7 @@ def _RemoveComment(line): def _ReadLine(f): while True: - line = _RemoveComment(f.next()) + line = _RemoveComment(next(f)) if line: return line def _ReadFiles(deps_file, item, library_name): @@ -147,7 +147,7 @@ def Load(): line = None current_type = None while True: - while not line: line = _RemoveComment(deps_file.next()) + while not line: line = _RemoveComment(next(deps_file)) if line.startswith("library: "): current_type = "library" diff --git a/icu4c/source/test/depstest/depstest.py b/icu4c/source/test/depstest/depstest.py index e73dbe18186..4d05f06bd99 100755 --- a/icu4c/source/test/depstest/depstest.py +++ b/icu4c/source/test/depstest/depstest.py @@ -45,6 +45,15 @@ _virtual_classes = set() # nm shows a symbol class of "W" rather than "T". _weak_destructors = set() +def iteritems(items): + """Python 2/3-compatible iteritems""" + try: + for v in items.iteritems(): + yield v + except AttributeError: + for v in items.items(): + yield v + def _ReadObjFile(root_path, library_name, obj_name): global _ignored_symbols, _obj_files, _symbols_to_files global _virtual_classes, _weak_destructors @@ -61,7 +70,7 @@ def _ReadObjFile(root_path, library_name, obj_name): obj_imports = set() obj_exports = set() for line in nm_result.splitlines(): - fields = line.split("|") + fields = line.decode().split("|") if len(fields) == 1: continue name = fields[0].strip() # Ignore symbols like '__cxa_pure_virtual', @@ -168,7 +177,7 @@ def Process(root_path): global _ignored_symbols, _obj_files, _return_value global _virtual_classes, _weak_destructors dependencies.Load() - for name_and_item in dependencies.items.iteritems(): + for name_and_item in iteritems(dependencies.items): name = name_and_item[0] item = name_and_item[1] system_symbols = item.get("system_symbols")