Skip to contentSkip to conversation

rteval: return empty string in compress_cpulist for an empty list

PATCH New John Kacur 1 participant 1 message Aug 31, 2023

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 rteval: return empty string in compress_cpulist for an empty list

If an empty list is passed to the function compress_cpulist in systopology.py, return an empty string, or else an IndexError will be triggered.

---
 rteval/systopology.py | 2 ++
 1 file changed, 2 insertions(+)
rteval/systopology.py +2 -0
index aca2dfd03e95..62ad3558e2e5 100644
@@ -147,6 +147,8 @@ class CpuList:
     @staticmethod
     def compress_cpulist(cpulist):
         """ return a string representation of cpulist """
+        if not cpulist:
+            return ""
         if isinstance(cpulist[0], int):
             return ",".join(str(e) for e in cpulist)
         return ",".join(cpulist)
Signature · 1 line
2.40.1