mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
time.clock() now emits a DeprecationWarning (GH-4020)
bpo-31803: time.clock() and time.get_clock_info('clock') now emit a
DeprecationWarning warning.
Replace time.clock() with time.perf_counter() in tests and demos.
Remove also hasattr(time, 'monotonic') in test_time since time.monotonic()
is now always available since Python 3.5.
This commit is contained in:
parent
de86073a76
commit
884d13a55f
14 changed files with 39 additions and 20 deletions
|
|
@ -104,6 +104,13 @@ perf_counter(_Py_clock_info_t *info)
|
|||
static PyObject*
|
||||
pyclock(_Py_clock_info_t *info)
|
||||
{
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"time.clock has been deprecated in Python 3.3 and will "
|
||||
"be removed from Python 3.8: "
|
||||
"use time.perf_counter or time.process_time "
|
||||
"instead", 1) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
#ifdef MS_WINDOWS
|
||||
return perf_counter(info);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue