diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 566f22ba33b228e..99546c42688d3d7 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3571,6 +3571,7 @@ dec_as_long(PyObject *dec, PyObject *context, int round) mpd_t *x; mpd_context_t workctx; uint32_t status = 0; + const PyLongLayout *layout = PyLong_GetNativeLayout(); if (mpd_isspecial(MPD(dec))) { if (mpd_isnan(MPD(dec))) { @@ -3599,8 +3600,9 @@ dec_as_long(PyObject *dec, PyObject *context, int round) status = 0; n = (mpd_sizeinbase(x, 2) + - PyLong_LAYOUT.bits_per_digit - 1) / PyLong_LAYOUT.bits_per_digit; - PyLongWriter *writer = PyLongWriter_Create(mpd_isnegative(x), n, &ob_digit); + layout->bits_per_digit - 1) / layout->bits_per_digit; + PyLongWriter *writer = PyLongWriter_Create(mpd_isnegative(x), n, + &ob_digit, layout); /* mpd_sizeinbase can overestimate size by 1 digit, set it to zero. */ ob_digit[n-1] = 0; if (writer == NULL) {