Skip to content

Commit ddd7c42

Browse files
authored
bpo-33717: pythoninfo logs information of all clocks (GH-11460)
test.pythoninfo now logs information of all clocks, not only time.time() and time.perf_counter().
1 parent df8e1fb commit ddd7c42

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Lib/test/pythoninfo.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import sys
88
import traceback
9+
import warnings
910

1011

1112
def normalize_text(text):
@@ -380,9 +381,17 @@ def collect_time(info_add):
380381
copy_attributes(info_add, time, 'time.%s', attributes)
381382

382383
if hasattr(time, 'get_clock_info'):
383-
for clock in ('time', 'perf_counter'):
384-
tinfo = time.get_clock_info(clock)
385-
info_add('time.get_clock_info(%s)' % clock, tinfo)
384+
for clock in ('clock', 'monotonic', 'perf_counter',
385+
'process_time', 'thread_time', 'time'):
386+
try:
387+
# prevent DeprecatingWarning on get_clock_info('clock')
388+
with warnings.catch_warnings(record=True):
389+
clock_info = time.get_clock_info(clock)
390+
except ValueError:
391+
# missing clock like time.thread_time()
392+
pass
393+
else:
394+
info_add('time.get_clock_info(%s)' % clock, clock_info)
386395

387396

388397
def collect_datetime(info_add):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test.pythoninfo now logs information of all clocks, not only time.time() and
2+
time.perf_counter().

0 commit comments

Comments
 (0)