[PATCH 18/22] Beware of 0 being the same bool value as None when setting time
David Shea
dshea at redhat.com
Wed Jun 3 16:03:42 UTC 2015
From: Vratislav Podzimek <vpodzime at redhat.com>
The 'day or now.day' expression gives now.day not only in case day is None, but
also if day is 0.
(cherry picked from commit b155f199de8dbb3f1200516cb097b8055170dc88)
Related: rhbz#1188287
---
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 d31656c..e6e3d02 100644
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -132,12 +132,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