Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 3.13 support #703

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ 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

- 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: |
Expand Down Expand Up @@ -80,7 +83,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-*"
Copy link

@LecrisUT LecrisUT Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually pypa/cibuildwheel minor version takes care of adding and removing EOL and new python versions. I think there is some handling for pre-release but don't remember how.

Could consider moving these to the pyproject.toml to make it more easily reproducible and removing the explicit CIBW_BUILD?

(Not in this PR, but a subsequent one when python 3.13 is working)

CIBW_SKIP: "*-win32 *_i686 *_s390x *_ppc64le"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_LINUX: "x86_64 aarch64"
Expand Down
13 changes: 10 additions & 3 deletions msgspec/_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not declaring int out anymore.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…and passing one argument too many in both branches.

#else
out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0, 0);
#endif
Py_DECREF(int128);
return out;
}

static PyObject *
Expand Down