From: Daira Hopwood Date: Tue, 2 Feb 2016 18:10:33 +0000 (+0000) Subject: Don't call time.tzset() if the platform doesn't have it. fixes ticket:2723 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/...?a=commitdiff_plain;h=0abbf474b0dfbdb953316023ee9e17e9257c0547;p=tahoe-lafs%2Ftahoe-lafs.git Don't call time.tzset() if the platform doesn't have it. fixes ticket:2723 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index 47dbe59a..9e8149d1 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -177,18 +177,23 @@ class TestMixin(SignalMixin): class TimezoneMixin(object): def setTimezone(self, timezone): + def tzset_if_possible(): + # Windows doesn't have time.tzset(). + if hasattr(time, 'tzset'): + time.tzset() + unset = object() originalTimezone = os.environ.get('TZ', unset) def restoreTimezone(): if originalTimezone is unset: del os.environ['TZ'] - time.tzset() else: os.environ['TZ'] = originalTimezone - time.tzset() + tzset_if_possible() + os.environ['TZ'] = timezone - time.tzset() self.addCleanup(restoreTimezone) + tzset_if_possible() try: