diff -r 76c5f3371db6 Lib/test/test_int.py --- a/Lib/test/test_int.py Sun Dec 23 15:35:23 2012 -0800 +++ b/Lib/test/test_int.py Mon Dec 24 11:41:33 2012 +0200 @@ -230,15 +230,9 @@ 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.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 76c5f3371db6 Objects/longobject.c --- a/Objects/longobject.c Sun Dec 23 15:35:23 2012 -0800 +++ b/Objects/longobject.c Mon Dec 24 11:41:33 2012 +0200 @@ -4256,8 +4256,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); @@ -4266,7 +4272,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; }