diff options
author | Stefan Krah <skrah@bytereef.org> | 2012-04-05 13:46:19 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2012-04-05 13:46:19 (GMT) |
commit | ff3eca0cc3c2b0e57079140af313682eecc5f4cc (patch) | |
tree | 1fb0ca20e28298b4c608843184a418c1fe999e94 /Modules/_decimal/_decimal.c | |
parent | 0774e9b9f57197380c796d36353344cb95ed07bf (diff) | |
download | cpython-ff3eca0cc3c2b0e57079140af313682eecc5f4cc.zip cpython-ff3eca0cc3c2b0e57079140af313682eecc5f4cc.tar.gz cpython-ff3eca0cc3c2b0e57079140af313682eecc5f4cc.tar.bz2 |
Allow printing a leading '-' and the maximum number of exponent digits
rather than raising RuntimeError (allocated space is sufficient for the
additional character).
Diffstat (limited to 'Modules/_decimal/_decimal.c')
-rw-r--r-- | Modules/_decimal/_decimal.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index ad3c3df..9ef564f 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -2435,8 +2435,8 @@ dectuple_as_str(PyObject *dectuple) if (sign_special[1] == '\0') { /* not a special number */ *cp++ = 'E'; - n = snprintf(cp, MPD_EXPDIGITS+1, "%" PRI_mpd_ssize_t, exp); - if (n < 0 || n >= MPD_EXPDIGITS+1) { + n = snprintf(cp, MPD_EXPDIGITS+2, "%" PRI_mpd_ssize_t, exp); + if (n < 0 || n >= MPD_EXPDIGITS+2) { PyErr_SetString(PyExc_RuntimeError, "internal error in dec_sequence_as_str"); goto error; |