[PATCH 3/3] Beware of 0 being the same bool value as None when setting time

Vratislav Podzimek vpodzime at redhat.com
Mon Dec 15 14:04:35 UTC 2014


The 'day or now.day' expression gives now.day not only in case day is None, but
also if day is 0.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/isys/__init__.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index f417b25..b099355 100644
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -123,12 +123,12 @@ def set_system_date_time(year=None, month=None, day=None, hour=None, minute=None
 
     # get the right values
     now = datetime.datetime.now()
-    year = year or now.year
-    month = month or now.month
-    day = day or now.day
-    hour = hour or now.hour
-    minute = minute or now.minute
-    second = second or now.second
+    year = year if year is not None else now.year
+    month = month if month is not None else now.month
+    day = day if day is not None else now.day
+    hour = hour if hour is not None else now.hour
+    minute = minute if minute is not None else now.minute
+    second = second if second is not None else now.second
 
     # struct fields -> year, month, day, hour, minute, second, week_day, year_day, dst
     time_struct = time.struct_time((year, month, day, hour, minute, second, 0, 0, -1))
-- 
2.1.0



More information about the anaconda-patches mailing list