diff --git a/py313-support.patch b/py313-support.patch new file mode 100644 index 0000000..1790a6a --- /dev/null +++ b/py313-support.patch @@ -0,0 +1,46 @@ +From 206a3754466397baeb418e70be9d35b12cc4079f Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 4 Sep 2024 19:09:04 +0200 +Subject: [PATCH] Fix build with Python 3.13+ +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Avoid using PyObject_AsReadBuffer, do what PyObject_AsReadBuffer does. + +Note that this is not safe, and it has never been safe, +but the code does *exactly* what it used to do (at least on Python 3.8+). + +Fixes https://github.com/jnwatson/py-lmdb/issues/362 + +Co-Authored-By: Miro Hrončok +--- + lmdb/cpython.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/lmdb/cpython.c b/lmdb/cpython.c +index 3030883..81fdb06 100644 +--- a/lmdb/cpython.c ++++ b/lmdb/cpython.c +@@ -545,9 +545,21 @@ val_from_buffer(MDB_val *val, PyObject *buf) + type_error("Won't implicitly convert Unicode to bytes; use .encode()"); + return -1; + } ++#if PY_VERSION_HEX < 0x030d0000 + return PyObject_AsReadBuffer(buf, + (const void **) &val->mv_data, + (Py_ssize_t *) &val->mv_size); ++#else ++ Py_buffer view; ++ int ret; ++ ret = PyObject_GetBuffer(buf, &view, PyBUF_SIMPLE); ++ if(ret == 0) { ++ val->mv_data = view.buf; ++ val->mv_size = view.len; ++ PyBuffer_Release(&view); ++ } ++ return ret; ++#endif + } + + /* ------------------- */ diff --git a/python-lmdb.changes b/python-lmdb.changes index 2ae95e3..931f374 100644 --- a/python-lmdb.changes +++ b/python-lmdb.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Nov 19 10:20:27 UTC 2024 - Dirk Müller + +- add py313-support.patch to fix build with py313 + ------------------------------------------------------------------- Mon Jul 1 16:53:38 UTC 2024 - Mia Herkt @@ -12,7 +17,7 @@ Thu Apr 6 16:05:15 UTC 2023 - Mia Herkt ------------------------------------------------------------------- Tue Dec 13 15:43:15 UTC 2022 - Yogalakshmi Arunachalam -- Update to v1.4.0 +- Update to v1.4.0 * Update manifest and a copyright ------------------------------------------------------------------- diff --git a/python-lmdb.spec b/python-lmdb.spec index a6c2320..20f94af 100644 --- a/python-lmdb.spec +++ b/python-lmdb.spec @@ -24,6 +24,7 @@ License: OLDAP-2.8 Group: Development/Languages/Python URL: https://github.com/dw/py-lmdb/ Source: https://files.pythonhosted.org/packages/source/l/lmdb/lmdb-%{version}.tar.gz +Patch1: https://github.com/jnwatson/py-lmdb/pull/368/commits/206a3754466397baeb418e70be9d35b12cc4079f.patch#/py313-support.patch BuildRequires: %{python_module cffi} BuildRequires: %{python_module devel} BuildRequires: %{python_module pytest} @@ -52,7 +53,7 @@ LMDB is a tiny database with the following properties: LMDB uses the operating system’s buffer cache. %prep -%setup -q -n lmdb-%{version} +%autosetup -p1 -n lmdb-%{version} %build export LMDB_FORCE_SYSTEM=1