Skip to content

Commit

Permalink
only last
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorpela committed Jan 27, 2024
1 parent f4cf3ed commit 5c9489f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions overrides/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,17 @@ def _get_base_class_names(frame: FrameType) -> List[List[str]]:
"""Get baseclass names from the code object"""
current_item: List[str] = []
items: List[List[str]] = []
add_last_step = True

for instruction in dis.get_instructions(frame.f_code):
print(f"{instruction.offset} : {instruction.opname} {instruction.argval}")
if instruction.offset > frame.f_lasti:
break
if instruction.opcode not in dis.hasname:
continue
if not add_last_step:
items = []
add_last_step = True

# Combine LOAD_NAME and LOAD_GLOBAL as they have similar functionality
if instruction.opname in ["LOAD_NAME", "LOAD_GLOBAL"]:
Expand All @@ -218,9 +222,11 @@ def _get_base_class_names(frame: FrameType) -> List[List[str]]:
current_item.append(instruction.argval)

# Reset on other instructions
elif current_item:
items.append(current_item)
else:
if current_item:
items.append(current_item)
current_item = []
add_last_step = False

if current_item:
items.append(current_item)
Expand Down

0 comments on commit 5c9489f

Please sign in to comment.