tracer: add PyPy support to get_var_name().

Fixes #141.
This commit is contained in:
Jacob Lifshay 2019-07-09 00:29:01 -07:00 committed by whitequark
parent 367ad5aee7
commit 62b3e36612
2 changed files with 11 additions and 1 deletions

View file

@ -3,6 +3,7 @@ language: python
python: python:
- "3.6" - "3.6"
- "3.7" - "3.7"
- "pypy3"
cache: cache:
directories: directories:
- "$HOME/.ccache" - "$HOME/.ccache"
@ -23,3 +24,7 @@ script:
- python setup.py develop - python setup.py develop
- coverage run -m unittest discover - coverage run -m unittest discover
- codecov - codecov
matrix:
fast_finish: true
allow_failures:
- python: "pypy3"

View file

@ -20,7 +20,12 @@ def get_var_name(depth=2, default=_raise_exception):
code = frame.f_code code = frame.f_code
call_index = frame.f_lasti 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"): if call_opc not in ("CALL_FUNCTION", "CALL_FUNCTION_KW", "CALL_FUNCTION_EX", "CALL_METHOD"):
return None return None