mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-04-10 00:02:41 +02:00
111 lines
3.8 KiB
Diff
111 lines
3.8 KiB
Diff
From 55b3be5234f1c670b0c7d3f3a1584af2573d9288 Mon Sep 17 00:00:00 2001
|
|
From: Mykola Golub <mgolub@suse.com>
|
|
Date: Sun, 3 Dec 2023 09:37:02 +0000
|
|
Subject: [PATCH 1/2] test/pybind/rbd: test callbacks raising exceptions
|
|
|
|
Signed-off-by: Mykola Golub <mgolub@suse.com>
|
|
---
|
|
src/test/pybind/test_rbd.py | 22 ++++++++++++++++++++++
|
|
1 file changed, 22 insertions(+)
|
|
|
|
diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py
|
|
index 7b5f31b577a61..0ce3c0dd90caa 100644
|
|
--- a/src/test/pybind/test_rbd.py
|
|
+++ b/src/test/pybind/test_rbd.py
|
|
@@ -415,6 +415,18 @@ def progress_cb(current, total):
|
|
assert_raises(OperationCanceled, RBD().remove, ioctx, image_name,
|
|
on_progress=progress_cb)
|
|
|
|
+def test_remove_with_progress_except():
|
|
+ create_image()
|
|
+ d = {'received_callback': False}
|
|
+ def progress_cb(current, total):
|
|
+ d['received_callback'] = True
|
|
+ raise Exception()
|
|
+
|
|
+ # exception is logged and ignored with a Cython warning:
|
|
+ # Exception ignored in: 'rbd.progress_callback'
|
|
+ RBD().remove(ioctx, image_name, on_progress=progress_cb)
|
|
+ eq(True, d['received_callback'])
|
|
+
|
|
def test_rename(tmp_image):
|
|
rbd = RBD()
|
|
image_name2 = get_temp_image_name()
|
|
@@ -1251,6 +1263,16 @@ def cb(_, buf):
|
|
assert(comp.get_return_value() < 0)
|
|
eq(sys.getrefcount(comp), 2)
|
|
|
|
+ # test3: except case
|
|
+ def cbex(_, buf):
|
|
+ raise KeyError()
|
|
+
|
|
+ def test3():
|
|
+ comp = self.image.aio_read(IMG_SIZE, 20, cbex)
|
|
+ comp.wait_for_complete_and_cb()
|
|
+
|
|
+ assert_raises(KeyError, test3)
|
|
+
|
|
def test_aio_write(self):
|
|
retval = [None]
|
|
def cb(comp):
|
|
|
|
From e3156050d0ce9b504ee40d30e98f49a860b7dde5 Mon Sep 17 00:00:00 2001
|
|
From: Mykola Golub <mgolub@suse.com>
|
|
Date: Mon, 4 Dec 2023 09:38:56 +0000
|
|
Subject: [PATCH 2/2] pybind/rbd: make cdef functions not propagate exceptions
|
|
by default
|
|
|
|
Setting legacy_implicit_noexcept compiler directive to True will cause
|
|
Cython 3.0 to have the same semantics as Cython 0.x.
|
|
|
|
Fixes: https://tracker.ceph.com/issues/62140
|
|
Signed-off-by: Mykola Golub <mgolub@suse.com>
|
|
---
|
|
src/pybind/rbd/setup.py | 14 +++++++++++++-
|
|
1 file changed, 13 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py
|
|
index 1f20c3ed42fe6..eeb33c73d49b3 100755
|
|
--- a/src/pybind/rbd/setup.py
|
|
+++ b/src/pybind/rbd/setup.py
|
|
@@ -14,6 +14,7 @@
|
|
from distutils.ccompiler import new_compiler
|
|
from distutils.errors import CompileError, LinkError
|
|
from itertools import filterfalse, takewhile
|
|
+from packaging import version
|
|
import distutils.sysconfig
|
|
|
|
|
|
@@ -148,11 +149,22 @@ def check_sanity():
|
|
sys.exit(1)
|
|
|
|
cmdclass = {}
|
|
+compiler_directives={'language_level': sys.version_info.major}
|
|
try:
|
|
from Cython.Build import cythonize
|
|
from Cython.Distutils import build_ext
|
|
+ from Cython import __version__ as cython_version
|
|
|
|
cmdclass = {'build_ext': build_ext}
|
|
+
|
|
+ # Needed for building with Cython 0.x and Cython 3 from the same file,
|
|
+ # preserving the same behavior.
|
|
+ # When Cython 0.x builds go away, replace this compiler directive with
|
|
+ # noexcept on rbd_callback_t and librbd_progress_fn_t (or consider doing
|
|
+ # something similar to except? -9000 on rbd_diff_iterate2() callback for
|
|
+ # progress callbacks to propagate exceptions).
|
|
+ if version.parse(cython_version) >= version.parse('3'):
|
|
+ compiler_directives['legacy_implicit_noexcept'] = True
|
|
except ImportError:
|
|
print("WARNING: Cython is not installed.")
|
|
|
|
@@ -197,7 +209,7 @@ def cythonize(x, **kwargs):
|
|
**ext_args
|
|
)
|
|
],
|
|
- compiler_directives={'language_level': sys.version_info.major},
|
|
+ compiler_directives=compiler_directives,
|
|
build_dir=os.environ.get("CYTHON_BUILD_DIR", None),
|
|
**cythonize_args
|
|
),
|