bpo-36895: remove time.clock() as per removal notice. (GH-13270) · python/cpython@e250061 (original) (raw)

`@@ -145,44 +145,6 @@ perf_counter(_Py_clock_info_t *info)

`

145

145

`return _PyFloat_FromPyTime(t);

`

146

146

`}

`

147

147

``

148

``

`-

#if (defined(MS_WINDOWS) || defined(HAVE_CLOCK)) && !defined(VXWORKS)

`

149

``

`-

#define PYCLOCK

`

150

``

`-

static PyObject*

`

151

``

`-

pyclock(_Py_clock_info_t *info)

`

152

``

`-

{

`

153

``

`-

if (PyErr_WarnEx(PyExc_DeprecationWarning,

`

154

``

`-

"time.clock has been deprecated in Python 3.3 and will "

`

155

``

`-

"be removed from Python 3.8: "

`

156

``

`-

"use time.perf_counter or time.process_time "

`

157

``

`-

"instead", 1) < 0) {

`

158

``

`-

return NULL;

`

159

``

`-

}

`

160

``

-

161

``

`-

#ifdef MS_WINDOWS

`

162

``

`-

return perf_counter(info);

`

163

``

`-

#else

`

164

``

`-

_PyTime_t t;

`

165

``

`-

if (_PyTime_GetClockWithInfo(&t, info) < 0) {

`

166

``

`-

return NULL;

`

167

``

`-

}

`

168

``

`-

return _PyFloat_FromPyTime(t);

`

169

``

`-

#endif

`

170

``

`-

}

`

171

``

-

172

``

`-

static PyObject *

`

173

``

`-

time_clock(PyObject *self, PyObject *unused)

`

174

``

`-

{

`

175

``

`-

return pyclock(NULL);

`

176

``

`-

}

`

177

``

-

178

``

`-

PyDoc_STRVAR(clock_doc,

`

179

``

`-

"clock() -> floating point number\n\

`

180

``

`-

\n\

`

181

``

`-

Return the CPU time or real time since the start of the process or since\n\

`

182

``

`-

the first call to clock(). This has as much precision as the system\n\

`

183

``

`-

records.");

`

184

``

`-

#endif

`

185

``

-

186

148

`#ifdef HAVE_CLOCK_GETTIME

`

187

149

`static PyObject *

`

188

150

`time_clock_gettime(PyObject *self, PyObject *args)

`

`@@ -1477,15 +1439,6 @@ time_get_clock_info(PyObject *self, PyObject *args)

`

1477

1439

`return NULL;

`

1478

1440

` }

`

1479

1441

` }

`

1480

``

`-

#ifdef PYCLOCK

`

1481

``

`-

else if (strcmp(name, "clock") == 0) {

`

1482

``

`-

obj = pyclock(&info);

`

1483

``

`-

if (obj == NULL) {

`

1484

``

`-

return NULL;

`

1485

``

`-

}

`

1486

``

`-

Py_DECREF(obj);

`

1487

``

`-

}

`

1488

``

`-

#endif

`

1489

1442

`else if (strcmp(name, "monotonic") == 0) {

`

1490

1443

`if (_PyTime_GetMonotonicClockWithInfo(&t, &info) < 0) {

`

1491

1444

`return NULL;

`

`@@ -1700,9 +1653,6 @@ init_timezone(PyObject *m)

`

1700

1653

`static PyMethodDef time_methods[] = {

`

1701

1654

` {"time", time_time, METH_NOARGS, time_doc},

`

1702

1655

` {"time_ns", time_time_ns, METH_NOARGS, time_ns_doc},

`

1703

``

`-

#ifdef PYCLOCK

`

1704

``

`-

{"clock", time_clock, METH_NOARGS, clock_doc},

`

1705

``

`-

#endif

`

1706

1656

`#ifdef HAVE_CLOCK_GETTIME

`

1707

1657

` {"clock_gettime", time_clock_gettime, METH_VARARGS, clock_gettime_doc},

`

1708

1658

` {"clock_gettime_ns",time_clock_gettime_ns, METH_VARARGS, clock_gettime_ns_doc},

`