Issue #13436: Fix a bogus error message when an AST object was passed

an invalid integer value.
This commit is contained in:
Amaury Forgeot d'Arc 2011-11-22 21:51:55 +01:00
parent 3b1acf11e9
commit 58e8761da6
3 changed files with 15 additions and 5 deletions

View file

@ -486,6 +486,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))
def test_main():
support.run_unittest(AST_Tests, ASTHelpers_Test)