Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4953d9

Browse files
committed
fix lambda test
1 parent0193b83 commite4953d9

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+
deftest_lambda_consts(self):
345+
l=lambda:"this is the only const"
346+
self.assertEqual(len(l.__code__.co_consts),1)
347+
344348
deftest_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=lambdax:xin {("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)

[8]ページ先頭

©2009-2025 Movatter.jp