Skip to content

Commit 59865e7

Browse files
Issue #26200: Restored more safe usages of Py_SETREF.
2 parents a29f720 + 864b63c commit 59865e7

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

Modules/_decimal/_decimal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,14 +3439,14 @@ dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
34393439
goto error;
34403440
}
34413441

3442-
Py_XSETREF(exponent, long_methods->nb_power(tmp, exponent, Py_None));
3442+
Py_SETREF(exponent, long_methods->nb_power(tmp, exponent, Py_None));
34433443
Py_DECREF(tmp);
34443444
if (exponent == NULL) {
34453445
goto error;
34463446
}
34473447

34483448
if (exp >= 0) {
3449-
Py_XSETREF(numerator, long_methods->nb_multiply(numerator, exponent));
3449+
Py_SETREF(numerator, long_methods->nb_multiply(numerator, exponent));
34503450
if (numerator == NULL) {
34513451
goto error;
34523452
}
@@ -3462,8 +3462,8 @@ dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
34623462
if (tmp == NULL) {
34633463
goto error;
34643464
}
3465-
Py_XSETREF(numerator, long_methods->nb_floor_divide(numerator, tmp));
3466-
Py_XSETREF(denominator, long_methods->nb_floor_divide(denominator, tmp));
3465+
Py_SETREF(numerator, long_methods->nb_floor_divide(numerator, tmp));
3466+
Py_SETREF(denominator, long_methods->nb_floor_divide(denominator, tmp));
34673467
Py_DECREF(tmp);
34683468
if (numerator == NULL || denominator == NULL) {
34693469
goto error;

Modules/_functoolsmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ partial_setstate(partialobject *pto, PyObject *state)
294294
else
295295
Py_INCREF(dict);
296296

297-
Py_XSETREF(pto->fn, fn);
298-
Py_XSETREF(pto->args, fnargs);
299-
Py_XSETREF(pto->kw, kw);
297+
Py_SETREF(pto->fn, fn);
298+
Py_SETREF(pto->args, fnargs);
299+
Py_SETREF(pto->kw, kw);
300300
Py_XSETREF(pto->dict, dict);
301301
Py_RETURN_NONE;
302302
}

Objects/floatobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,13 +1494,13 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
14941494

14951495
/* fold in 2**exponent */
14961496
if (exponent > 0) {
1497-
Py_XSETREF(numerator,
1497+
Py_SETREF(numerator,
14981498
long_methods->nb_lshift(numerator, py_exponent));
14991499
if (numerator == NULL)
15001500
goto error;
15011501
}
15021502
else {
1503-
Py_XSETREF(denominator,
1503+
Py_SETREF(denominator,
15041504
long_methods->nb_lshift(denominator, py_exponent));
15051505
if (denominator == NULL)
15061506
goto error;

0 commit comments

Comments
 (0)