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

This commit is contained in:
Pablo Galindo Salgado 2022-08-14 15:42:31 +01:00 committed by GitHub
parent 32ac98e899
commit c26500224f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -394,7 +394,7 @@ def _get_name_info(name_index, get_name, **extrainfo):
else: else:
return UNKNOWN, '' return UNKNOWN, ''
def parse_varint(iterator): def _parse_varint(iterator):
b = next(iterator) b = next(iterator)
val = b & 63 val = b & 63
while b&64: while b&64:
@ -403,16 +403,16 @@ def parse_varint(iterator):
val |= b&63 val |= b&63
return val return val
def parse_exception_table(code): def _parse_exception_table(code):
iterator = iter(code.co_exceptiontable) iterator = iter(code.co_exceptiontable)
entries = [] entries = []
try: try:
while True: while True:
start = parse_varint(iterator)*2 start = _parse_varint(iterator)*2
length = parse_varint(iterator)*2 length = _parse_varint(iterator)*2
end = start + length end = start + length
target = parse_varint(iterator)*2 target = _parse_varint(iterator)*2
dl = parse_varint(iterator) dl = _parse_varint(iterator)
depth = dl >> 1 depth = dl >> 1
lasti = bool(dl&1) lasti = bool(dl&1)
entries.append(_ExceptionTableEntry(start, end, target, depth, lasti)) entries.append(_ExceptionTableEntry(start, end, target, depth, lasti))
@ -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): def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False):
"""Disassemble a code object.""" """Disassemble a code object."""
linestarts = dict(findlinestarts(co)) linestarts = dict(findlinestarts(co))
exception_entries = parse_exception_table(co) exception_entries = _parse_exception_table(co)
_disassemble_bytes(_get_code_array(co, adaptive), _disassemble_bytes(_get_code_array(co, adaptive),
lasti, co._varname_from_oparg, lasti, co._varname_from_oparg,
co.co_names, co.co_consts, linestarts, file=file, co.co_names, co.co_consts, linestarts, file=file,
@ -717,7 +717,7 @@ class Bytecode:
self._linestarts = dict(findlinestarts(co)) self._linestarts = dict(findlinestarts(co))
self._original_object = x self._original_object = x
self.current_offset = current_offset 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.show_caches = show_caches
self.adaptive = adaptive self.adaptive = adaptive