PAPI: Python 3.8 compatibility 26/31326/2
authorpmikus <pmikus@cisco.com>
Wed, 17 Feb 2021 14:27:12 +0000 (14:27 +0000)
committerPeter Mikus <pmikus@cisco.com>
Wed, 17 Feb 2021 15:07:51 +0000 (15:07 +0000)
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: I33fefddda9055524c1817b13b5c99bb1b97ebff4

resources/libraries/python/PapiExecutor.py

index 6b21680..76d7daf 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -23,6 +23,8 @@ import subprocess
 import sys
 import tempfile
 import time
 import sys
 import tempfile
 import time
+from collections import UserDict
+
 
 from pprint import pformat
 from robot.api import logger
 
 from pprint import pformat
 from robot.api import logger
@@ -67,11 +69,11 @@ def dictize(obj):
     """
     if not hasattr(obj, u"_asdict"):
         return obj
     """
     if not hasattr(obj, u"_asdict"):
         return obj
-    ret = obj._asdict()
-    old_get = ret.__getitem__
+    overriden = UserDict(obj._asdict())
+    old_get = overriden.__getitem__
     new_get = lambda self, key: dictize(old_get(self, key))
     new_get = lambda self, key: dictize(old_get(self, key))
-    ret.__getitem__ = new_get
-    return ret
+    overriden.__getitem__ = new_get
+    return overriden
 
 
 class PapiSocketExecutor:
 
 
 class PapiSocketExecutor: