diff -r 96a68e369d13 Doc/library/functions.rst --- a/Doc/library/functions.rst Mon Dec 09 20:33:33 2013 -0700 +++ b/Doc/library/functions.rst Tue Dec 10 12:29:08 2013 +0800 @@ -1178,8 +1178,8 @@ .. function:: round(number[, ndigits]) Return the floating point value *number* rounded to *ndigits* digits after - the decimal point. If *ndigits* is omitted, it defaults to zero. Delegates - to ``number.__round__(ndigits)``. + the decimal point. If *ndigits* is omitted, it returns the nearest integer + to its input. Delegates to ``number.__round__(ndigits)``. For the built-in types supporting :func:`round`, values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are diff -r 96a68e369d13 Lib/test/test_float.py --- a/Lib/test/test_float.py Mon Dec 09 20:33:33 2013 -0700 +++ b/Lib/test/test_float.py Tue Dec 10 12:29:08 2013 +0800 @@ -769,6 +769,14 @@ test(sfmt, NAN, ' nan') test(sfmt, -NAN, ' nan') + def test_None_ndigits(self): + for x in round(1.23), round(1.23, None), round(1.23, ndigits=None): + self.assertEqual(x, 1) + self.assertIsInstance(x, int) + for x in round(1.78), round(1.78, None), round(1.78, ndigits=None): + self.assertEqual(x, 2) + self.assertIsInstance(x, int) + # Beginning with Python 2.6 float has cross platform compatible # ways to create and represent inf and nan diff -r 96a68e369d13 Objects/floatobject.c --- a/Objects/floatobject.c Mon Dec 09 20:33:33 2013 -0700 +++ b/Objects/floatobject.c Tue Dec 10 12:29:08 2013 +0800 @@ -979,8 +979,9 @@ 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 */