]> granicus.if.org Git - icu/commitdiff
ICU-20334 Additional python3 compatibility changes to depstest.
authorShane Carr <shane@unicode.org>
Fri, 18 Jan 2019 00:53:46 +0000 (16:53 -0800)
committerShane F. Carr <shane@unicode.org>
Fri, 18 Jan 2019 06:38:18 +0000 (22:38 -0800)
Also adds python3 depstest call to .travis.yml.

.travis.yml
icu4c/source/test/depstest/dependencies.py
icu4c/source/test/depstest/depstest.py

index 25487aff54ebb01cd942e84392a08b400b8f501b..83011799b64d0d6692cdc77ee3214cba8f6e7fcb 100644 (file)
@@ -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
index f4e7a7d47517cd599ef66b15175be3d2bd0b8c38..2ef225ce382539ce68433fcd74b127141699fd5d 100755 (executable)
@@ -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"
index e73dbe181864020d254c010c1d48ef824bc87319..4d05f06bd99a7cb0f4b2627e72a0e4f6654eb8d7 100755 (executable)
@@ -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")