Commit 2172adf9 authored by Victor Stinner's avatar Victor Stinner

Merge branch default

parents 80eee935 7af563da
...@@ -44,9 +44,9 @@ The following exceptions are used mostly as base classes for other exceptions. ...@@ -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 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 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 :func:`str` is called on an instance of this class, the representation of
representation of the argument(s) to the instance are returned, or the empty the argument(s) to the instance are returned, or the empty string when
string when there were no arguments. there were no arguments.
.. attribute:: args .. attribute:: args
......
...@@ -491,6 +491,17 @@ class ASTHelpers_Test(unittest.TestCase): ...@@ -491,6 +491,17 @@ class ASTHelpers_Test(unittest.TestCase):
self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j) self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j)
self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 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): class ASTValidatorTests(unittest.TestCase):
......
...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? ...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins 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 - Issue #13411: memoryview objects are now hashable when the underlying
object is hashable. object is hashable.
......
...@@ -844,11 +844,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) ...@@ -844,11 +844,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{ {
int i; int i;
if (!PyLong_Check(obj)) { if (!PyLong_Check(obj)) {
PyObject *s = PyObject_Repr(obj); PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
PyBytes_AS_STRING(s));
Py_DECREF(s);
return 1; return 1;
} }
......
...@@ -690,11 +690,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) ...@@ -690,11 +690,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{ {
int i; int i;
if (!PyLong_Check(obj)) { if (!PyLong_Check(obj)) {
PyObject *s = PyObject_Repr(obj); PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
PyBytes_AS_STRING(s));
Py_DECREF(s);
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment