@@ -38,25 +38,60 @@ __all__ = [
3838_HaveCodeType : TypeAlias = types .MethodType | types .FunctionType | types .CodeType | type | Callable [..., Any ]
3939_HaveCodeOrStringType : TypeAlias = _HaveCodeType | str | bytes
4040
41- class Instruction (NamedTuple ):
42- opname : str
43- opcode : int
44- arg : int | None
45- argval : Any
46- argrepr : str
47- offset : int
48- starts_line : int | None
49- is_jump_target : bool
41+ if sys .version_info >= (3 , 11 ):
42+ class Positions (NamedTuple ):
43+ lineno : int | None = ...
44+ end_lineno : int | None = ...
45+ col_offset : int | None = ...
46+ end_col_offset : int | None = ...
47+
48+ if sys .version_info >= (3 , 11 ):
49+ class Instruction (NamedTuple ):
50+ opname : str
51+ opcode : int
52+ arg : int | None
53+ argval : Any
54+ argrepr : str
55+ offset : int
56+ starts_line : int | None
57+ is_jump_target : bool
58+ positions : Positions | None = ...
59+
60+ else :
61+ class Instruction (NamedTuple ):
62+ opname : str
63+ opcode : int
64+ arg : int | None
65+ argval : Any
66+ argrepr : str
67+ offset : int
68+ starts_line : int | None
69+ is_jump_target : bool
5070
5171class Bytecode :
5272 codeobj : types .CodeType
5373 first_line : int
54- def __init__ (self , x : _HaveCodeOrStringType , * , first_line : int | None = ..., current_offset : int | None = ...) -> None : ...
74+ if sys .version_info >= (3 , 11 ):
75+ def __init__ (
76+ self ,
77+ x : _HaveCodeOrStringType ,
78+ * ,
79+ first_line : int | None = ...,
80+ current_offset : int | None = ...,
81+ show_caches : bool = ...,
82+ ) -> None : ...
83+ @classmethod
84+ def from_traceback (cls : type [Self ], tb : types .TracebackType , * , show_caches : bool = ...) -> Self : ...
85+ else :
86+ def __init__ (
87+ self , x : _HaveCodeOrStringType , * , first_line : int | None = ..., current_offset : int | None = ...
88+ ) -> None : ...
89+ @classmethod
90+ def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
91+
5592 def __iter__ (self ) -> Iterator [Instruction ]: ...
5693 def info (self ) -> str : ...
5794 def dis (self ) -> str : ...
58- @classmethod
59- def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
6095
6196COMPILER_FLAG_NAMES : dict [int , str ]
6297
@@ -65,14 +100,27 @@ def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
65100def pretty_flags (flags : int ) -> str : ...
66101def code_info (x : _HaveCodeOrStringType ) -> str : ...
67102
68- if sys .version_info >= (3 , 7 ):
103+ if sys .version_info >= (3 , 11 ):
104+ def dis (
105+ x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ..., show_caches : bool = ...
106+ ) -> None : ...
107+
108+ elif sys .version_info >= (3 , 7 ):
69109 def dis (x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ...) -> None : ...
70110
71111else :
72112 def dis (x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
73113
74- def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
75- def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
76- def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
114+ if sys .version_info >= (3 , 11 ):
115+ def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
116+ def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
117+ def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
118+ def get_instructions (x : _HaveCodeType , * , first_line : int | None = ..., show_caches : bool = ...) -> Iterator [Instruction ]: ...
119+
120+ else :
121+ def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
122+ def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
123+ def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
124+ def get_instructions (x : _HaveCodeType , * , first_line : int | None = ...) -> Iterator [Instruction ]: ...
125+
77126def show_code (co : _HaveCodeType , * , file : IO [str ] | None = ...) -> None : ...
78- def get_instructions (x : _HaveCodeType , * , first_line : int | None = ...) -> Iterator [Instruction ]: ...
0 commit comments