Skip to content

tracer: fix on pypy-3.11 #1601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- '3.13'
- 'pypy-3.9'
- 'pypy-3.10'
- 'pypy-3.11'
allow-failure:
- false
include:
Expand Down
5 changes: 3 additions & 2 deletions amaranth/tracer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import platform
from opcode import opname


Expand Down Expand Up @@ -44,13 +45,13 @@ def get_var_name(depth=2, default=_raise_exception):
return code.co_names[imm]
elif opc == "STORE_FAST":
imm |= int(code.co_code[index + 1])
if sys.version_info >= (3, 11):
if sys.version_info >= (3, 11) and platform.python_implementation() == 'CPython':
return code._varname_from_oparg(imm)
else:
return code.co_varnames[imm]
elif opc == "STORE_DEREF":
imm |= int(code.co_code[index + 1])
if sys.version_info >= (3, 11):
if sys.version_info >= (3, 11) and platform.python_implementation() == 'CPython':
return code._varname_from_oparg(imm)
else:
if imm < len(code.co_cellvars):
Expand Down
5 changes: 5 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import platform
import re
import shutil
import subprocess
import sys
import textwrap
import traceback
import unittest
Expand Down Expand Up @@ -69,6 +71,9 @@ def format_repr(input_repr, *, indent=" "):
self.assertEqual(format_repr(squish_repr(repr(obj))), format_repr(squish_repr(repr_str)))

def assertFormal(self, spec, ports=None, mode="bmc", depth=1):
if sys.version_info >= (3, 11) and platform.python_implementation() == 'PyPy':
self.skipTest("sby is broken with pypy-3.11 without https://github.com/YosysHQ/sby/pull/323")

stack = traceback.extract_stack()
for frame in reversed(stack):
if os.path.dirname(__file__) not in frame.filename:
Expand Down
Loading