summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast.py
diff options
context:
space:
mode:
authorCurtis Bucher <cpbucher5@gmail.com>2020-05-05 19:40:56 (GMT)
committerGitHub <noreply@github.com>2020-05-05 19:40:56 (GMT)
commitc21c51235aa8061da6b0593d6f857f42fd92fd8b (patch)
treebbac12bdb68cdaa5d3317cd6de8e2e47d2724c83 /Lib/test/test_ast.py
parentfb2c7c4afbab0514352ab0246b0c0cc85d1bba53 (diff)
downloadcpython-c21c51235aa8061da6b0593d6f857f42fd92fd8b.zip
cpython-c21c51235aa8061da6b0593d6f857f42fd92fd8b.tar.gz
cpython-c21c51235aa8061da6b0593d6f857f42fd92fd8b.tar.bz2
bpo-40355: Improve error messages in ast.literal_eval with malformed Dict nodes (GH-19868)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r--Lib/test/test_ast.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 9063b3d..a8a13fd 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -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',