summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-05 20:00:57 (GMT)
committerGitHub <noreply@github.com>2020-05-05 20:00:57 (GMT)
commit2a3b876b0286b22a9058510d9e51dc4d60eeb89a (patch)
treec71a4a368b32e1c1ec86e95ea90e7f000c5e74a9 /Lib/test
parenta6a116c1b964b3d1fdff0f533861ed2a2227de1f (diff)
downloadcpython-2a3b876b0286b22a9058510d9e51dc4d60eeb89a.zip
cpython-2a3b876b0286b22a9058510d9e51dc4d60eeb89a.tar.gz
cpython-2a3b876b0286b22a9058510d9e51dc4d60eeb89a.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> (cherry picked from commit c21c51235aa8061da6b0593d6f857f42fd92fd8b) Co-authored-by: Curtis Bucher <cpbucher5@gmail.com>
Diffstat (limited to 'Lib/test')
-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 3e8a39d..8887558 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -869,6 +869,12 @@ class ASTHelpers_Test(unittest.TestCase):
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',