diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-08-23 13:13:59 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-08-30 10:57:37 +1000 |
commit | 4a3fdc0e76c640d550099cecaa41f8c3e1489562 (patch) | |
tree | b2fc93cd2516f431b4066f1f9657347adefcb956 /tests/misc/sys_settrace_features.py | |
parent | 1dedb65e645f72afbd614431435208d687e16992 (diff) |
tests/misc/sys_settrace_features.py: Fix to run on newer CPython.
This test was failing on CPython 3.11 as it now emits `0` as the line
number for the "call" event corresponding to import, where as in 3.6 it had
`1` as the line number.
We maintain the old behavior, but in order to make this test pass on both
CPython versions, the trace handler now converts the `0` to a `1`.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/misc/sys_settrace_features.py')
-rw-r--r-- | tests/misc/sys_settrace_features.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/misc/sys_settrace_features.py b/tests/misc/sys_settrace_features.py index 8a38b7534..84cf875a8 100644 --- a/tests/misc/sys_settrace_features.py +++ b/tests/misc/sys_settrace_features.py @@ -22,7 +22,9 @@ def print_stacktrace(frame, level=0): frame.f_code.co_name, # Keep just the filename. "sys_settrace_" + frame.f_code.co_filename.split("sys_settrace_")[-1], - frame.f_lineno, + max( + 1, frame.f_lineno + ), # CPython 3.11 emits `0` where CPython 3.6 emits `1` for the "call" event corresponding to import. ) ) |