|
5 | 5 | """
|
6 | 6 |
|
7 | 7 |
|
8 |
| -# Note that __all__ is further extended below |
9 |
| -__all__ = ["cmp_op", "stack_effect", "hascompare"] |
| 8 | +__all__ = ["cmp_op", "stack_effect", "hascompare", "opname", "opmap", |
| 9 | + "HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname", |
| 10 | + "hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"] |
10 | 11 |
|
11 | 12 | import _opcode
|
12 | 13 | from _opcode import stack_effect
|
13 | 14 |
|
14 |
| -import sys |
15 |
| -# The build uses older versions of Python which do not have _opcode_metadata |
16 |
| -if sys.version_info[:2] >= (3, 13): |
17 |
| - from _opcode_metadata import _specializations, _specialized_opmap |
18 |
| - from _opcode_metadata import opmap, HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE |
19 |
| - EXTENDED_ARG = opmap['EXTENDED_ARG'] |
| 15 | +from _opcode_metadata import (_specializations, _specialized_opmap, opmap, |
| 16 | + HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) |
| 17 | +EXTENDED_ARG = opmap['EXTENDED_ARG'] |
20 | 18 |
|
21 |
| - opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)] |
22 |
| - for op, i in opmap.items(): |
23 |
| - opname[i] = op |
24 |
| - |
25 |
| - __all__.extend(["opname", "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG"]) |
| 19 | +opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)] |
| 20 | +for op, i in opmap.items(): |
| 21 | + opname[i] = op |
26 | 22 |
|
27 | 23 | cmp_op = ('<', '<=', '==', '!=', '>', '>=')
|
28 | 24 |
|
29 |
| -# The build uses older versions of Python which do not have _opcode.has_* functions |
30 |
| -if sys.version_info[:2] >= (3, 13): |
31 |
| - # These lists are documented as part of the dis module's API |
32 |
| - hasarg = [op for op in opmap.values() if _opcode.has_arg(op)] |
33 |
| - hasconst = [op for op in opmap.values() if _opcode.has_const(op)] |
34 |
| - hasname = [op for op in opmap.values() if _opcode.has_name(op)] |
35 |
| - hasjump = [op for op in opmap.values() if _opcode.has_jump(op)] |
36 |
| - hasjrel = hasjump # for backward compatibility |
37 |
| - hasjabs = [] |
38 |
| - hasfree = [op for op in opmap.values() if _opcode.has_free(op)] |
39 |
| - haslocal = [op for op in opmap.values() if _opcode.has_local(op)] |
40 |
| - hasexc = [op for op in opmap.values() if _opcode.has_exc(op)] |
| 25 | +# These lists are documented as part of the dis module's API |
| 26 | +hasarg = [op for op in opmap.values() if _opcode.has_arg(op)] |
| 27 | +hasconst = [op for op in opmap.values() if _opcode.has_const(op)] |
| 28 | +hasname = [op for op in opmap.values() if _opcode.has_name(op)] |
| 29 | +hasjump = [op for op in opmap.values() if _opcode.has_jump(op)] |
| 30 | +hasjrel = hasjump # for backward compatibility |
| 31 | +hasjabs = [] |
| 32 | +hasfree = [op for op in opmap.values() if _opcode.has_free(op)] |
| 33 | +haslocal = [op for op in opmap.values() if _opcode.has_local(op)] |
| 34 | +hasexc = [op for op in opmap.values() if _opcode.has_exc(op)] |
41 | 35 |
|
42 |
| - __all__.extend(["hasarg", "hasconst", "hasname", "hasjump", "hasjrel", |
43 |
| - "hasjabs", "hasfree", "haslocal", "hasexc"]) |
44 | 36 |
|
45 |
| - _intrinsic_1_descs = _opcode.get_intrinsic1_descs() |
46 |
| - _intrinsic_2_descs = _opcode.get_intrinsic2_descs() |
47 |
| - _nb_ops = _opcode.get_nb_ops() |
| 37 | +_intrinsic_1_descs = _opcode.get_intrinsic1_descs() |
| 38 | +_intrinsic_2_descs = _opcode.get_intrinsic2_descs() |
| 39 | +_nb_ops = _opcode.get_nb_ops() |
48 | 40 |
|
49 |
| - hascompare = [opmap["COMPARE_OP"]] |
| 41 | +hascompare = [opmap["COMPARE_OP"]] |
50 | 42 |
|
51 | 43 | _cache_format = {
|
52 | 44 | "LOAD_GLOBAL": {
|
|
0 commit comments