aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtgui.cpp')
-rw-r--r--sources/pyside6/PySide6/glue/qtgui.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp
index 5c860a2bf..aacac3508 100644
--- a/sources/pyside6/PySide6/glue/qtgui.cpp
+++ b/sources/pyside6/PySide6/glue/qtgui.cpp
@@ -310,9 +310,10 @@ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
// @snippet qtextline-cursortox
// @snippet qkeysequence-getitem
-if (_i < 0 || _i >= %CPPSELF.count()) {
- PyErr_SetString(PyExc_IndexError, "index out of bounds");
- return 0;
+const Py_ssize_t size = %CPPSELF.count();
+if (_i < 0 || _i >= size) {
+ Shiboken::Errors::setIndexOutOfBounds(_i, 0, size);
+ return nullptr;
}
QKeyCombination item = (*%CPPSELF)[_i];
return %CONVERTTOPYTHON[QKeyCombination](item);
@@ -912,8 +913,11 @@ return %CPPSELF.rectCount();
// @snippet qregion-len
// @snippet qregion-getitem
-if (_i < 0 || _i >= %CPPSELF.rectCount())
- return PyErr_Format(PyExc_IndexError, "index out of bounds");
+const Py_ssize_t size = %CPPSELF.rectCount();
+if (_i < 0 || _i >= size) {
+ Shiboken::Errors::setIndexOutOfBounds(_i, 0, size);
+ return nullptr;
+}
const QRect cppResult = *(%CPPSELF.cbegin() + _i);
return %CONVERTTOPYTHON[QRect](cppResult);