Skip to content

frame->f_lasti will be removed in Python 3.11 #1241

@encukou

Description

@encukou

Describe the bug
In Python 3.11, the f_lasti member of PyFrameObject will be removed.
AFAIK, the quickened interpreter uses a different strategy to track what it's executing; a byte offset into original bytecode would need to be computed from other data (and probably wouldn't make sense in some cases).

This is an early heads-up; you might want to be part of the conversation in CPython so a better API can be designed for coverage's use case.
AFAICS, coverage uses f_lasti for generators, but I'm not really sure what the code is actually doing. Should CPython add API for telling just-started generator apart from a resuming generator, for example?

To Reproduce

  1. What version of Python are you using? CPython 3.11.0a1+, main branch (380c440875)
  2. What version of coverage.py are you using? master branch (0eaeb99f2d)
  3. What versions of what packages do you have installed? Nothing extra; pip freeze output is empty
  4. What commands did you run? python3 setup.py build
...
coverage/ctracer/tracer.c: In function ‘CTracer_handle_call’:
coverage/ctracer/tracer.c:552:14: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_lasti’
  552 |     if (frame->f_lasti < 0) {
      |              ^~
In file included from coverage/ctracer/tracer.c:6:
coverage/ctracer/tracer.c: In function ‘CTracer_handle_return’:
coverage/ctracer/util.h:18:31: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_lasti’
   18 | #define MyFrame_lasti(f)    (f->f_lasti * 2)
      |                               ^~
coverage/ctracer/tracer.c:719:25: note: in expansion of macro ‘MyFrame_lasti’
  719 |             int lasti = MyFrame_lasti(frame);
      |                         ^~~~~~~~~~~~~
**
** Couldn't install with extension module, trying without it...
** BuildFailed: command '/usr/lib64/ccache/gcc' failed with exit code 1
**

Expected behavior
The extension compiles :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions