summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal/_decimal.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_decimal/_decimal.c')
-rw-r--r--Modules/_decimal/_decimal.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 7fc7315..35a1156 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3394,6 +3394,13 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
return NULL;
}
+ if (n == 1) {
+ sdigit val = mpd_arith_sign(x) * ob_digit[0];
+ mpd_free(ob_digit);
+ mpd_del(x);
+ return PyLong_FromLong(val);
+ }
+
assert(n > 0);
pylong = _PyLong_New(n);
if (pylong == NULL) {