diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-11-22 21:02:01 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-11-22 21:02:01 (GMT) |
commit | 942d5ba125860112c42f3a8981778c80c23d5499 (patch) | |
tree | 142f9ed4e3e83cee234402d0be2ca9d28839acd8 | |
parent | 02686751931e6cd267f60c65b59744c7dff50cd2 (diff) | |
parent | 5e8f8104116edfcbfee2690a58391830bd9883ae (diff) | |
download | cpython-942d5ba125860112c42f3a8981778c80c23d5499.zip cpython-942d5ba125860112c42f3a8981778c80c23d5499.tar.gz cpython-942d5ba125860112c42f3a8981778c80c23d5499.tar.bz2 |
Merge branch 3.2
-rw-r--r-- | Doc/library/exceptions.rst | 6 | ||||
-rw-r--r-- | Lib/test/test_ast.py | 11 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rwxr-xr-x | Parser/asdl_c.py | 6 | ||||
-rw-r--r-- | Python/Python-ast.c | 6 |
5 files changed, 19 insertions, 13 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index ca8e4d8..49cec1e 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -44,9 +44,9 @@ The following exceptions are used mostly as base classes for other exceptions. The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use :exc:`Exception`). If - :func:`bytes` or :func:`str` is called on an instance of this class, the - representation of the argument(s) to the instance are returned, or the empty - string when there were no arguments. + :func:`str` is called on an instance of this class, the representation of + the argument(s) to the instance are returned, or the empty string when + there were no arguments. .. attribute:: args diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 4fbe5b4..b1656bc 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -491,6 +491,17 @@ class ASTHelpers_Test(unittest.TestCase): 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)) + class ASTValidatorTests(unittest.TestCase): @@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? Core and Builtins ----------------- +- Issue #13436: Fix a bogus error message when an AST object was passed + an invalid integer value. + - Issue #13411: memoryview objects are now hashable when the underlying object is hashable. diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 651348e..07c06de 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -844,11 +844,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) { 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 --git a/Python/Python-ast.c b/Python/Python-ast.c index 3cfb8a8..8a101cf 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -690,11 +690,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) { 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; } |