From 89f65e19ffccb06b07716c6ae4a4a29b51085c3b Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 6 Dec 2017 17:36:47 -0700 Subject: [PATCH] Check for values other than 0 or 1 --- salt/modules/win_lgpo.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py index bbf5a3610a..50d4354b55 100644 --- a/salt/modules/win_lgpo.py +++ b/salt/modules/win_lgpo.py @@ -2435,15 +2435,18 @@ class _policy_info(object): ''' converts a binary 0/1 to Disabled/Enabled ''' - if val is not None: - if ord(val) == 0: - return 'Disabled' - elif ord(val) == 1: - return 'Enabled' + try: + if val is not None: + if ord(val) == 0: + return 'Disabled' + elif ord(val) == 1: + return 'Enabled' + else: + return 'Invalid Value' else: - return 'Invalid Value' - else: - return 'Not Defined' + return 'Not Defined' + except TypeError: + return 'Invalid Value' @classmethod def _binary_enable_zero_disable_one_reverse_conversion(cls, val, **kwargs):