Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
xuantengh committed Oct 30, 2024
commit be4cffe95063a2429eaef219f6a2a81f1102702c
4 changes: 2 additions & 2 deletions Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>')
consts: ('<code object g>',)

>>> dump(f(4).__code__)
name: g
Expand Down Expand Up @@ -86,7 +86,7 @@
cellvars: ()
freevars: ()
nlocals: 0
flags: 3
flags: 67108867
consts: ("'doc string'", 'None')

>>> def keywordonly_args(a,b,*,k1):
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def f():
return "unused"

self.assertEqual(f.__code__.co_consts,
(None, "used"))
(True, "used"))

@support.cpython_only
def test_remove_unused_consts_extended_args(self):
Expand All @@ -852,7 +852,7 @@ def test_remove_unused_consts_extended_args(self):
eval(compile(code, "file.py", "exec"), g)
exec(code, g)
f = g['f']
expected = tuple([None, ''] + [f't{i}' for i in range(N)])
expected = tuple(['', 1] + [f't{i}' for i in range(N)])
self.assertEqual(f.__code__.co_consts, expected)
expected = "".join(expected[2:])
self.assertEqual(expected, f())
Expand Down Expand Up @@ -1244,7 +1244,7 @@ def return_genexp():
y)
genexp_lines = [0, 4, 2, 0, 4]

genexp_code = return_genexp.__code__.co_consts[1]
genexp_code = return_genexp.__code__.co_consts[0]
code_lines = self.get_code_lines(genexp_code)
self.assertEqual(genexp_lines, code_lines)

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_compiler_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def inner():
return x
return inner() % 2

inner_code = mod_two.__code__.co_consts[1]
inner_code = mod_two.__code__.co_consts[0]
assert isinstance(inner_code, types.CodeType)

metadata = {
Expand Down