Skip to content

Commit

Permalink
Revert "Fix System Error on Python 3.13 and Windows"
Browse files Browse the repository at this point in the history
This reverts commit 0ccca0f.
  • Loading branch information
adamchainz committed Jun 29, 2024
1 parent 0ccca0f commit d5e0b64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Changelog
=========

* Fix ``SystemError`` on Python 3.13 and Windows when starting time travelling.

Thanks to Bernát Gábor for the report in `Issue #456 <https://github.com/adamchainz/time-machine/issues/456>`__.

2.14.1 (2024-03-22)
-------------------

Expand Down
18 changes: 7 additions & 11 deletions src/_time_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,21 @@ _time_machine_patch_if_needed(PyObject *module, PyObject *unused)

PyObject *time_module = PyImport_ImportModule("time");



PyCFunctionObject *time_clock_gettime = (PyCFunctionObject *) PyObject_GetAttrString(time_module, "clock_gettime");
/*
time.clock_gettime(), only available on Unix platforms.
time.clock_gettime() is not always available
e.g. on builds against old macOS = official Python.org installer
*/
PyCFunctionObject *time_clock_gettime = (PyCFunctionObject *) PyObject_GetAttrString(time_module, "clock_gettime");
if (time_clock_gettime == NULL) {
PyErr_Clear();
} else {
if (time_clock_gettime != NULL) {
state->original_clock_gettime = time_clock_gettime->m_ml->ml_meth;
time_clock_gettime->m_ml->ml_meth = _time_machine_clock_gettime;
Py_DECREF(time_clock_gettime);
}

/*
time.clock_gettime_ns(), only available on Unix platforms.
*/
PyCFunctionObject *time_clock_gettime_ns = (PyCFunctionObject *) PyObject_GetAttrString(time_module, "clock_gettime_ns");
if (time_clock_gettime_ns == NULL) {
PyErr_Clear();
} else {
if (time_clock_gettime_ns != NULL) {
state->original_clock_gettime_ns = time_clock_gettime_ns->m_ml->ml_meth;
time_clock_gettime_ns->m_ml->ml_meth = _time_machine_clock_gettime_ns;
Py_DECREF(time_clock_gettime_ns);
Expand Down

0 comments on commit d5e0b64

Please sign in to comment.