Skip to content

Missing test for docstring-handling code in ast_opt.c #123942

Closed
@iritkatriel

Description

@iritkatriel

astfold_body has a block of code that checks whether const folding created something that looks like a docstring, which was not there before. If it did, then we have a string that came out of folding a const expression. This is not recognised by Python as a docstring, so in order to prevent the compiler from recognising it as such, the astfold_body converts the AST node into a const f-string node (_PyAST_JoinedStr), which is also not recognised as a docstring.

This is not covered by tests, so it took me a while to figure out what's going on. I'll add the test.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions