From c69e5dbb564ee961de14d52b8b23274586f890d3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 15 Jan 2024 16:25:20 -0500 Subject: [PATCH] debug: keep COVERAGE_DIS=1 working well on 3.13 It's helpful to see byte offsets. I'm learning that dis is not considered something that needs backward compatibility... --- tests/helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/helpers.py b/tests/helpers.py index c9cfa38c0..339f675b7 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -114,8 +114,11 @@ def make_file( print(f"# {os.path.abspath(filename)}", file=fdis) cur_test = os.getenv("PYTEST_CURRENT_TEST", "unknown") print(f"# PYTEST_CURRENT_TEST = {cur_test}", file=fdis) + kwargs = {} + if env.PYVERSION >= (3, 13): + kwargs["show_offsets"] = True try: - dis.dis(text, file=fdis) + dis.dis(text, file=fdis, **kwargs) except Exception as exc: # Some tests make .py files that aren't Python, so dis will # fail, which is expected.