Added the show_positions parameter to various dis interfaces (#14010)

This commit is contained in:
Bénédikt Tran
2025-05-11 13:15:33 +02:00
committed by GitHub
parent 2312540035
commit db2949804c
2 changed files with 61 additions and 13 deletions
@@ -107,11 +107,7 @@ dataclasses.field
dataclasses.make_dataclass
decimal.Decimal.from_number
decimal.IEEE_CONTEXT_MAX_BITS
dis.Bytecode.__init__
dis.Instruction.make
dis.dis
dis.disassemble
dis.distb
enum.Enum.__signature__
enum.EnumMeta.__signature__
enum.EnumType.__signature__
+61 -9
View File
@@ -110,7 +110,21 @@ class Instruction(_Instruction):
class Bytecode:
codeobj: types.CodeType
first_line: int
if sys.version_info >= (3, 13):
if sys.version_info >= (3, 14):
show_positions: bool
# 3.14 added `show_positions`
def __init__(
self,
x: _HaveCodeType | str,
*,
first_line: int | None = None,
current_offset: int | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
elif sys.version_info >= (3, 13):
show_offsets: bool
# 3.13 added `show_offsets`
def __init__(
@@ -156,7 +170,39 @@ def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
def pretty_flags(flags: int) -> str: ...
def code_info(x: _HaveCodeType | str) -> str: ...
if sys.version_info >= (3, 13):
if sys.version_info >= (3, 14):
# 3.14 added `show_positions`
def dis(
x: _HaveCodeType | str | bytes | bytearray | None = None,
*,
file: IO[str] | None = None,
depth: int | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
def disassemble(
co: _HaveCodeType,
lasti: int = -1,
*,
file: IO[str] | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
def distb(
tb: types.TracebackType | None = None,
*,
file: IO[str] | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
elif sys.version_info >= (3, 13):
# 3.13 added `show_offsets`
def dis(
x: _HaveCodeType | str | bytes | bytearray | None = None,
@@ -184,10 +230,6 @@ if sys.version_info >= (3, 13):
adaptive: bool = False,
show_offsets: bool = False,
) -> None: ...
# 3.13 made `show_cache` `None` by default
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool | None = None, adaptive: bool = False
) -> Iterator[Instruction]: ...
elif sys.version_info >= (3, 11):
# 3.11 added `show_caches` and `adaptive`
@@ -205,9 +247,6 @@ elif sys.version_info >= (3, 11):
def distb(
tb: types.TracebackType | None = None, *, file: IO[str] | None = None, show_caches: bool = False, adaptive: bool = False
) -> None: ...
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool = False, adaptive: bool = False
) -> Iterator[Instruction]: ...
else:
def dis(
@@ -215,6 +254,19 @@ else:
) -> None: ...
def disassemble(co: _HaveCodeType, lasti: int = -1, *, file: IO[str] | None = None) -> None: ...
def distb(tb: types.TracebackType | None = None, *, file: IO[str] | None = None) -> None: ...
if sys.version_info >= (3, 13):
# 3.13 made `show_cache` `None` by default
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool | None = None, adaptive: bool = False
) -> Iterator[Instruction]: ...
elif sys.version_info >= (3, 11):
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool = False, adaptive: bool = False
) -> Iterator[Instruction]: ...
else:
def get_instructions(x: _HaveCodeType, *, first_line: int | None = None) -> Iterator[Instruction]: ...
def show_code(co: _HaveCodeType, *, file: IO[str] | None = None) -> None: ...