Skip to content

Commit 34a84d3

Browse files
committed
clear exceptions in PyLong_AsLong...AndOverflow
1 parent 07a3170 commit 34a84d3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

graalpython/com.oracle.graal.python.cext/src/longobject_shared.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow) {
7373
return -1;
7474
}
7575
long result = GraalPyTruffleLong_AsPrimitive(obj, MODE_COERCE_SIGNED, sizeof(long));
76-
*overflow = result == -1L && PyErr_Occurred() != NULL;
76+
if (result == -1L && PyErr_Occurred() != NULL) {
77+
PyErr_Clear();
78+
*overflow = 1;
79+
} else {
80+
*overflow = 0;
81+
}
7782
return result;
7883
}
7984

@@ -87,7 +92,12 @@ long long PyLong_AsLongLong(PyObject *obj) {
8792

8893
long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow) {
8994
long long result = PyLong_AsLongLong(obj);
90-
*overflow = result == -1L && PyErr_Occurred() != NULL;
95+
if (result == -1L && PyErr_Occurred() != NULL) {
96+
PyErr_Clear();
97+
*overflow = 1;
98+
} else {
99+
*overflow = 0;
100+
}
91101
return result;
92102
}
93103

0 commit comments

Comments
 (0)