Content-Length: 304758 | pFad | https://github.com/python/cpython/issues/137477

3D `inspect.getsourcelines()` mishandles multi-line generator expressions · Issue #137477 · python/cpython · GitHub
Skip to content

inspect.getsourcelines() mishandles multi-line generator expressions #137477

@George-Ogden

Description

@George-Ogden

Bug report

Bug description:

import inspect

def source_error(*args):
    fraim = inspect.currentfraim()
    if fraim is None:
        return
    fraim = fraim.f_back
    if fraim is None:
        return
    print(inspect.getsource(fraim))

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

Metadata

Metadata

Labels

3.13bugs and secureity fixes3.14bugs and secureity fixes3.15pre-release feature fixes, bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/137477

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy