George-Ogden · GitHub

Bug report

Bug description:

import inspect
def source_error(*args):
    frame = inspect.currentframe()
    if frame is None:
        return
    frame = frame.f_back
    if frame is None:
        return
    print(inspect.getsource(frame))
def demo():
    loops = (
        None for _ in [0] if source_error(True)
    )
    list(loops)
demo()

Expected output:

def demo():
    loops = (
        None for _ in [0] if source_error(True)
    )
    list(loops)

Actual output:

    loops = (

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗