From a0cc7ea1c94274e112c8918557b9d9a0979f3503 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Sun, 13 Oct 2024 13:59:00 -0500 Subject: [PATCH] Use PyLong_AsNativeBytes on Py3.13 --- msgspec/_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/msgspec/_core.c b/msgspec/_core.c index 9749608e..738546e6 100644 --- a/msgspec/_core.c +++ b/msgspec/_core.c @@ -11265,7 +11265,12 @@ ms_uuid_to_16_bytes(MsgspecState *mod, PyObject *obj, unsigned char *buf) { return -1; } #if PY313_PLUS - int out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0, 1); + int out = (int)PyLong_AsNativeBytes( + int128, + buf, + 16, + Py_ASNATIVEBYTES_BIG_ENDIAN | Py_ASNATIVEBYTES_UNSIGNED_BUFFER + ); #else int out = _PyLong_AsByteArray((PyLongObject *)int128, buf, 16, 0, 0); #endif