Skip to content

Commit c3c91f1

Browse files
committed
fix: the bytecode for yields was only different for 3.13
1 parent b9501d6 commit c3c91f1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

coverage/ctracer/util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@
6060
#endif
6161

6262
// Where does frame.f_lasti point when yielding from a generator?
63-
// It used to point at the YIELD, now it points at the RESUME.
63+
// It used to point at the YIELD, in 3.13 it points at the RESUME,
64+
// then it went back to the YIELD.
6465
// https://github.com/python/cpython/issues/113728
65-
#define ENV_LASTI_IS_YIELD (PY_VERSION_HEX < 0x030D0000)
66+
#define ENV_LASTI_IS_YIELD ((PY_VERSION_HEX & 0xFFFF0000) != 0x030D0000)
6667

6768
/* The values returned to indicate ok or error. */
6869
#define RET_OK 0

coverage/env.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ class PYBEHAVIOR:
120120
pep669 = bool(getattr(sys, "monitoring", None))
121121

122122
# Where does frame.f_lasti point when yielding from a generator?
123-
# It used to point at the YIELD, now it points at the RESUME.
123+
# It used to point at the YIELD, in 3.13 it points at the RESUME,
124+
# then it went back to the YIELD.
124125
# https://github.com/python/cpython/issues/113728
125-
lasti_is_yield = (PYVERSION < (3, 13))
126+
lasti_is_yield = (PYVERSION[:2] != (3, 13))
126127

127128

128129
# Coverage.py specifics, about testing scenarios. See tests/testenv.py also.

0 commit comments

Comments
 (0)