Skip to content

Commit 5764614

Browse files
committed
address review: add asserts
1 parent 021ab8e commit 5764614

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Modules/_decimal/_decimal.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,12 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v,
23402340
const uint8_t sign = export_long.negative ? MPD_NEG : MPD_POS;
23412341
const Py_ssize_t len = export_long.ndigits;
23422342

2343-
if (base > UINT16_MAX) {
2343+
assert(layout->bits_per_digit <= 32);
2344+
assert(layout->digits_order == -1);
2345+
assert(layout->digit_endianness == (PY_LITTLE_ENDIAN ? -1 : 1));
2346+
assert(layout->digit_size == 2 || layout->digit_size == 4);
2347+
2348+
if (layout->digit_size == 4) {
23442349
mpd_qimport_u32(MPD(dec), export_long.digits, len, sign,
23452350
base, ctx, status);
23462351
}

0 commit comments

Comments
 (0)