From 5c03ff7cbb4a6d0b30b626090b66243af13ebae3 Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:45:56 -0500 Subject: [PATCH 1/4] Support 3.13 --- msgspec/_core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/msgspec/_core.c b/msgspec/_core.c index 0f287814..71762b35 100644 --- a/msgspec/_core.c +++ b/msgspec/_core.c @@ -20,6 +20,7 @@ #define PY310_PLUS (PY_VERSION_HEX >= 0x030a0000) #define PY311_PLUS (PY_VERSION_HEX >= 0x030b0000) #define PY312_PLUS (PY_VERSION_HEX >= 0x030c0000) +#define PY313_PLUS (PY_VERSION_HEX >= 0x030d0000) /* Hint to the compiler not to store `x` in a register since it is likely to * change. Results in much higher performance on GCC, with smaller benefits on @@ -11255,9 +11256,15 @@ ms_uuid_to_16_bytes(MsgspecState *mod, PyObject *obj, unsigned char *buf) { PyErr_SetString(PyExc_TypeError, "uuid.int must be an int"); return -1; } - int out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0); - Py_DECREF(int128); - return out; + #if PY313_PLUS + // Python 3.13 adds an extra argument to control wether to throw an error on overflow. + // This happens by default in older versions, so simply match the behavior. + out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0, 0, 1); + #else + out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0, 0); + #endif + Py_DECREF(int128); + return out; } static PyObject * From 5c89505dae6a815dcc106b3f045d31d1ebe68ddb Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:50:22 -0500 Subject: [PATCH 2/4] Add 3.13 to wheels build --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f0839f0..716c8f39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: env: CIBW_TEST_REQUIRES: "pytest msgpack pyyaml tomli tomli_w" CIBW_TEST_COMMAND: "pytest {project}/tests" - CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp13-*" CIBW_SKIP: "*-win32 *_i686 *_s390x *_ppc64le" CIBW_ARCHS_MACOS: "x86_64 arm64" CIBW_ARCHS_LINUX: "x86_64 aarch64" From 32190fa599acc0a5c60abe85fbbf2b7935b64fd8 Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:15:22 -0500 Subject: [PATCH 3/4] grammar --- msgspec/_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msgspec/_core.c b/msgspec/_core.c index 71762b35..fa194f16 100644 --- a/msgspec/_core.c +++ b/msgspec/_core.c @@ -11257,7 +11257,7 @@ ms_uuid_to_16_bytes(MsgspecState *mod, PyObject *obj, unsigned char *buf) { return -1; } #if PY313_PLUS - // Python 3.13 adds an extra argument to control wether to throw an error on overflow. + // Python 3.13 adds an extra argument to control whether to throw an error on overflow. // This happens by default in older versions, so simply match the behavior. out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0, 0, 1); #else From 443d92fa2259430bc21b3fe2e7c50e5609605f0d Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:20:05 -0500 Subject: [PATCH 4/4] Add to testing matrix --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 716c8f39..e23e32d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,9 @@ jobs: lint: name: Lint and ruff code runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v2 @@ -25,7 +28,7 @@ jobs: - name: Install Python uses: actions/setup-python@v2 with: - python-version: "3.11" + python-version: ${{ matrix.python-version }} - name: Build msgspec and install dependencies run: |