diff -r 1e0e821d2626 Lib/test/test_ast.py --- a/Lib/test/test_ast.py Fri Nov 04 22:17:45 2011 +0100 +++ b/Lib/test/test_ast.py Sun Nov 20 21:33:21 2011 +0100 @@ -486,6 +486,17 @@ self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j) self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j) + def test_bad_integer(self): + # issue13436: Bad error message with invalid numeric values + body = [ast.ImportFrom(module='time', + names=[ast.alias(name='sleep')], + level=None, + lineno=None, col_offset=None)] + mod = ast.Module(body) + with self.assertRaises(ValueError) as cm: + compile(mod, 'test', 'exec') + self.assertIn("invalid integer value: None", str(cm.exception)) + def test_main(): support.run_unittest(AST_Tests, ASTHelpers_Test) diff -r 1e0e821d2626 Parser/asdl_c.py --- a/Parser/asdl_c.py Fri Nov 04 22:17:45 2011 +0100 +++ b/Parser/asdl_c.py Sun Nov 20 21:33:21 2011 +0100 @@ -816,11 +816,7 @@ { int i; if (!PyLong_Check(obj)) { - PyObject *s = PyObject_Repr(obj); - if (s == NULL) return 1; - PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s", - PyBytes_AS_STRING(s)); - Py_DECREF(s); + PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj); return 1; } diff -r 1e0e821d2626 Python/Python-ast.c --- a/Python/Python-ast.c Fri Nov 04 22:17:45 2011 +0100 +++ b/Python/Python-ast.c Sun Nov 20 21:33:21 2011 +0100 @@ -622,11 +622,7 @@ { int i; if (!PyLong_Check(obj)) { - PyObject *s = PyObject_Repr(obj); - if (s == NULL) return 1; - PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s", - PyBytes_AS_STRING(s)); - Py_DECREF(s); + PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj); return 1; }