Python 3 porting - Wrap returns from map() in list()
authorZachary Turner <zturner@google.com>
Thu, 22 Oct 2015 20:39:59 +0000 (20:39 +0000)
committerZachary Turner <zturner@google.com>
Thu, 22 Oct 2015 20:39:59 +0000 (20:39 +0000)
Under Python 2 this has no effect, since map() returns a list.
In Python 3 map() returns an iterable, so wrapping in a list is
necessary to keep the same semantics.

llvm-svn: 251060

lldb/test/dosep.py
lldb/test/dotest.py
lldb/test/lldbtest.py
lldb/test/lldbutil.py

index f413336..7f276e0 100755 (executable)
@@ -921,7 +921,7 @@ def inprocess_exec_test_runner(test_work_items):
         socket_thread.start()
 
     # Do the work.
-    test_results = map(process_dir_mapper_inprocess, test_work_items)
+    test_results = list(map(process_dir_mapper_inprocess, test_work_items))
 
     # If we have a listener channel, shut it down here.
     if RESULTS_LISTENER_CHANNEL is not None:
index 883379d..d1ce34b 100755 (executable)
@@ -857,7 +857,7 @@ def parseOptionsAndInitTestdirs():
 
     # Gather all the dirs passed on the command line.
     if len(args.args) > 0:
-        testdirs = map(os.path.abspath, args.args)
+        testdirs = list(map(os.path.abspath, args.args))
         # Shut off multiprocessing mode when test directories are specified.
         no_multiprocess_test_runner = True
 
index 1b0a8e0..29404a8 100644 (file)
@@ -186,7 +186,7 @@ def SETTING_MSG(setting):
 
 def EnvArray():
     """Returns an env variable array from the os.environ map object."""
-    return map(lambda k,v: k+"="+v, os.environ.keys(), os.environ.values())
+    return list(map(lambda k,v: k+"="+v, os.environ.keys(), os.environ.values()))
 
 def line_number(filename, string_to_match):
     """Helper function to return the line number of the first matched string."""
index 92cb853..8c23637 100644 (file)
@@ -77,7 +77,7 @@ def int_to_bytearray(val, bytesize):
         return None
 
     packed = struct.pack(fmt, val)
-    return bytearray(map(ord, packed))
+    return bytearray(list(map(ord, packed)))
 
 def bytearray_to_int(bytes, bytesize):
     """Utility function to convert a bytearray into an integer.
@@ -607,7 +607,7 @@ def get_function_names(thread):
     def GetFuncName(i):
         return thread.GetFrameAtIndex(i).GetFunctionName()
 
-    return map(GetFuncName, range(thread.GetNumFrames()))
+    return list(map(GetFuncName, range(thread.GetNumFrames())))
 
 
 def get_symbol_names(thread):
@@ -617,7 +617,7 @@ def get_symbol_names(thread):
     def GetSymbol(i):
         return thread.GetFrameAtIndex(i).GetSymbol().GetName()
 
-    return map(GetSymbol, range(thread.GetNumFrames()))
+    return list(map(GetSymbol, range(thread.GetNumFrames())))
 
 
 def get_pc_addresses(thread):
@@ -627,7 +627,7 @@ def get_pc_addresses(thread):
     def GetPCAddress(i):
         return thread.GetFrameAtIndex(i).GetPCAddress()
 
-    return map(GetPCAddress, range(thread.GetNumFrames()))
+    return list(map(GetPCAddress, range(thread.GetNumFrames())))
 
 
 def get_filenames(thread):
@@ -637,7 +637,7 @@ def get_filenames(thread):
     def GetFilename(i):
         return thread.GetFrameAtIndex(i).GetLineEntry().GetFileSpec().GetFilename()
 
-    return map(GetFilename, range(thread.GetNumFrames()))
+    return list(map(GetFilename, range(thread.GetNumFrames())))
 
 
 def get_line_numbers(thread):
@@ -647,7 +647,7 @@ def get_line_numbers(thread):
     def GetLineNumber(i):
         return thread.GetFrameAtIndex(i).GetLineEntry().GetLine()
 
-    return map(GetLineNumber, range(thread.GetNumFrames()))
+    return list(map(GetLineNumber, range(thread.GetNumFrames())))
 
 
 def get_module_names(thread):
@@ -657,7 +657,7 @@ def get_module_names(thread):
     def GetModuleName(i):
         return thread.GetFrameAtIndex(i).GetModule().GetFileSpec().GetFilename()
 
-    return map(GetModuleName, range(thread.GetNumFrames()))
+    return list(map(GetModuleName, range(thread.GetNumFrames())))
 
 
 def get_stack_frames(thread):
@@ -667,7 +667,7 @@ def get_stack_frames(thread):
     def GetStackFrame(i):
         return thread.GetFrameAtIndex(i)
 
-    return map(GetStackFrame, range(thread.GetNumFrames()))
+    return list(map(GetStackFrame, range(thread.GetNumFrames())))
 
 
 def print_stacktrace(thread, string_buffer = False):