Skip to content

Commit 2188203

Browse files
committed
tracer: fix on pypy-3.11
pypy does not have _varname_from_oparg, so fall back to pre cpython-3.11 path ref: https://github.com/pypy/pypy/blob/0253c85bf5f86a45760eda7f0af8953ed8a253c7/lib-python/3/dis.py#L351
1 parent c26adef commit 2188203

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

amaranth/tracer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import platform
23
from opcode import opname
34

45

@@ -44,13 +45,13 @@ def get_var_name(depth=2, default=_raise_exception):
4445
return code.co_names[imm]
4546
elif opc == "STORE_FAST":
4647
imm |= int(code.co_code[index + 1])
47-
if sys.version_info >= (3, 11):
48+
if sys.version_info >= (3, 11) and platform.python_implementation() == 'CPython':
4849
return code._varname_from_oparg(imm)
4950
else:
5051
return code.co_varnames[imm]
5152
elif opc == "STORE_DEREF":
5253
imm |= int(code.co_code[index + 1])
53-
if sys.version_info >= (3, 11):
54+
if sys.version_info >= (3, 11) and platform.python_implementation() == 'CPython':
5455
return code._varname_from_oparg(imm)
5556
else:
5657
if imm < len(code.co_cellvars):

0 commit comments

Comments
 (0)