]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Don't call time.tzset() if the platform doesn't have it. fixes ticket:2723
authorDaira Hopwood <daira@jacaranda.org>
Tue, 2 Feb 2016 18:10:33 +0000 (18:10 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 2 Feb 2016 18:10:33 +0000 (18:10 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/common_util.py

index 47dbe59a3fb685ad02cb99c54f7425e71cff9b61..9e8149d13583790c12ad61fb1a5331d5316cf709 100644 (file)
@@ -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: