GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: adapt to a 3.13 change in frame.f_lasti · coveragepy/coveragepy@f4c7a19

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • coverage
    • ctracer
      • tracer.c
      • util.h
    • env.py
    • pytracer.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎coverage/ctracer/tracer.c‎

Copy file name to clipboardExpand all lines: coverage/ctracer/tracer.c
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,10 @@ CTracer_handle_return(CTracer *self, PyFrameObject *frame)
710710
real_return = TRUE;
711711
}
712712
else {
713-
real_return = (code_bytes[lasti + 2] != RESUME);
713+
#if ENV_LASTI_IS_YIELD
714+
lasti += 2;
715+
#endif
716+
real_return = (code_bytes[lasti] != RESUME);
714717
}
715718
#else
716719
/* Need to distinguish between RETURN_VALUE and YIELD_VALUE. Read
Collapse file

‎coverage/ctracer/util.h‎

Copy file name to clipboardExpand all lines: coverage/ctracer/util.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
#define MyCode_FreeCode(code)
6060
#endif
6161

62+
// 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.
64+
// https://github.com/python/cpython/issues/113728
65+
#define ENV_LASTI_IS_YIELD (PY_VERSION_HEX < 0x030D0000)
66+
6267
/* The values returned to indicate ok or error. */
6368
#define RET_OK 0
6469
#define RET_ERROR -1
Collapse file

‎coverage/env.py‎

Copy file name to clipboardExpand all lines: coverage/env.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class PYBEHAVIOR:
117117
# PEP669 Low Impact Monitoring: https://peps.python.org/pep-0669/
118118
pep669 = bool(getattr(sys, "monitoring", None))
119119

120+
# Where does frame.f_lasti point when yielding from a generator?
121+
# It used to point at the YIELD, now it points at the RESUME.
122+
# https://github.com/python/cpython/issues/113728
123+
lasti_is_yield = (PYVERSION < (3, 13))
124+
120125

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

Collapse file

‎coverage/pytracer.py‎

Copy file name to clipboardExpand all lines: coverage/pytracer.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222

2323
# We need the YIELD_VALUE opcode below, in a comparison-friendly form.
24+
# PYVERSIONS: RESUME is new in Python3.11
2425
RESUME = dis.opmap.get("RESUME")
2526
RETURN_VALUE = dis.opmap["RETURN_VALUE"]
2627
if RESUME is None:
@@ -137,7 +138,7 @@ def _trace(
137138
if THIS_FILE in frame.f_code.co_filename:
138139
return None
139140

140-
#self.log(":", frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name + "()", event)
141+
# self.log(":", frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name + "()", event)
141142

142143
if (self.stopped and sys.gettrace() == self._cached_bound_method_trace): # pylint: disable=comparison-with-callable
143144
# The PyTrace.stop() method has been called, possibly by another
@@ -255,8 +256,10 @@ def _trace(
255256
# A return from the end of a code object is a real return.
256257
real_return = True
257258
else:
258-
# it's a real return.
259-
real_return = (code[lasti + 2] != RESUME)
259+
# It is a real return if we aren't going to resume next.
260+
if env.PYBEHAVIOR.lasti_is_yield:
261+
lasti += 2
262+
real_return = (code[lasti] != RESUME)
260263
else:
261264
if code[lasti] == RETURN_VALUE:
262265
real_return = True

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.