From 17ac6cb22556ed73825453443ca3f99b9863118e Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Fri, 25 Sep 2015 21:49:59 +0200 Subject: [PATCH] core3: boolean properties can be set explicitely --- qubes/__init__.py | 17 ++++++++++------- qubes/tests/tools/qvm_ls.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index eb0cb2f9..c572d6cc 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -757,13 +757,16 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name :py:obj:`True`. ''' # pylint: disable=bad-staticmethod-argument,unused-argument - lcvalue = value.lower() - if lcvalue in ('0', 'no', 'false'): - return False - if lcvalue in ('1', 'yes', 'true'): - return True - raise ValueError( - 'Invalid literal for boolean property: {!r}'.format(value)) + if isinstance(value, basestring): + lcvalue = value.lower() + if lcvalue in ('0', 'no', 'false', 'off'): + return False + if lcvalue in ('1', 'yes', 'true', 'on'): + return True + raise ValueError( + 'Invalid literal for boolean property: {!r}'.format(value)) + + return bool(value) diff --git a/qubes/tests/tools/qvm_ls.py b/qubes/tests/tools/qvm_ls.py index 5063bf9a..edfa1163 100644 --- a/qubes/tests/tools/qvm_ls.py +++ b/qubes/tests/tools/qvm_ls.py @@ -68,7 +68,7 @@ class TC_90_globals(qubes.tests.QubesTestCase): qid=0, name='dom0', internal='False') self.assertFalse(flag(None, vm)) - vm.internal = 'True' + vm.internal = True self.assertTrue(flag(None, vm))