Skip to content

Commit

Permalink
time.clock_gettime and clock_gettime_ns are METH_O in Python 3.13.0a2+
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Nov 24, 2023
1 parent e3478cc commit a46d63d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/_time_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ _time_machine_clock_gettime(PyObject *self, PyObject *args)
PyObject *time_machine_module = PyImport_ImportModule("time_machine");
PyObject *time_machine_clock_gettime = PyObject_GetAttrString(time_machine_module, "clock_gettime");

#if PY_VERSION_HEX >= 0x030d00a2
PyObject* result = PyObject_CallOneArg(time_machine_clock_gettime, args);
#else
PyObject* result = PyObject_CallObject(time_machine_clock_gettime, args);
#endif

Py_DECREF(time_machine_clock_gettime);
Py_DECREF(time_machine_module);
Expand Down Expand Up @@ -142,7 +146,11 @@ _time_machine_clock_gettime_ns(PyObject *self, PyObject *args)
PyObject *time_machine_module = PyImport_ImportModule("time_machine");
PyObject *time_machine_clock_gettime_ns = PyObject_GetAttrString(time_machine_module, "clock_gettime_ns");

#if PY_VERSION_HEX >= 0x030d00a2
PyObject* result = PyObject_CallOneArg(time_machine_clock_gettime_ns, args);
#else
PyObject* result = PyObject_CallObject(time_machine_clock_gettime_ns, args);
#endif

Py_DECREF(time_machine_clock_gettime_ns);
Py_DECREF(time_machine_module);
Expand Down Expand Up @@ -478,8 +486,13 @@ PyDoc_STRVAR(module_doc, "_time_machine module");
static PyMethodDef module_functions[] = {
{"original_now", (PyCFunction)_time_machine_original_now, METH_FASTCALL|METH_KEYWORDS, original_now_doc},
{"original_utcnow", (PyCFunction)_time_machine_original_utcnow, METH_NOARGS, original_utcnow_doc},
#if PY_VERSION_HEX >= 0x030d00a2
{"original_clock_gettime", (PyCFunction)_time_machine_original_clock_gettime, METH_O, original_clock_gettime_doc},
{"original_clock_gettime_ns", (PyCFunction)_time_machine_original_clock_gettime_ns, METH_O, original_clock_gettime_ns_doc},
#else
{"original_clock_gettime", (PyCFunction)_time_machine_original_clock_gettime, METH_VARARGS, original_clock_gettime_doc},
{"original_clock_gettime_ns", (PyCFunction)_time_machine_original_clock_gettime_ns, METH_VARARGS, original_clock_gettime_ns_doc},
#endif
{"original_gmtime", (PyCFunction)_time_machine_original_gmtime, METH_VARARGS, original_gmtime_doc},
{"original_localtime", (PyCFunction)_time_machine_original_localtime, METH_VARARGS, original_localtime_doc},
{"original_monotonic", (PyCFunction)_time_machine_original_monotonic, METH_NOARGS, original_monotonic_doc},
Expand Down

0 comments on commit a46d63d

Please sign in to comment.