Skip to content

Commit

Permalink
pythongh-105375: Improve _decimal error handling (pythonGH-105605)
Browse files Browse the repository at this point in the history
Fix a bug where an exception could end up being overwritten.
(cherry picked from commit c932f72)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
erlend-aasland authored and miss-islington committed Jun 11, 2023
1 parent aaa8a49 commit e25225f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug in :mod:`decimal` where an exception could end up being overwritten.
6 changes: 5 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit e25225f

Please sign in to comment.