From 253cc81a57535fa93c762b4a50b4673274721121 Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Mon, 17 Sep 2018 19:03:15 +0800 Subject: [PATCH] Remove custom item retrieval in the params object Not only does this hide a proper stack trace of where the missing parameter was detected but it also makes it impossible to use other useful methods like pop() with a default and so on, all because of the unnecessary custom ParamNotFound error which is never caught in an exception clause at the abc collection on a higher level. Signed-off-by: Plamen Dimitrov --- virttest/utils_params.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/virttest/utils_params.py b/virttest/utils_params.py index d8302526ca..118ee928ef 100644 --- a/virttest/utils_params.py +++ b/virttest/utils_params.py @@ -20,22 +20,6 @@ class Params(IterableUserDict): """ lock = Lock() - def __getitem__(self, key): - """ overrides the error messages of missing params[$key] """ - try: - return IterableUserDict.__getitem__(self, key) - except KeyError: - raise ParamNotFound("Mandatory parameter '%s' is missing. " - "Check your cfg files for typos/mistakes" % - key) - - def get(self, key, default=None): - """ overrides the behavior to catch ParamNotFound error""" - try: - return self[key] - except ParamNotFound: - return default - def setdefault(self, key, failobj=None): if key not in self: self[key] = failobj