1
# DP: Fix issue #762963, python loses current timezone.
3
Index: python2.6-2.6.5+20100521/Lib/test/test_time.py
4
===================================================================
5
--- python2.6-2.6.5+20100521.orig/Lib/test/test_time.py 2010-05-21 16:20:32.980725082 +0200
6
+++ python2.6-2.6.5+20100521/Lib/test/test_time.py 2010-05-21 16:20:33.004709833 +0200
8
from test import test_support
9
+from os import environ
15
self.assert_(0 <= (t1-t0) < 0.2)
17
+ # Check for problems with tm_gmtoff in struct time. These can bite us
18
+ # on BSD-derived libc's. The primary (only?) sympton is to break the
19
+ # strftime %z format.
20
+ def test_tm_gmtoff1(self):
21
+ # The %z format is not guaranteed to be supported by the libc
22
+ # strftime(), but strftime(fmt) is documented to work the same as
23
+ # as strftime(fmt, localtime()) in all cases.
24
+ self.failUnlessEqual(
25
+ time.strftime("%z"), time.strftime("%z", time.localtime()))
27
+ @unittest.skipUnless(hasattr(time, "tzset"), "tzset not available")
28
+ def test_tm_gmtoff2(self):
29
+ # The %z format is not guaranteed to be supported by the libc
30
+ # strftime(), but if it is US Eastern timezone should never
32
+ eastern = "EST+05EDT,M4.1.0,M10.5.0"
33
+ org_TZ = environ.get("TZ", None)
35
+ environ["TZ"] = eastern
37
+ self.assertNotEqual(
38
+ time.strftime("%z", time.localtime()), "+0000")
40
+ # Repair TZ environment variable in case any other tests
42
+ if org_TZ is not None:
43
+ environ["TZ"] = org_TZ
44
+ elif "TZ" in environ:
49
test_support.run_unittest(TimeTestCase)
51
Index: python2.6-2.6.5+20100521/Modules/timemodule.c
52
===================================================================
53
--- python2.6-2.6.5+20100521.orig/Modules/timemodule.c 2010-05-21 16:20:33.000710163 +0200
54
+++ python2.6-2.6.5+20100521/Modules/timemodule.c 2010-05-21 16:20:33.008710342 +0200
57
memset((void *) p, '\0', sizeof(struct tm));
60
+ /* Use mktime to normalize the struct tm field tm_gmtoff to
61
+ the current timezone offset for the benefit of the
62
+ BSD-style struct tm's that have it. Without this we would
63
+ lie to these libc's by using a struct tm that says we are
67
if (!PyArg_Parse(args, "(iiiiiiiii)",