Skip to content

Commit

Permalink
fix: the bytecode for yields was only different for 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Aug 8, 2024
1 parent b9501d6 commit c3c91f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions coverage/ctracer/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@
#endif

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

/* The values returned to indicate ok or error. */
#define RET_OK 0
Expand Down
5 changes: 3 additions & 2 deletions coverage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ class PYBEHAVIOR:
pep669 = bool(getattr(sys, "monitoring", None))

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


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

0 comments on commit c3c91f1

Please sign in to comment.