diff -r 5358ee70f831 Lib/test/test_descr.py --- a/Lib/test/test_descr.py Sat Apr 13 17:46:04 2013 +0100 +++ b/Lib/test/test_descr.py Sat Apr 13 21:01:52 2013 +0100 @@ -1784,6 +1784,7 @@ ("__exit__", run_context, swallow, set(), {"__enter__" : iden}), ("__complex__", complex, complex_num, set(), {}), ("__format__", format, format_impl, set(), {}), + ("__round__", round, zero, set(), {}), ("__floor__", math.floor, zero, set(), {}), ("__trunc__", math.trunc, zero, set(), {}), ("__trunc__", int, zero, set(), {}), diff -r 5358ee70f831 Python/bltinmodule.c --- a/Python/bltinmodule.c Sat Apr 13 17:46:04 2013 +0100 +++ b/Python/bltinmodule.c Sat Apr 13 21:01:52 2013 +0100 @@ -1810,10 +1810,10 @@ static PyObject * builtin_round(PyObject *self, PyObject *args, PyObject *kwds) { - static PyObject *round_str = NULL; PyObject *ndigits = NULL; static char *kwlist[] = {"number", "ndigits", 0}; PyObject *number, *round; + _Py_IDENTIFIER(__round__); if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:round", kwlist, &number, &ndigits)) @@ -1824,24 +1824,20 @@ return NULL; } - if (round_str == NULL) { - round_str = PyUnicode_InternFromString("__round__"); - if (round_str == NULL) - return NULL; - } - - round = _PyType_Lookup(Py_TYPE(number), round_str); + round = _PyObject_LookupSpecial(number, &PyId___round__); if (round == NULL) { - PyErr_Format(PyExc_TypeError, - "type %.100s doesn't define __round__ method", - Py_TYPE(number)->tp_name); + if (!PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "type %.100s doesn't define __round__ method", + Py_TYPE(number)->tp_name); + } return NULL; } if (ndigits == NULL) - return PyObject_CallFunction(round, "O", number); + return PyObject_CallObject(round, NULL); else - return PyObject_CallFunction(round, "OO", number, ndigits); + return PyObject_CallFunctionObjArgs(round, ndigits, NULL); } PyDoc_STRVAR(round_doc,