mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
[3.11] gh-105375: Improve _decimal error handling (GH-105605) (#105648)
Fix a bug where an exception could end up being overwritten.
(cherry picked from commit c932f72849
)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
cfa0f7c59b
commit
cb26fafdcc
2 changed files with 6 additions and 1 deletions
|
@ -0,0 +1 @@
|
|||
Fix bug in :mod:`decimal` where an exception could end up being overwritten.
|
|
@ -3658,9 +3658,13 @@ dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
|
|||
goto error;
|
||||
}
|
||||
Py_SETREF(numerator, _py_long_floor_divide(numerator, tmp));
|
||||
if (numerator == NULL) {
|
||||
Py_DECREF(tmp);
|
||||
goto error;
|
||||
}
|
||||
Py_SETREF(denominator, _py_long_floor_divide(denominator, tmp));
|
||||
Py_DECREF(tmp);
|
||||
if (numerator == NULL || denominator == NULL) {
|
||||
if (denominator == NULL) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue