Skip to content

Commit e4953d9

Browse files
committed
fix lambda test
1 parent 0193b83 commit e4953d9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/test/test_compile.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ def test_lambda_doc(self):
341341
l = lambda: "foo"
342342
self.assertIsNone(l.__doc__)
343343

344+
def test_lambda_consts(self):
345+
l = lambda: "this is the only const"
346+
self.assertEqual(len(l.__code__.co_consts), 1)
347+
344348
def test_encoding(self):
345349
code = b'# -*- coding: badencoding -*-\npass\n'
346350
self.assertRaises(SyntaxError, compile, code, 'tmp', 'exec')
@@ -789,10 +793,10 @@ def check_same_constant(const):
789793
# Merge constants in tuple or frozenset
790794
f1, f2 = lambda: "not a name", lambda: ("not a name",)
791795
f3 = lambda x: x in {("not a name",)}
792-
self.assertIs(f1.__code__.co_consts[1],
793-
f2.__code__.co_consts[1][0])
794-
self.assertIs(next(iter(f3.__code__.co_consts[1])),
795-
f2.__code__.co_consts[1])
796+
self.assertIs(f1.__code__.co_consts[0],
797+
f2.__code__.co_consts[0][0])
798+
self.assertIs(next(iter(f3.__code__.co_consts[0])),
799+
f2.__code__.co_consts[0])
796800

797801
# {0} is converted to a constant frozenset({0}) by the peephole
798802
# optimizer

0 commit comments

Comments
 (0)