summaryrefslogtreecommitdiff
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-10-17 14:46:45 -0700
committerGitHub <noreply@github.com>2017-10-17 14:46:45 -0700
commit884d13a55fc328e2e1e3948a82b361b30804b818 (patch)
tree8b68f04b9261c26d4f2f5ed7a7beaa1d31c236c0 /Modules/timemodule.c
parentde86073a761cd3539aaca6f886a1f55effc0d9da (diff)
downloadcpython-git-884d13a55fc328e2e1e3948a82b361b30804b818.tar.gz
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.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 6af9a90e58..463f5c5577 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -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