From 656f94c76badf6a179ba23bf849bfe22319e488d Mon Sep 17 00:00:00 2001 From: Elephant Liu Date: Mon, 7 Jul 2025 17:24:25 +0800 Subject: [PATCH 1/3] chore: upgrade cython to latest version --- libmc/_client.pyx | 6 +++++- setup.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libmc/_client.pyx b/libmc/_client.pyx index 1bfd7f71..f44d411a 100644 --- a/libmc/_client.pyx +++ b/libmc/_client.pyx @@ -8,7 +8,11 @@ from libcpp.string cimport string from libcpp.vector cimport vector from cpython.mem cimport PyMem_Malloc, PyMem_Free from cpython.version cimport PY_MAJOR_VERSION -from cpython cimport Py_INCREF, Py_DECREF, PyInt_AsLong, PyInt_FromLong +from cpython cimport ( + Py_INCREF, Py_DECREF, + PyLong_AsLong as PyInt_AsLong, + PyLong_FromLong as PyInt_FromLong, +) if PY_MAJOR_VERSION < 3: from cpython cimport PyString_AsStringAndSize, PyString_AsString diff --git a/setup.py b/setup.py index 21d0e801..1d3b789e 100644 --- a/setup.py +++ b/setup.py @@ -100,7 +100,7 @@ def find_version(*file_paths): "Topic :: Software Development :: Libraries", ], # Support for the basestring type is new in Cython 0.20. - setup_requires=["Cython >= 0.20, < 3.1"], + setup_requires=["Cython >= 0.20"], ext_modules=[ Extension( "libmc._client", From 2312ddd2462764d7eadaad4ec43750d202f55a78 Mon Sep 17 00:00:00 2001 From: Elephant Liu Date: Mon, 7 Jul 2025 17:25:56 +0800 Subject: [PATCH 2/3] fix --- libmc/_client.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/libmc/_client.pyx b/libmc/_client.pyx index f44d411a..d0123411 100644 --- a/libmc/_client.pyx +++ b/libmc/_client.pyx @@ -13,6 +13,7 @@ from cpython cimport ( PyLong_AsLong as PyInt_AsLong, PyLong_FromLong as PyInt_FromLong, ) +from ctypes import c_long as long if PY_MAJOR_VERSION < 3: from cpython cimport PyString_AsStringAndSize, PyString_AsString From 1b19ea2beda1a8bf3701e9d351ce5d64401cfe45 Mon Sep 17 00:00:00 2001 From: Elephant Liu Date: Mon, 7 Jul 2025 17:28:58 +0800 Subject: [PATCH 3/3] fix --- libmc/_client.pyx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libmc/_client.pyx b/libmc/_client.pyx index d0123411..476d61b9 100644 --- a/libmc/_client.pyx +++ b/libmc/_client.pyx @@ -12,16 +12,12 @@ from cpython cimport ( Py_INCREF, Py_DECREF, PyLong_AsLong as PyInt_AsLong, PyLong_FromLong as PyInt_FromLong, + PyBytes_AsStringAndSize as PyString_AsStringAndSize, + PyBytes_AsString as PyString_AsString, + PyUnicode_AsUTF8String, ) from ctypes import c_long as long -if PY_MAJOR_VERSION < 3: - from cpython cimport PyString_AsStringAndSize, PyString_AsString - import cPickle as pickle -else: - from cpython cimport PyBytes_AsStringAndSize as PyString_AsStringAndSize, PyBytes_AsString as PyString_AsString, PyUnicode_AsUTF8String - import pickle - import os import sys import traceback @@ -29,6 +25,7 @@ import threading import zlib import marshal import warnings +import pickle from contextlib import contextmanager cdef extern from "Common.h" namespace "douban::mc":