aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-08-02 13:16:47 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-08-02 20:53:04 +0200
commit1b0134fd104cb710bc9d619c22fd0bacc0832c05 (patch)
tree7c22ce8c8bec9a4058033500fed9d8c2382b9610 /sources/shiboken6/tests/libsample
parentbc7face18376b52e99079d633da610adc5cc57ef (diff)
shiboken6: Propagate exceptions through return value ownership modifications
The code for modifying return value ownership clears errors set by PyErr_SetString(). To work around this, store the error type and the message in variables and set the error at the end of the code block. Fixes: PYSIDE-1995 Change-Id: I45816197117a3b409fd549e89d57f7b9f0eac458 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/tests/libsample')
-rw-r--r--sources/shiboken6/tests/libsample/exceptiontest.cpp7
-rw-r--r--sources/shiboken6/tests/libsample/exceptiontest.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsample/exceptiontest.cpp b/sources/shiboken6/tests/libsample/exceptiontest.cpp
index 35da4e90b..56144e086 100644
--- a/sources/shiboken6/tests/libsample/exceptiontest.cpp
+++ b/sources/shiboken6/tests/libsample/exceptiontest.cpp
@@ -37,3 +37,10 @@ void ExceptionTest::voidThrowInt(bool doThrow)
if (doThrow)
throw 42;
}
+
+ExceptionTest *ExceptionTest::create(bool doThrow)
+{
+ if (doThrow)
+ throw TestException();
+ return new ExceptionTest;
+}
diff --git a/sources/shiboken6/tests/libsample/exceptiontest.h b/sources/shiboken6/tests/libsample/exceptiontest.h
index 4931fc2ed..b5812a090 100644
--- a/sources/shiboken6/tests/libsample/exceptiontest.h
+++ b/sources/shiboken6/tests/libsample/exceptiontest.h
@@ -18,6 +18,8 @@ class LIBSAMPLE_API ExceptionTest
int intThrowInt(bool doThrow);
void voidThrowInt(bool doThrow);
+
+ static ExceptionTest *create(bool doThrow);
};
#endif // EXCEPTIONTEST_H