From 090aa40e2b318b50a0078132e0c4b76a6492aceb Mon Sep 17 00:00:00 2001 From: Martin Ahrnbom Date: Sat, 26 Apr 2025 00:14:24 +0200 Subject: [PATCH] Fix https://github.com/jcrist/msgspec/issues/799 --- msgspec/_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/msgspec/_core.c b/msgspec/_core.c index 147ad95a..75166bf3 100644 --- a/msgspec/_core.c +++ b/msgspec/_core.c @@ -13768,7 +13768,10 @@ static MS_NOINLINE int json_encode_dict_key_noinline(EncoderState *self, PyObject *obj) { PyTypeObject *type = Py_TYPE(obj); - if (type == &PyLong_Type) { + if (type == &PyUnicode_Type) { + return json_encode_str(self, obj); + } + else if (type == &PyLong_Type) { return json_encode_long_as_str(self, obj); } else if (type == &PyFloat_Type) {