[Python-checkins] bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898)
tiran
webhook-mailer at python.org
Tue Mar 15 16:55:48 EDT 2022
https://github.com/python/cpython/commit/a4674f0194067a801f6c6bdb4fc6448e3a40e069
commit: a4674f0194067a801f6c6bdb4fc6448e3a40e069
branch: main
author: Christian Heimes <christian at python.org>
committer: tiran <christian at python.org>
date: 2022-03-15T21:55:35+01:00
summary:
bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898)
files:
M Lib/test/datetimetester.py
M Lib/test/test_strptime.py
M Lib/test/test_time.py
M Modules/timemodule.c
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index e208a29813eed..efea40d3f4ff1 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -5856,6 +5856,9 @@ def test_gaps(self):
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:
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 55a0f426731a5..e5f75b7aab9aa 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -390,6 +390,9 @@ def test_timezone(self):
"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
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 57011d158cd03..faac639613a5c 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -561,8 +561,9 @@ def test_get_clock_info(self):
'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):
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 5b2d9b768ddd6..7475ef344b72b 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -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)
More information about the Python-checkins
mailing list