diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-04-15 20:10:59 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-04-15 20:10:59 (GMT) |
commit | cb39d1f466eeecbec969f50a5df609eb0a863084 (patch) | |
tree | cd4fd87d2cc51a15730a5e061075a5da8e069b9b /Objects | |
parent | 807b80d4ec9d9dd2c0f5e6a4bf07caa7c90625e1 (diff) | |
download | cpython-cb39d1f466eeecbec969f50a5df609eb0a863084.zip cpython-cb39d1f466eeecbec969f50a5df609eb0a863084.tar.gz cpython-cb39d1f466eeecbec969f50a5df609eb0a863084.tar.bz2 |
Issue 19933: Provide default argument for ndigits in round. Patch by Vajrasky Kok.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 1d369f9..d681981 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -986,8 +986,9 @@ float_round(PyObject *v, PyObject *args) x = PyFloat_AsDouble(v); if (!PyArg_ParseTuple(args, "|O", &o_ndigits)) return NULL; - if (o_ndigits == NULL) { - /* single-argument round: round to nearest integer */ + if (o_ndigits == NULL || o_ndigits == Py_None) { + /* single-argument round or with None ndigits: + * round to nearest integer */ rounded = round(x); if (fabs(x-rounded) == 0.5) /* halfway case: round to even */ |