diff mbox series

[1/3] rteval: systopology: Fix offline NUMA node parsing

Message ID 20220419161443.89674-2-vschneid@redhat.com
State New
Headers show
Series rteval: Offline NUMA node bugfix | expand

Commit Message

Valentin Schneider April 19, 2022, 4:14 p.m. UTC
An offline NUMA node will report in its cpulist an empty
string. Unfortunately, "".split(sep=x) with x != None returns a list
containing an empty string rather than an empty list, which causes
CpuList._expand_cpulist() to try to run int(''), which ends up in the
following exception:

  ValueError: invalid literal for int() with base 10: ''

Prevent this by adding an early empty-string check.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 rteval/systopology.py | 4 ++++
 1 file changed, 4 insertions(+)

Comments

John Kacur April 29, 2022, 7:54 p.m. UTC | #1
On Tue, 19 Apr 2022, Valentin Schneider wrote:

> An offline NUMA node will report in its cpulist an empty
> string. Unfortunately, "".split(sep=x) with x != None returns a list
> containing an empty string rather than an empty list, which causes
> CpuList._expand_cpulist() to try to run int(''), which ends up in the
> following exception:
> 
>   ValueError: invalid literal for int() with base 10: ''
> 
> Prevent this by adding an early empty-string check.
> 
> Signed-off-by: Valentin Schneider <vschneid@redhat.com>
> ---
>  rteval/systopology.py | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/rteval/systopology.py b/rteval/systopology.py
> index bf794ce..b2da7bb 100644
> --- a/rteval/systopology.py
> +++ b/rteval/systopology.py
> @@ -103,6 +103,10 @@ class CpuList:
>          don't error check against online cpus
>          """
>          result = []
> +
> +        if not cpulist:
> +            return result
> +
>          for part in cpulist.split(','):
>              if '-' in part:
>                  a, b = part.split('-')
> -- 
> 2.27.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/rteval/systopology.py b/rteval/systopology.py
index bf794ce..b2da7bb 100644
--- a/rteval/systopology.py
+++ b/rteval/systopology.py
@@ -103,6 +103,10 @@  class CpuList:
         don't error check against online cpus
         """
         result = []
+
+        if not cpulist:
+            return result
+
         for part in cpulist.split(','):
             if '-' in part:
                 a, b = part.split('-')