|
17 | 17 | freevars: ()
|
18 | 18 | nlocals: 2
|
19 | 19 | flags: 3
|
20 |
| -lnotab: [4, 1, 10, 2] |
21 | 20 | consts: ('None', '<code object g>')
|
22 | 21 |
|
23 | 22 | >>> dump(f(4).__code__)
|
|
31 | 30 | freevars: ('x',)
|
32 | 31 | nlocals: 1
|
33 | 32 | flags: 19
|
34 |
| -lnotab: [4, 1] |
35 | 33 | consts: ('None',)
|
36 | 34 |
|
37 | 35 | >>> def h(x, y):
|
|
52 | 50 | freevars: ()
|
53 | 51 | nlocals: 5
|
54 | 52 | flags: 3
|
55 |
| -lnotab: [2, 1, 10, 1, 10, 1, 10, 1] |
56 | 53 | consts: ('None',)
|
57 | 54 |
|
58 | 55 | >>> def attrs(obj):
|
|
71 | 68 | freevars: ()
|
72 | 69 | nlocals: 1
|
73 | 70 | flags: 3
|
74 |
| -lnotab: [2, 1, 46, 1, 46, 1] |
75 | 71 | consts: ('None',)
|
76 | 72 |
|
77 | 73 | >>> def optimize_away():
|
|
91 | 87 | freevars: ()
|
92 | 88 | nlocals: 0
|
93 | 89 | flags: 3
|
94 |
| -lnotab: [2, 2, 2, 1, 2, 1] |
95 | 90 | consts: ("'doc string'", 'None')
|
96 | 91 |
|
97 | 92 | >>> def keywordonly_args(a,b,*,k1):
|
|
109 | 104 | freevars: ()
|
110 | 105 | nlocals: 3
|
111 | 106 | flags: 3
|
112 |
| -lnotab: [2, 1] |
113 | 107 | consts: ('None',)
|
114 | 108 |
|
115 | 109 | >>> def posonly_args(a,b,/,c):
|
|
127 | 121 | freevars: ()
|
128 | 122 | nlocals: 3
|
129 | 123 | flags: 3
|
130 |
| -lnotab: [2, 1] |
131 | 124 | consts: ('None',)
|
132 | 125 |
|
133 | 126 | """
|
@@ -168,7 +161,6 @@ def dump(co):
|
168 | 161 | "kwonlyargcount", "names", "varnames",
|
169 | 162 | "cellvars", "freevars", "nlocals", "flags"]:
|
170 | 163 | print("%s: %s" % (attr, getattr(co, "co_" + attr)))
|
171 |
| - print("lnotab:", list(co.co_lnotab)) |
172 | 164 | print("consts:", tuple(consts(co.co_consts)))
|
173 | 165 |
|
174 | 166 | # Needed for test_closure_injection below
|
@@ -436,21 +428,6 @@ def func():
|
436 | 428 | self.assertIsNone(line)
|
437 | 429 | self.assertEqual(end_line, new_code.co_firstlineno + 1)
|
438 | 430 |
|
439 |
| - def test_large_lnotab(self): |
440 |
| - d = {} |
441 |
| - lines = ( |
442 |
| - ["def f():"] + |
443 |
| - [""] * (1 << 17) + |
444 |
| - [" pass"] * (1 << 17) |
445 |
| - ) |
446 |
| - source = "\n".join(lines) |
447 |
| - exec(source, d) |
448 |
| - code = d["f"].__code__ |
449 |
| - |
450 |
| - expected = 1032 * [0, 127] + [0, 9] + ((1 << 17) - 1) * [2, 1] |
451 |
| - expected[0] = 2 |
452 |
| - self.assertEqual(list(code.co_lnotab), expected) |
453 |
| - |
454 | 431 |
|
455 | 432 | def isinterned(s):
|
456 | 433 | return s is sys.intern(('_' + s + '_')[1:-1])
|
|
0 commit comments