8000 bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31… · python/cpython@a4674f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4674f0

Browse files
authored
bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898)
1 parent af0a50d commit a4674f0

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Lib/test/datetimetester.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,9 @@ def test_gaps(self):
58565856
ldt = tz.fromutc(udt.replace(tzinfo=tz))
58575857
self.assertEqual(ldt.fold, 0)
58585858

5859+
@unittest.skipUnless(
5860+
hasattr(time, "tzset"), "time module has no attribute tzset"
5861+
)
58595862
def test_system_transitions(self):
58605863
if ('Riyadh8' in self.zonename or
58615864
# From tzdata NEWS file:

Lib/test/test_strptime.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ def test_timezone(self):
390390
"LocaleTime().timezone has duplicate values and "
391391
"time.daylight but timezone value not set to -1")
392392

393+
@unittest.skipUnless(
394+
hasattr(time, "tzset"), "time module has no attribute tzset"
395+
)
393396
def test_bad_timezone(self):
394397
# Explicitly test possibility of bad timezone;
395398
# when time.tzname[0] == time.tzname[1] and time.daylight

Lib/test/test_time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,9 @@ def test_get_clock_info(self):
561561
'perf_counter',
562562
'process_time',
563563
'time',
564-
'thread_time',
565564
]
565+
if hasattr(time, 'thread_time'):
566+
clocks.append('thread_time')
566567

567568
for name in clocks:
568569
with self.subTest(name=name):

Modules/timemodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,9 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
14791479
return 0;
14801480
}
14811481

1482-
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
1482+
#elif defined(HAVE_CLOCK_GETTIME) && \
1483+
defined(CLOCK_PROCESS_CPUTIME_ID) && \
1484+
!defined(__EMSCRIPTEN__)
14831485
#define HAVE_THREAD_TIME
14841486

14851487
#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)

0 commit comments

Comments
 (0)
0