Skip to content

bpo-40222: Mark exception table function in the dis module as private #95961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def _get_name_info(name_index, get_name, **extrainfo):
else:
return UNKNOWN, ''

def parse_varint(iterator):
def _parse_varint(iterator):
b = next(iterator)
val = b & 63
while b&64:
Expand All @@ -403,16 +403,16 @@ def parse_varint(iterator):
val |= b&63
return val

def parse_exception_table(code):
def _parse_exception_table(code):
iterator = iter(code.co_exceptiontable)
entries = []
try:
while True:
start = parse_varint(iterator)*2
length = parse_varint(iterator)*2
start = _parse_varint(iterator)*2
length = _parse_varint(iterator)*2
end = start + length
target = parse_varint(iterator)*2
dl = parse_varint(iterator)
target = _parse_varint(iterator)*2
dl = _parse_varint(iterator)
depth = dl >> 1
lasti = bool(dl&1)
entries.append(_ExceptionTableEntry(start, end, target, depth, lasti))
Expand Down Expand Up @@ -527,7 +527,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False):
"""Disassemble a code object."""
linestarts = dict(findlinestarts(co))
exception_entries = parse_exception_table(co)
exception_entries = _parse_exception_table(co)
_disassemble_bytes(_get_code_array(co, adaptive),
lasti, co._varname_from_oparg,
co.co_names, co.co_consts, linestarts, file=file,
Expand Down Expand Up @@ -717,7 +717,7 @@ def __init__(self, x, *, first_line=None, current_offset=None, show_caches=False
self._linestarts = dict(findlinestarts(co))
self._original_object = x
self.current_offset = current_offset
self.exception_entries = parse_exception_table(co)
self.exception_entries = _parse_exception_table(co)
self.show_caches = show_caches
self.adaptive = adaptive

Expand Down