# Bug report ### Bug description: ```python 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 <!-- gh-linked-prs --> ### Linked PRs * gh-137479 * gh-137488 * gh-137993 * gh-137995 <!-- /gh-linked-prs -->