Tomas Golembiovsky has uploaded a new change for review. Change subject: utils: Making try block smaller in tobool() ......................................................................
utils: Making try block smaller in tobool() The try-except block was too broad and spanned unnecessarily large block of code. That is a good way to hide bugs. Change-Id: I9c7326798fc5a2c8c1491fb7433657fa460495be Signed-off-by: Tomáš Golembiovský <tgole...@redhat.com> --- M lib/vdsm/utils.py 1 file changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/57549/1 diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py index 40bb4d5..23e3171 100644 --- a/lib/vdsm/utils.py +++ b/lib/vdsm/utils.py @@ -409,15 +409,15 @@ def tobool(s): + if s is None: + return False + if type(s) == bool: + return s + if isinstance(s, basestring) and s.lower() == 'true': + return True try: - if s is None: - return False - if type(s) == bool: - return s - if isinstance(s, basestring) and s.lower() == 'true': - return True return bool(int(s)) - except: + except ValueError: return False -- To view, visit https://gerrit.ovirt.org/57549 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9c7326798fc5a2c8c1491fb7433657fa460495be Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Tomas Golembiovsky <tgole...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches