From 96c0838ba65c87adaa0610d3edadc02756a80de3 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Sat, 15 Jul 2023 15:48:13 +0100 Subject: [PATCH] Python 3.12 compat: Include new return opcodes --- pysnooper/tracer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 0f35500..badefdd 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -21,6 +21,11 @@ if pycompat.PY2: ipython_filename_pattern = re.compile('^$') ansible_filename_pattern = re.compile(r'^(.+\.zip)[/|\\](ansible[/|\\]modules[/|\\].+\.py)$') +RETURN_OPCODES = { + 'RETURN_GENERATOR', 'RETURN_VALUE', 'RETURN_CONST', + 'INSTRUMENTED_RETURN_GENERATOR', 'INSTRUMENTED_RETURN_VALUE', + 'INSTRUMENTED_RETURN_CONST', 'YIELD_VALUE', 'INSTRUMENTED_YIELD_VALUE' +} def get_local_reprs(frame, watch=(), custom_repr=(), max_length=None, normalize=False): @@ -527,8 +532,7 @@ class Tracer: ended_by_exception = ( event == 'return' and arg is None - and (opcode.opname[code_byte] - not in ('RETURN_VALUE', 'YIELD_VALUE')) + and opcode.opname[code_byte] not in RETURN_OPCODES ) if ended_by_exception: