aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-26 14:16:58 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-26 14:53:22 +0100
commita0f1df9610d692b4d4ee042dcc918f792bde5792 (patch)
treed68cb43e7d2d46b9805a5ead0f09f77fe2cf7e8a /sources/shiboken6
parent0e62a3d9903dd22391b769e0df0d37fdb9110d88 (diff)
Debug operators: Fix handling of longs exceeding long long max
Use PyLong_AsUnsignedLongLong if an overflow occurs. Use hex for those large values. Task-number: PYSIDE-2652 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I9c3404cf8b01b1fcda20516c1105797fc512ed53 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/libshiboken/helper.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp
index 01001dec5..23663433e 100644
--- a/sources/shiboken6/libshiboken/helper.cpp
+++ b/sources/shiboken6/libshiboken/helper.cpp
@@ -330,8 +330,15 @@ static void formatPyObjectHelper(PyObject *obj, std::ostream &str)
}
formatPyTypeObject(obj->ob_type, str, false);
str << ", ";
- if (PyLong_Check(obj))
- str << PyLong_AsLong(obj);
+ if (PyLong_Check(obj)) {
+ const auto llv = PyLong_AsLongLong(obj);
+ if (PyErr_Occurred() != PyExc_OverflowError) {
+ str << llv;
+ } else {
+ PyErr_Clear();
+ str << "0x" << std::hex << PyLong_AsUnsignedLongLong(obj) << std::dec;
+ }
+ }
else if (PyFloat_Check(obj))
str << PyFloat_AsDouble(obj);
else if (PyUnicode_Check(obj))