Updating multiline output can insert invalid Python quote delimiters
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 45/100
Research direction
The payload names run_print_update() and example.source but not the file that writes printed output back into examples, so search for run_print_update first. Reproduce with an example whose print output contains a triple-quote delimiter, in both the Markdown and Python-docstring variants. Done means example.source compiles after the update in both cases, and the output still matches the printed text.
Written by the indexing model from the issue text.
Description
Reproduced on main at df945f7043cb8c456359b01700f3d664d30fbe44.
Multiline printed text is inserted between triple-quote delimiters without checking whether the text contains the chosen delimiter. An example printing a line of three double quotes in Markdown, or three single quotes in a Python docstring example, produces an early-closed or unterminated string after output updating.
With --update-examples enabled, update an example whose print output is first line, then the chosen triple-quote delimiter, then last line. Compile example.source after run_print_update(): it raises SyntaxError. Both Markdown and Python-docstring delimiter variants reproduce.
Expected: checking/updating output preserves valid Python print semantics and produces compilable source.
Contract: https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
Both delimiter regressions fail before the fix and pass afterward. The independently checked full local suite passes 83 tests with one expected failure and the known Windows object-address case deselected.
Relevant current and closed PR patches and issue discussions were checked; this does not duplicate the existing object-address, set-output, control-flow, metadata or indentation fixes.
- Dominant language
- Python
- Stars
- 181
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydantic/pytest-examples
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
pydantic/pytest-examples#102 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pydantic/pytest-examples#87 ·
-
Clean up NeededPossibly taken @Danipulok claimed this 86 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pydantic/pytest-examples#72 · 5 comments ·
-
Print checking swallows writes to explicit output streamsPossibly taken @vinsymoyya claimed this 13 days ago. Open
Difficulty 3/5 Half a day Newbie friendliness 22/100
pydantic/pytest-examples#96 · 1 comment ·
-
Inline backticks truncate fenced Python examplesPossibly taken @vinsymoyya claimed this 13 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
pydantic/pytest-examples#94 · 1 comment ·
All issues in pydantic/pytest-examples
Similar issues
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
Maintainers usually reply within 1 day
-
CI: MSYS2 jobs fail — mingw python3 package renamed upstream to pythonPossibly taken @ronaldtse claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
huggingface/lighteval#1534 ·
Maintainers usually reply within 1 day