~ubuntu-branches/ubuntu/quantal/python2.7/quantal-updates

« back to all changes in this revision

Viewing changes to debian/patches/issue762963.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-11-30 19:16:23 UTC
  • mfrom: (36.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111130191623-ov9hszutdakcsnbz
Tags: 2.7.2-8
* Update to 20111130, taken from the 2.7 branch.
* New patch, ctypes-arm, allow for ",hard-float" after libc6 in ldconfig -p
  output (Loic Minier). LP: #898172.
* debian/rules: Define DPKG_VARS (Alban Browaeys). Closes: #647419).
* Add python-config man page (Johann Felix Soden). Closes: #650181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# DP: Fix issue #762963, python loses current timezone.
2
 
 
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
7
 
@@ -1,4 +1,5 @@
8
 
 from test import test_support
9
 
+from os import environ
10
 
 import time
11
 
 import unittest
12
 
 
13
 
@@ -218,6 +219,37 @@
14
 
         t1 = time.mktime(lt1)
15
 
         self.assert_(0 <= (t1-t0) < 0.2)
16
 
 
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()))
26
 
+
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 
31
 
+        # return +0.
32
 
+        eastern = "EST+05EDT,M4.1.0,M10.5.0"
33
 
+        org_TZ = environ.get("TZ", None)
34
 
+        try:
35
 
+            environ["TZ"] = eastern
36
 
+            time.tzset()
37
 
+            self.assertNotEqual(
38
 
+                    time.strftime("%z", time.localtime()), "+0000")
39
 
+        finally:
40
 
+            # Repair TZ environment variable in case any other tests
41
 
+            # rely on it.
42
 
+            if org_TZ is not None:
43
 
+                environ["TZ"] = org_TZ
44
 
+            elif "TZ" in environ:
45
 
+                del environ["TZ"]
46
 
+            time.tzset()
47
 
+
48
 
 def test_main():
49
 
     test_support.run_unittest(TimeTestCase)
50
 
 
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
55
 
@@ -345,6 +345,14 @@
56
 
     int y;
57
 
     memset((void *) p, '\0', sizeof(struct tm));
58
 
 
59
 
+#ifdef HAVE_TM_ZONE
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
64
 
+          in GMT.  */
65
 
+       mktime(p);
66
 
+#endif
67
 
     if (!PyArg_Parse(args, "(iiiiiiiii)",
68
 
                      &y,
69
 
                      &p->tm_mon,