Skip to content

Commit d4881aa

Browse files
hroncokadamchainz
andauthored
Add Python 3.13 to the CI infrastructure, fix for 3.13.0a2+ (#409)
Co-authored-by: Adam Johnson <[email protected]>
1 parent 3fbd386 commit d4881aa

File tree

9 files changed

+125
-2
lines changed

9 files changed

+125
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- '3.10'
2424
- '3.11'
2525
- '3.12'
26+
- '3.13'
2627

2728
steps:
2829
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ repos:
1717
rev: 1.7.0
1818
hooks:
1919
- id: pyproject-fmt
20+
additional_dependencies: ["tox>=4.9"]
2021
- repo: https://github.com/tox-dev/tox-ini-fmt
2122
rev: 1.3.1
2223
hooks:

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Changelog
1414

1515
Thanks to Nikita Sobolev for the ping in `CPython Issue #113308 <https://github.com/python/cpython/issues/113308>`__.
1616

17+
* Support Python 3.13 alpha 4.
18+
19+
Thanks to Miro Hrončok in `PR #409 <https://github.com/adamchainz/time-machine/pull/409>`__.
20+
1721
2.13.0 (2023-09-19)
1822
-------------------
1923

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Use **pip**:
5454
5555
python -m pip install time-machine
5656
57-
Python 3.8 to 3.12 supported.
57+
Python 3.8 to 3.13 supported.
5858
Only CPython is supported at this time because time-machine directly hooks into the C-level API.
5959

6060

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ classifiers = [
3535
"Programming Language :: Python :: 3.10",
3636
"Programming Language :: Python :: 3.11",
3737
"Programming Language :: Python :: 3.12",
38+
"Programming Language :: Python :: 3.13",
3839
"Typing :: Typed",
3940
]
4041
dependencies = [

requirements/compile.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@
4242
check=True,
4343
capture_output=True,
4444
)
45+
subprocess.run(
46+
["python3.13", *common_args, "-o", "py313.txt"],
47+
check=True,
48+
capture_output=True,
49+
)

requirements/py313.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.13
3+
# by the following command:
4+
#
5+
# requirements/compile.py
6+
#
7+
coverage[toml]==7.4.1 \
8+
--hash=sha256:0193657651f5399d433c92f8ae264aff31fc1d066deee4b831549526433f3f61 \
9+
--hash=sha256:02f2edb575d62172aa28fe00efe821ae31f25dc3d589055b3fb64d51e52e4ab1 \
10+
--hash=sha256:0491275c3b9971cdbd28a4595c2cb5838f08036bca31765bad5e17edf900b2c7 \
11+
--hash=sha256:077d366e724f24fc02dbfe9d946534357fda71af9764ff99d73c3c596001bbd7 \
12+
--hash=sha256:10e88e7f41e6197ea0429ae18f21ff521d4f4490aa33048f6c6f94c6045a6a75 \
13+
--hash=sha256:18e961aa13b6d47f758cc5879383d27b5b3f3dcd9ce8cdbfdc2571fe86feb4dd \
14+
--hash=sha256:1a78b656a4d12b0490ca72651fe4d9f5e07e3c6461063a9b6265ee45eb2bdd35 \
15+
--hash=sha256:1ed4b95480952b1a26d863e546fa5094564aa0065e1e5f0d4d0041f293251d04 \
16+
--hash=sha256:23b27b8a698e749b61809fb637eb98ebf0e505710ec46a8aa6f1be7dc0dc43a6 \
17+
--hash=sha256:23f5881362dcb0e1a92b84b3c2809bdc90db892332daab81ad8f642d8ed55042 \
18+
--hash=sha256:32a8d985462e37cfdab611a6f95b09d7c091d07668fdc26e47a725ee575fe166 \
19+
--hash=sha256:3468cc8720402af37b6c6e7e2a9cdb9f6c16c728638a2ebc768ba1ef6f26c3a1 \
20+
--hash=sha256:379d4c7abad5afbe9d88cc31ea8ca262296480a86af945b08214eb1a556a3e4d \
21+
--hash=sha256:3cacfaefe6089d477264001f90f55b7881ba615953414999c46cc9713ff93c8c \
22+
--hash=sha256:3e3424c554391dc9ef4a92ad28665756566a28fecf47308f91841f6c49288e66 \
23+
--hash=sha256:46342fed0fff72efcda77040b14728049200cbba1279e0bf1188f1f2078c1d70 \
24+
--hash=sha256:536d609c6963c50055bab766d9951b6c394759190d03311f3e9fcf194ca909e1 \
25+
--hash=sha256:5d6850e6e36e332d5511a48a251790ddc545e16e8beaf046c03985c69ccb2676 \
26+
--hash=sha256:6008adeca04a445ea6ef31b2cbaf1d01d02986047606f7da266629afee982630 \
27+
--hash=sha256:64e723ca82a84053dd7bfcc986bdb34af8d9da83c521c19d6b472bc6880e191a \
28+
--hash=sha256:6b00e21f86598b6330f0019b40fb397e705135040dbedc2ca9a93c7441178e74 \
29+
--hash=sha256:6d224f0c4c9c98290a6990259073f496fcec1b5cc613eecbd22786d398ded3ad \
30+
--hash=sha256:6dceb61d40cbfcf45f51e59933c784a50846dc03211054bd76b421a713dcdf19 \
31+
--hash=sha256:7ac8f8eb153724f84885a1374999b7e45734bf93a87d8df1e7ce2146860edef6 \
32+
--hash=sha256:85ccc5fa54c2ed64bd91ed3b4a627b9cce04646a659512a051fa82a92c04a448 \
33+
--hash=sha256:869b5046d41abfea3e381dd143407b0d29b8282a904a19cb908fa24d090cc018 \
34+
--hash=sha256:8bdb0285a0202888d19ec6b6d23d5990410decb932b709f2b0dfe216d031d218 \
35+
--hash=sha256:8dfc5e195bbef80aabd81596ef52a1277ee7143fe419efc3c4d8ba2754671756 \
36+
--hash=sha256:8e738a492b6221f8dcf281b67129510835461132b03024830ac0e554311a5c54 \
37+
--hash=sha256:918440dea04521f499721c039863ef95433314b1db00ff826a02580c1f503e45 \
38+
--hash=sha256:9641e21670c68c7e57d2053ddf6c443e4f0a6e18e547e86af3fad0795414a628 \
39+
--hash=sha256:9d2f9d4cc2a53b38cabc2d6d80f7f9b7e3da26b2f53d48f05876fef7956b6968 \
40+
--hash=sha256:a07f61fc452c43cd5328b392e52555f7d1952400a1ad09086c4a8addccbd138d \
41+
--hash=sha256:a3277f5fa7483c927fe3a7b017b39351610265308f5267ac6d4c2b64cc1d8d25 \
42+
--hash=sha256:a4a3907011d39dbc3e37bdc5df0a8c93853c369039b59efa33a7b6669de04c60 \
43+
--hash=sha256:aeb2c2688ed93b027eb0d26aa188ada34acb22dceea256d76390eea135083950 \
44+
--hash=sha256:b094116f0b6155e36a304ff912f89bbb5067157aff5f94060ff20bbabdc8da06 \
45+
--hash=sha256:b8ffb498a83d7e0305968289441914154fb0ef5d8b3157df02a90c6695978295 \
46+
--hash=sha256:b9bb62fac84d5f2ff523304e59e5c439955fb3b7f44e3d7b2085184db74d733b \
47+
--hash=sha256:c61f66d93d712f6e03369b6a7769233bfda880b12f417eefdd4f16d1deb2fc4c \
48+
--hash=sha256:ca6e61dc52f601d1d224526360cdeab0d0712ec104a2ce6cc5ccef6ed9a233bc \
49+
--hash=sha256:ca7b26a5e456a843b9b6683eada193fc1f65c761b3a473941efe5a291f604c74 \
50+
--hash=sha256:d12c923757de24e4e2110cf8832d83a886a4cf215c6e61ed506006872b43a6d1 \
51+
--hash=sha256:d17bbc946f52ca67adf72a5ee783cd7cd3477f8f8796f59b4974a9b59cacc9ee \
52+
--hash=sha256:dfd1e1b9f0898817babf840b77ce9fe655ecbe8b1b327983df485b30df8cc011 \
53+
--hash=sha256:e0860a348bf7004c812c8368d1fc7f77fe8e4c095d661a579196a9533778e156 \
54+
--hash=sha256:f2f5968608b1fe2a1d00d01ad1017ee27efd99b3437e08b83ded9b7af3f6f766 \
55+
--hash=sha256:f3771b23bb3675a06f5d885c3630b1d01ea6cac9e84a01aaf5508706dba546c5 \
56+
--hash=sha256:f68ef3660677e6624c8cace943e4765545f8191313a07288a53d3da188bd8581 \
57+
--hash=sha256:f86f368e1c7ce897bf2457b9eb61169a44e2ef797099fb5728482b8d69f3f016 \
58+
--hash=sha256:f90515974b39f4dea2f27c0959688621b46d96d5a626cf9c53dbc653a895c05c \
59+
--hash=sha256:fe558371c1bdf3b8fa03e097c523fb9645b8730399c14fe7721ee9c9e2a545d3
60+
# via -r requirements.in
61+
iniconfig==2.0.0 \
62+
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
63+
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
64+
# via pytest
65+
packaging==23.2 \
66+
--hash=sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5 \
67+
--hash=sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7
68+
# via pytest
69+
pluggy==1.4.0 \
70+
--hash=sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981 \
71+
--hash=sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be
72+
# via pytest
73+
pytest==7.4.4 \
74+
--hash=sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280 \
75+
--hash=sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8
76+
# via
77+
# -r requirements.in
78+
# pytest-randomly
79+
pytest-randomly==3.15.0 \
80+
--hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \
81+
--hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047
82+
# via -r requirements.in
83+
python-dateutil==2.8.2 \
84+
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
85+
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
86+
# via -r requirements.in
87+
six==1.16.0 \
88+
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
89+
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
90+
# via python-dateutil

src/_time_machine.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
// Module state
66
typedef struct {
7+
#if PY_VERSION_HEX >= 0x030d00a4
8+
PyCFunctionFastWithKeywords original_now;
9+
#else
710
_PyCFunctionFastWithKeywords original_now;
11+
#endif
812
PyCFunction original_utcnow;
913
PyCFunction original_clock_gettime;
1014
PyCFunction original_clock_gettime_ns;
@@ -108,7 +112,11 @@ _time_machine_clock_gettime(PyObject *self, PyObject *args)
108112
PyObject *time_machine_module = PyImport_ImportModule("time_machine");
109113
PyObject *time_machine_clock_gettime = PyObject_GetAttrString(time_machine_module, "clock_gettime");
110114

115+
#if PY_VERSION_HEX >= 0x030d00a2
116+
PyObject* result = PyObject_CallOneArg(time_machine_clock_gettime, args);
117+
#else
111118
PyObject* result = PyObject_CallObject(time_machine_clock_gettime, args);
119+
#endif
112120

113121
Py_DECREF(time_machine_clock_gettime);
114122
Py_DECREF(time_machine_module);
@@ -142,7 +150,11 @@ _time_machine_clock_gettime_ns(PyObject *self, PyObject *args)
142150
PyObject *time_machine_module = PyImport_ImportModule("time_machine");
143151
PyObject *time_machine_clock_gettime_ns = PyObject_GetAttrString(time_machine_module, "clock_gettime_ns");
144152

153+
#if PY_VERSION_HEX >= 0x030d00a2
154+
PyObject* result = PyObject_CallOneArg(time_machine_clock_gettime_ns, args);
155+
#else
145156
PyObject* result = PyObject_CallObject(time_machine_clock_gettime_ns, args);
157+
#endif
146158

147159
Py_DECREF(time_machine_clock_gettime_ns);
148160
Py_DECREF(time_machine_module);
@@ -393,7 +405,11 @@ _time_machine_patch_if_needed(PyObject *module, PyObject *unused)
393405
PyObject *datetime_class = PyObject_GetAttrString(datetime_module, "datetime");
394406

395407
PyCFunctionObject *datetime_datetime_now = (PyCFunctionObject *) PyObject_GetAttrString(datetime_class, "now");
408+
#if PY_VERSION_HEX >= 0x030d00a4
409+
state->original_now = (PyCFunctionFastWithKeywords) datetime_datetime_now->m_ml->ml_meth;
410+
#else
396411
state->original_now = (_PyCFunctionFastWithKeywords) datetime_datetime_now->m_ml->ml_meth;
412+
#endif
397413
datetime_datetime_now->m_ml->ml_meth = (PyCFunction) _time_machine_now;
398414
Py_DECREF(datetime_datetime_now);
399415

@@ -478,8 +494,13 @@ PyDoc_STRVAR(module_doc, "_time_machine module");
478494
static PyMethodDef module_functions[] = {
479495
{"original_now", (PyCFunction)_time_machine_original_now, METH_FASTCALL|METH_KEYWORDS, original_now_doc},
480496
{"original_utcnow", (PyCFunction)_time_machine_original_utcnow, METH_NOARGS, original_utcnow_doc},
497+
#if PY_VERSION_HEX >= 0x030d00a2
498+
{"original_clock_gettime", (PyCFunction)_time_machine_original_clock_gettime, METH_O, original_clock_gettime_doc},
499+
{"original_clock_gettime_ns", (PyCFunction)_time_machine_original_clock_gettime_ns, METH_O, original_clock_gettime_ns_doc},
500+
#else
481501
{"original_clock_gettime", (PyCFunction)_time_machine_original_clock_gettime, METH_VARARGS, original_clock_gettime_doc},
482502
{"original_clock_gettime_ns", (PyCFunction)_time_machine_original_clock_gettime_ns, METH_VARARGS, original_clock_gettime_ns_doc},
503+
#endif
483504
{"original_gmtime", (PyCFunction)_time_machine_original_gmtime, METH_VARARGS, original_gmtime_doc},
484505
{"original_localtime", (PyCFunction)_time_machine_original_localtime, METH_VARARGS, original_localtime_doc},
485506
{"original_monotonic", (PyCFunction)_time_machine_original_monotonic, METH_NOARGS, original_monotonic_doc},

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
requires =
33
tox>=4.2
44
env_list =
5-
py{312, 311, 310, 39, 38}
5+
py{313, 312, 311, 310, 39, 38}
66

77
[testenv]
88
package = wheel

0 commit comments

Comments
 (0)