diff -r 517f3432d1b5 Lib/test/test_int.py --- a/Lib/test/test_int.py Tue Dec 25 15:27:56 2012 -0800 +++ b/Lib/test/test_int.py Wed Dec 26 12:43:25 2012 +0200 @@ -226,19 +226,11 @@ def test_keyword_args(self): # Test invoking int() using keyword arguments. - self.assertEquals(int(x=1.2), 1) - self.assertEquals(int('100', base=2), 4) - self.assertEquals(int(x='100', base=2), 4) - - # For example, PyPy 1.9.0 raised TypeError for these cases because it - # expects x to be a string if base is given. - @support.cpython_only - def test_base_arg_with_no_x_arg(self): - self.assertEquals(int(base=6), 0) - # Even invalid bases don't raise an exception. - self.assertEquals(int(base=1), 0) - self.assertEquals(int(base=1000), 0) - self.assertEquals(int(base='foo'), 0) + self.assertEqual(int(x=1.2), 1) + self.assertEqual(int('100', base=2), 4) + self.assertEqual(int(x='100', base=2), 4) + self.assertRaises(TypeError, int, base=10) + self.assertRaises(TypeError, int, base=0) def test_non_numeric_input_types(self): # Test possible non-numeric types for the argument x, including diff -r 517f3432d1b5 Objects/longobject.c --- a/Objects/longobject.c Tue Dec 25 15:27:56 2012 -0800 +++ b/Objects/longobject.c Wed Dec 26 12:43:25 2012 +0200 @@ -4267,8 +4267,14 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:int", kwlist, &x, &obase)) return NULL; - if (x == NULL) + if (x == NULL) { + if (obase != NULL) { + PyErr_SetString(PyExc_TypeError, + "int() missing string argument"); + return NULL; + } return PyLong_FromLong(0L); + } if (obase == NULL) return PyNumber_Long(x); @@ -4277,7 +4283,7 @@ return NULL; if (overflow || (base != 0 && base < 2) || base > 36) { PyErr_SetString(PyExc_ValueError, - "int() arg 2 must be >= 2 and <= 36"); + "int() base must be >= 2 and <= 36"); return NULL; }