mirror of https://github.com/python/cpython
Revert "gh-94816: Improve coverage of decode_linetable (GH-94853)" (GH-94982)
This reverts commit 20b9d2a658
.
This commit is contained in:
parent
fc0dc9203d
commit
4b5360c7d5
|
@ -17,7 +17,6 @@ cellvars: ('x',)
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 2
|
nlocals: 2
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [4, 1, 10, 2]
|
|
||||||
consts: ('None', '<code object g>')
|
consts: ('None', '<code object g>')
|
||||||
|
|
||||||
>>> dump(f(4).__code__)
|
>>> dump(f(4).__code__)
|
||||||
|
@ -31,7 +30,6 @@ cellvars: ()
|
||||||
freevars: ('x',)
|
freevars: ('x',)
|
||||||
nlocals: 1
|
nlocals: 1
|
||||||
flags: 19
|
flags: 19
|
||||||
lnotab: [4, 1]
|
|
||||||
consts: ('None',)
|
consts: ('None',)
|
||||||
|
|
||||||
>>> def h(x, y):
|
>>> def h(x, y):
|
||||||
|
@ -52,7 +50,6 @@ cellvars: ()
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 5
|
nlocals: 5
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [2, 1, 10, 1, 10, 1, 10, 1]
|
|
||||||
consts: ('None',)
|
consts: ('None',)
|
||||||
|
|
||||||
>>> def attrs(obj):
|
>>> def attrs(obj):
|
||||||
|
@ -71,7 +68,6 @@ cellvars: ()
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 1
|
nlocals: 1
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [2, 1, 46, 1, 46, 1]
|
|
||||||
consts: ('None',)
|
consts: ('None',)
|
||||||
|
|
||||||
>>> def optimize_away():
|
>>> def optimize_away():
|
||||||
|
@ -91,7 +87,6 @@ cellvars: ()
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 0
|
nlocals: 0
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [2, 2, 2, 1, 2, 1]
|
|
||||||
consts: ("'doc string'", 'None')
|
consts: ("'doc string'", 'None')
|
||||||
|
|
||||||
>>> def keywordonly_args(a,b,*,k1):
|
>>> def keywordonly_args(a,b,*,k1):
|
||||||
|
@ -109,7 +104,6 @@ cellvars: ()
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 3
|
nlocals: 3
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [2, 1]
|
|
||||||
consts: ('None',)
|
consts: ('None',)
|
||||||
|
|
||||||
>>> def posonly_args(a,b,/,c):
|
>>> def posonly_args(a,b,/,c):
|
||||||
|
@ -127,7 +121,6 @@ cellvars: ()
|
||||||
freevars: ()
|
freevars: ()
|
||||||
nlocals: 3
|
nlocals: 3
|
||||||
flags: 3
|
flags: 3
|
||||||
lnotab: [2, 1]
|
|
||||||
consts: ('None',)
|
consts: ('None',)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -168,7 +161,6 @@ def dump(co):
|
||||||
"kwonlyargcount", "names", "varnames",
|
"kwonlyargcount", "names", "varnames",
|
||||||
"cellvars", "freevars", "nlocals", "flags"]:
|
"cellvars", "freevars", "nlocals", "flags"]:
|
||||||
print("%s: %s" % (attr, getattr(co, "co_" + attr)))
|
print("%s: %s" % (attr, getattr(co, "co_" + attr)))
|
||||||
print("lnotab:", list(co.co_lnotab))
|
|
||||||
print("consts:", tuple(consts(co.co_consts)))
|
print("consts:", tuple(consts(co.co_consts)))
|
||||||
|
|
||||||
# Needed for test_closure_injection below
|
# Needed for test_closure_injection below
|
||||||
|
@ -436,21 +428,6 @@ class CodeTest(unittest.TestCase):
|
||||||
self.assertIsNone(line)
|
self.assertIsNone(line)
|
||||||
self.assertEqual(end_line, new_code.co_firstlineno + 1)
|
self.assertEqual(end_line, new_code.co_firstlineno + 1)
|
||||||
|
|
||||||
def test_large_lnotab(self):
|
|
||||||
d = {}
|
|
||||||
lines = (
|
|
||||||
["def f():"] +
|
|
||||||
[""] * (1 << 17) +
|
|
||||||
[" pass"] * (1 << 17)
|
|
||||||
)
|
|
||||||
source = "\n".join(lines)
|
|
||||||
exec(source, d)
|
|
||||||
code = d["f"].__code__
|
|
||||||
|
|
||||||
expected = 1032 * [0, 127] + [0, 9] + ((1 << 17) - 1) * [2, 1]
|
|
||||||
expected[0] = 2
|
|
||||||
self.assertEqual(list(code.co_lnotab), expected)
|
|
||||||
|
|
||||||
|
|
||||||
def isinterned(s):
|
def isinterned(s):
|
||||||
return s is sys.intern(('_' + s + '_')[1:-1])
|
return s is sys.intern(('_' + s + '_')[1:-1])
|
||||||
|
|
Loading…
Reference in New Issue