rteval: Add __contains__ in rtevalConfig
PATCH 1/1 rteval: Add __contains__ in rtevalConfig
Add the __contains__ function to the rtevalCfgSection class to make "in" function correctly.
For example in cyclictest.py, self.__cfg is not a dictionary, it is an instance of the rtevalCfgSection class, therefore
key in self.__cfg
does not work as expected. In order to make sure this is fixed everywhere, instead of comparing to self.__cfg.keys() everywhere this is used, implement the __contains__ function so that "in" works as expected.
This bug was introduced by the commit fd3b732f714d ("rteval: 2to3 transformations")
Correction
--- rteval/rtevalConfig.py | 2 ++ 1 file changed, 2 insertions(+)
rteval/rtevalConfig.py +2 -0
@@ -126,6 +126,8 @@ class rtevalCfgSection: return self.__cfgdata[key] return None + def __contains__(self, key): + return key in self.__cfgdata def items(self): return list(self.__cfgdata.items())
Signature · 1 line
2.31.1
Quoted 38 lines · John Kacur
Add the
__contains__function to the rtevalCfgSection class to make "in" function correctly.For example in
cyclictest.py, self.__cfg is not a dictionary, it is an instance of the rtevalCfgSection class, therefore
key in self.__cfg
does not work as expected. In order to make sure this is fixed everywhere, instead of comparing toself.__cfg.keys()everywhere this is used, implement the__contains__function so that "in" works as expected.This bug was introduced by the commit
fd3b732f714d("rteval: 2to3 transformations")Reported-by Atsushi Nemoto <[email protected]>Signed-off-by John Kacur <[email protected]>Correction
Suggested-by Jeff Epler <[email protected]>Signed-off-by John Kacur <[email protected]>--- rteval/rtevalConfig.py | 2 ++ 1 file changed, 2 insertions(+)rteval/rtevalConfig.py +2
-0@@ -126,6 +126,8 @@ class rtevalCfgSection: return self.__cfgdata[key] return None + def __contains__(self, key): + return key in self.__cfgdata def items(self): return list(self.__cfgdata.items())Signature · 1 line
2.31.1
Thank you for review and correct fix.
---
Atsushi Nemoto