Skip to content

Commit

Permalink
Merge pull request #109 from kc611/main
Browse files Browse the repository at this point in the history
Simulator test fixes for Python 3.12 version upgrade
  • Loading branch information
esc authored Dec 11, 2023
2 parents 8292806 + 61c14d0 commit 1cababd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions numba_rvsdg/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import logging
import sys

_logger = logging.getLogger(__name__)

PYVERSION = sys.version_info[:2]


class _LogWrap:
def __init__(self, fn): # type: ignore
Expand Down
23 changes: 22 additions & 1 deletion numba_rvsdg/tests/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
RegionBlock,
SyntheticBlock,
)
from numba_rvsdg.core.utils import PYVERSION

import builtins

Expand Down Expand Up @@ -327,8 +328,13 @@ def op_FOR_ITER(self, inst):
try:
ind = next(tos)
except StopIteration:
self.stack.pop()
self.branch = True
if PYVERSION in ((3, 11),):
self.stack.pop()
elif PYVERSION in ((3, 12),):
self.stack.append(None)
else:
raise NotImplementedError(PYVERSION)
else:
self.branch = False
self.stack.append(ind)
Expand Down Expand Up @@ -427,3 +433,18 @@ def op_POP_JUMP_FORWARD_IF_NONE(self, inst):
def op_POP_JUMP_BACKWARD_IF_NONE(self, inst):
self.branch = self.stack[-1] is None
self.stack.pop()

if PYVERSION in ((3, 12),):

def op_END_FOR(self, inst):
self.stack.pop()
self.stack.pop()

else:

def op_END_FOR(self, inst):
raise NotImplementedError(PYVERSION)

def op_COPY(self, inst):
assert inst.argval > 0
self.stack.append(self.stack[-inst.argval])

0 comments on commit 1cababd

Please sign in to comment.