Skip to content

Commit

Permalink
Merge pull request #80 from MatthieuDartiailh/3.10-b2
Browse files Browse the repository at this point in the history
Start testing with latest Python 3.10 beta
  • Loading branch information
MatthieuDartiailh committed Jun 21, 2021
2 parents 6d298ae + ca77ec4 commit 8ebd549
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
toxenv: py38
- python-version: "3.9"
toxenv: py39
- python-version: "3.10.0-beta.1"
- python-version: "3.10.0-beta.3"
toxenv: py310
steps:
- uses: actions/checkout@v2
Expand Down
15 changes: 10 additions & 5 deletions bytecode/instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _pushes_back(opname):
return (
opname.startswith("UNARY_")
or opname.startswith("GET_")
# BUILD_XXX_UNPACK have been removed in 3.9
or opname.startswith("BINARY_")
or opname.startswith("INPLACE_")
or opname.startswith("BUILD_")
Expand Down Expand Up @@ -317,23 +318,27 @@ def stack_effect(self, jump=None):
def pre_and_post_stack_effect(self, jump=None):
_effect = self.stack_effect(jump=jump)

# To compute pre size and post size to avoid segfault cause by not enough stack element
# To compute pre size and post size to avoid segfault cause by not enough
# stack element
_opname = _opcode.opname[self._opcode]
if _opname.startswith("DUP_TOP"):
return _effect * -1, _effect * 2
if _pushes_back(_opname):
# if the op pushes value back to the stack, then the stack effect given by dis.stack_effect
# actually equals pre + post effect, therefore we need -1 from the stack effect as a pre
# condition
# if the op pushes value back to the stack, then the stack effect given
# by dis.stack_effect actually equals pre + post effect, therefore we need
# -1 from the stack effect as a pre condition
return _effect - 1, 1
if _opname.startswith("UNPACK_"):
# Instr(UNPACK_* , n) pops 1 and pushes n
# _effect = n - 1
# hence we return -1, _effect + 1
return -1, _effect + 1
if _opname == "FOR_ITER" and not jump:
# Since FOR_ITER needs TOS to be an iterator, which basically means a prerequisite of 1 on the stack
# Since FOR_ITER needs TOS to be an iterator, which basically means
# a prerequisite of 1 on the stack
return -1, 2
if _opname == "ROT_N":
return (-self._arg, self._arg)
return {"ROT_TWO": (-2, 2), "ROT_THREE": (-3, 3), "ROT_FOUR": (-4, 4)}.get(
_opname, (_effect, 0)
)
Expand Down

0 comments on commit 8ebd549

Please sign in to comment.