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 — Set line number on the POP_TOP that follows a RETURN_GENERATOR · Issue #109923 · python/cpython

Set line number on the POP_TOP that follows a RETURN_GENERATOR #109923

New issue
Copy link
New issue
Copy link
Closed
#109924
Closed
Set line number on the POP_TOP that follows a RETURN_GENERATOR#109923
#109924
Copy link

Description

@iritkatriel
iritkatriel
opened on Sep 26, 2023
Issue body actions

Currently the POP_TOP of a generator doesn't get a line number.
If we give it the same line number as the RETURN_GENERATOR and RESUME, that will reduce the size of the line number table.

The missing line number also got in my way while working on #109094.

>>> def f(): yield 42
... 
>>> dis.dis(f)
   1           0 RETURN_GENERATOR

None           2 POP_TOP

   1           4 RESUME                   0
               6 LOAD_CONST               1 (42)
               8 YIELD_VALUE              1
              10 RESUME                   1
              12 POP_TOP
              14 RETURN_CONST             0 (None)

None     >>   16 CALL_INTRINSIC_1         3 (INTRINSIC_STOPITERATION_ERROR)
              18 RERAISE                  1
ExceptionTable:
  4 to 14 -> 16 [0] lasti

Linked PRs

  • gh-109923: set line number on the POP_TOP that follows a RETURN_GENERATOR #109924
Reacted by Guido van Rossum and Donghee Na

Activity

  1. iritkatriel
    added 2 commits that reference this issue on Sep 26, 2023

    pythongh-109923: set line number on the POP_TOP that follows a RETURN…

    1cbf607

    pythongh-109923: set line number on the POP_TOP that follows a RETURN…

    6cb83e6
  2. markshannon commented on Sep 27, 2023

    @markshannon
    markshannon
    on Sep 27, 2023
    Member
    More actions

    The POP_TOP always comes before the RESUME, so the line number should never be visible.

    I agree it is worth doing in order to reduce the size of the table, but I'm curious how it helped with #109094.

  3. iritkatriel commented on Sep 27, 2023

    @iritkatriel
    iritkatriel
    on Sep 27, 2023
    MemberAuthor
    More actions

    I'm curious how it helped with #109094.

    There's a test that throws into a newly created generator. The instr_ptr points to the POP_TOP and the prev_instr points to the RETURN_GENERATOR so that line number in the traceback was different.

  4. iritkatriel
    closed this as completedin #109924on Sep 27, 2023
  5. iritkatriel
    added a commit that references this issue on Sep 27, 2023

    gh-109923: set line number on the POP_TOP that follows a RETURN_GENER…

    ea285ad
  6. csm10495
    added a commit that references this issue on Sep 28, 2023

    pythongh-109923: set line number on the POP_TOP that follows a RETURN…

    64fcb92
  7. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-109923: set line number on the POP_TOP that follows a RETURN…

    7e9a34f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.