]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898)
authorChristian Heimes <christian@python.org>
Tue, 15 Mar 2022 20:55:35 +0000 (22:55 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Mar 2022 20:55:35 +0000 (21:55 +0100)
Lib/test/datetimetester.py
Lib/test/test_strptime.py
Lib/test/test_time.py
Modules/timemodule.c

index e208a29813eed3f29efb1a537cee20d9f673c8fb..efea40d3f4ff1f0947b6544cbd9db1e36e16ef5e 100644 (file)
@@ -5856,6 +5856,9 @@ class ZoneInfoTest(unittest.TestCase):
                 ldt = tz.fromutc(udt.replace(tzinfo=tz))
                 self.assertEqual(ldt.fold, 0)
 
+    @unittest.skipUnless(
+        hasattr(time, "tzset"), "time module has no attribute tzset"
+    )
     def test_system_transitions(self):
         if ('Riyadh8' in self.zonename or
             # From tzdata NEWS file:
index 55a0f426731a5dbbddc428496afeae9be946db3d..e5f75b7aab9aa5e1fb1b32c818edb2545366f276 100644 (file)
@@ -390,6 +390,9 @@ class StrptimeTests(unittest.TestCase):
                             "LocaleTime().timezone has duplicate values and "
                              "time.daylight but timezone value not set to -1")
 
+    @unittest.skipUnless(
+        hasattr(time, "tzset"), "time module has no attribute tzset"
+        )
     def test_bad_timezone(self):
         # Explicitly test possibility of bad timezone;
         # when time.tzname[0] == time.tzname[1] and time.daylight
index 57011d158cd03772b3ea97e7cd83ac7a5c165f8b..faac639613a5c2af54cfc8cd4c99c61873b3c211 100644 (file)
@@ -561,8 +561,9 @@ class TimeTestCase(unittest.TestCase):
             'perf_counter',
             'process_time',
             'time',
-            'thread_time',
         ]
+        if hasattr(time, 'thread_time'):
+            clocks.append('thread_time')
 
         for name in clocks:
             with self.subTest(name=name):
index 5b2d9b768ddd6f0c8f572d79d5a9e234bfb9d75c..7475ef344b72b28b0a7df8d0a2f09821f36a41e6 100644 (file)
@@ -1479,7 +1479,9 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
     return 0;
 }
 
-#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
+#elif defined(HAVE_CLOCK_GETTIME) && \
+      defined(CLOCK_PROCESS_CPUTIME_ID) && \
+      !defined(__EMSCRIPTEN__)
 #define HAVE_THREAD_TIME
 
 #if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)