aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-05-14 16:36:34 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-05-16 10:29:48 +0200
commita9412347da9333ea8a0cfcbd55aca8f82c2cb481 (patch)
tree486fc7b22a5cd9aebdb1c2baf75b02f4e5e24580 /sources/pyside6/PySide6
parentf37e2101be92998ca4d01d37db4af877a39c1dd0 (diff)
Python 3.12: Avoid issues with reference counting of immortal Python types
Use the PY_RETURN_* macros for returning them. Pick-to: 6.7 6.5 Task-number: PYSIDE-2747 Change-Id: I48db8b958925e6ae39ce8ae8fb926429d0e4cd02 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6')
-rw-r--r--sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp5
-rw-r--r--sources/pyside6/PySide6/glue/qtcore.cpp6
2 files changed, 6 insertions, 5 deletions
diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
index 52a45e026..ca3dfebed 100644
--- a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
+++ b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
@@ -49,7 +49,10 @@ static void QtQml_VolatileBoolObject_dealloc(PyObject *self)
static PyObject *
QtQml_VolatileBoolObject_get(QtQml_VolatileBoolObject *self)
{
- return *self->flag ? Py_True : Py_False;
+ if (*self->flag) {
+ Py_RETURN_TRUE;
+ }
+ Py_RETURN_FALSE;
}
static PyObject *
diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp
index a8afc9b6a..fc2fe7a58 100644
--- a/sources/pyside6/PySide6/glue/qtcore.cpp
+++ b/sources/pyside6/PySide6/glue/qtcore.cpp
@@ -84,11 +84,9 @@ static PyObject *convertToPrimitiveType(const QVariant &out, int metaTypeId)
return PyFloat_FromDouble(out.toFloat());
case QMetaType::Bool:
if (out.toBool()) {
- Py_INCREF(Py_True);
- return Py_True;
+ Py_RETURN_TRUE;
}
- Py_INCREF(Py_False);
- return Py_False;
+ Py_RETURN_FALSE;
default:
break;
}