mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 19:26:25 +00:00
Don't call time.tzset() if the platform doesn't have it. fixes ticket:2723
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
67af736db1
commit
0abbf474b0
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user