diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-11-24 10:54:58 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-11-24 10:54:58 (GMT) |
commit | bce783757ff5398280fc06efc2e0e951ec022d21 (patch) | |
tree | a993309641944c618f3b7f64f174f5b151f7307d /Python | |
parent | 9dd5e16c5d8e7d9e7fa9c2fb1b2754df8161ab2b (diff) | |
download | cpython-bce783757ff5398280fc06efc2e0e951ec022d21.zip cpython-bce783757ff5398280fc06efc2e0e951ec022d21.tar.gz cpython-bce783757ff5398280fc06efc2e0e951ec022d21.tar.bz2 |
round(0, "ermintrude") succeeded instead of producing a TypeError. Fix this.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a8d8d97..80fc9b4 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2130,10 +2130,6 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds) kwlist, &x, &o_ndigits)) return NULL; - /* nans, infinities and zeros round to themselves */ - if (!Py_IS_FINITE(x) || x == 0.0) - return PyFloat_FromDouble(x); - if (o_ndigits == NULL) { /* second argument defaults to 0 */ ndigits = 0; @@ -2145,6 +2141,10 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds) return NULL; } + /* nans, infinities and zeros round to themselves */ + if (!Py_IS_FINITE(x) || x == 0.0) + return PyFloat_FromDouble(x); + /* Deal with extreme values for ndigits. For ndigits > NDIGITS_MAX, x always rounds to itself. For ndigits < NDIGITS_MIN, x always rounds to +-0.0. Here 0.30103 is an upper bound for log10(2). */ |