mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
bpo-40355: Improve error messages in ast.literal_eval with malformed Dict nodes (GH-19868)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
fb2c7c4afb
commit
c21c51235a
3 changed files with 15 additions and 4 deletions
|
@ -965,6 +965,12 @@ Module(
|
|||
self.assertRaises(ValueError, ast.literal_eval, '3+(0+6j)')
|
||||
self.assertRaises(ValueError, ast.literal_eval, '-(3+6j)')
|
||||
|
||||
def test_literal_eval_malformed_dict_nodes(self):
|
||||
malformed = ast.Dict(keys=[ast.Constant(1), ast.Constant(2)], values=[ast.Constant(3)])
|
||||
self.assertRaises(ValueError, ast.literal_eval, malformed)
|
||||
malformed = ast.Dict(keys=[ast.Constant(1)], values=[ast.Constant(2), ast.Constant(3)])
|
||||
self.assertRaises(ValueError, ast.literal_eval, malformed)
|
||||
|
||||
def test_bad_integer(self):
|
||||
# issue13436: Bad error message with invalid numeric values
|
||||
body = [ast.ImportFrom(module='time',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue