summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_decimal')
-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 15c64e2..996f9da 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -2364,6 +2364,7 @@ dectuple_as_str(PyObject *dectuple)
long sign, l;
mpd_ssize_t exp = 0;
Py_ssize_t i, mem, tsize;
+ int is_infinite = 0;
int n;
assert(PyTuple_Check(dectuple));
@@ -2399,6 +2400,7 @@ dectuple_as_str(PyObject *dectuple)
/* special */
if (PyUnicode_CompareWithASCIIString(tmp, "F") == 0) {
strcat(sign_special, "Inf");
+ is_infinite = 1;
}
else if (PyUnicode_CompareWithASCIIString(tmp, "n") == 0) {
strcat(sign_special, "NaN");
@@ -2470,6 +2472,11 @@ dectuple_as_str(PyObject *dectuple)
"coefficient must be a tuple of digits");
goto error;
}
+ if (is_infinite) {
+ /* accept but ignore any well-formed coefficient for compatibility
+ with decimal.py */
+ continue;
+ }
*cp++ = (char)l + '0';
}
*cp = '\0';