Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix len(self.hold)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrr1999 committed Jul 17, 2023
1 parent 73af75f commit 83f4cb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions sot/opcode_translator/executor/variables/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class VariableBase:
"""

tracker: Tracker # An attribute to store the Tracker object associated with the variable
value: Any
name_generator = NameGenerator(
"object_"
) # A class-level attribute to generate names for new variables
Expand Down
11 changes: 8 additions & 3 deletions sot/opcode_translator/executor/variables/iter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Sized

from ..tracker import ConstTracker, DummyTracker
from .base import VariableBase
Expand All @@ -13,13 +13,18 @@
from ..tracker import Tracker


class SizedVariable(VariableBase, Sized):
def __len__(self) -> int:
...


class IterVariable(VariableBase):
"""
This Variable (include subclasses) should be generated only when simulate GET_ITER opcode
"""

def __init__(
self, obj: VariableBase, graph: FunctionGraph, tracker: Tracker
self, obj: SizedVariable, graph: FunctionGraph, tracker: Tracker
):
super().__init__(graph, tracker)
self.hold = obj
Expand Down Expand Up @@ -94,7 +99,7 @@ def get_wrapped_items(self):
return self.get_items()

@staticmethod
def from_iterator(value, graph: FunctionGraph | None, tracker: Tracker):
def from_iterator(value, graph: FunctionGraph, tracker: Tracker):
# breakpoint()
if isinstance(
value,
Expand Down

0 comments on commit 83f4cb2

Please sign in to comment.