tracer: add PyPy support to get_var_name().
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 9 Jul 2019 07:29:01 +0000 (00:29 -0700)
committerwhitequark <cz@m-labs.hk>
Tue, 9 Jul 2019 07:29:01 +0000 (07:29 +0000)
Fixes #141.

.travis.yml
nmigen/tracer.py

index fea7d808bc762f2eced71409c3edf8ed544ff84c..22af9037fc105afd71bd49d7fddf0a8dc74d7b91 100644 (file)
@@ -3,6 +3,7 @@ language: python
 python:
   - "3.6"
   - "3.7"
+  - "pypy3"
 cache:
   directories:
     - "$HOME/.ccache"
@@ -23,3 +24,7 @@ script:
   - python setup.py develop
   - coverage run -m unittest discover
   - codecov
+matrix:
+  fast_finish: true
+  allow_failures:
+  - python: "pypy3"
index 49c965048e3848a13462ff96d21a9f9b1e26963f..eb8a71e0233554469d6f887ff73aeda9cfc4ffe2 100644 (file)
@@ -20,7 +20,12 @@ def get_var_name(depth=2, default=_raise_exception):
 
     code = frame.f_code
     call_index = frame.f_lasti
-    call_opc   = opname[code.co_code[call_index]]
+    while True:
+        call_opc   = opname[code.co_code[call_index]]
+        if call_opc in ("EXTENDED_ARG"):
+            call_index += 2
+        else:
+            break
     if call_opc not in ("CALL_FUNCTION", "CALL_FUNCTION_KW", "CALL_FUNCTION_EX", "CALL_METHOD"):
         return None