Skip to content

gh-145642: Match tutorial output to real interpreter output#145643

Merged
nedbat merged 2 commits intopython:mainfrom
SnoopJ:doc/gh145642_describe-syntaxwarning
Mar 8, 2026
Merged

gh-145642: Match tutorial output to real interpreter output#145643
nedbat merged 2 commits intopython:mainfrom
SnoopJ:doc/gh145642_describe-syntaxwarning

Conversation

@SnoopJ
Copy link
Contributor

@SnoopJ SnoopJ commented Mar 8, 2026

Closes #145642.

This changeset updates the official tutorial to match real interpreter output for an example that demonstrates escape sequences, namely showing the generated SyntaxWarning.


📚 Documentation preview 📚: https://cpython-previews--145643.org.readthedocs.build/

@SnoopJ
Copy link
Contributor Author

SnoopJ commented Mar 8, 2026

I should note that this update to the docs contains the text that matches Python 3.14's output, but on Python 3.12 and 3.13 the output is more terse:

>>> print('C:\some\name')
<unknown>:1: SyntaxWarning: invalid escape sequence '\s'
C:\some
ame

So this change should not be backported to the docs for those versions as-is. If the docs for these older versions should also be updated, I can submit a separate PR.

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
@SnoopJ
Copy link
Contributor Author

SnoopJ commented Mar 8, 2026

Reworked the example to avoid the invalid escape sequence, per discussion with @nedbat

@picnixz
Copy link
Member

picnixz commented Mar 8, 2026

I should note that this update to the docs contains the text that matches Python 3.14's output, but on Python 3.12 and 3.13 the output is more terse:

With C:\this\name, is the output for 3.13 the same as the one that you have in this PR? if so, we can backport it to 3.13. 3.12 won't get a backport because it's security-only though

@SnoopJ
Copy link
Contributor Author

SnoopJ commented Mar 8, 2026

With C:\this\name, is the output for 3.13 the same as the one that you have in this PR? if so, we can backport it to 3.13. 3.12 won't get a backport because it's security-only though

Yep, output is the same on 3.13 and 3.14 so this can be backported.

@nedbat nedbat merged commit 5a15a52 into python:main Mar 8, 2026
32 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Mar 8, 2026
@nedbat nedbat added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 8, 2026
@miss-islington-app
Copy link

Thanks @SnoopJ for the PR, and @nedbat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @SnoopJ for the PR, and @nedbat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2026
…utorial (pythonGH-145643)

* Match tutorial output to real interpreter output

* Avoid invalid escape sequence in example

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

---------
(cherry picked from commit 5a15a52)

Co-authored-by: James <snoopjedi@gmail.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2026
…utorial (pythonGH-145643)

* Match tutorial output to real interpreter output

* Avoid invalid escape sequence in example

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

---------
(cherry picked from commit 5a15a52)

Co-authored-by: James <snoopjedi@gmail.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 8, 2026

GH-145646 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 8, 2026
@bedevere-app
Copy link

bedevere-app bot commented Mar 8, 2026

GH-145647 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Mar 8, 2026
picnixz pushed a commit that referenced this pull request Mar 8, 2026
…tutorial (GH-145643) (#145646)

gh-145642: Docs: Avoid warning for invalid escape sequence in tutorial (GH-145643)

---------
(cherry picked from commit 5a15a52)

Co-authored-by: James <snoopjedi@gmail.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
picnixz pushed a commit that referenced this pull request Mar 8, 2026
…tutorial (GH-145643) (#145647)

gh-145642: Docs: Avoid warning for invalid escape sequence in tutorial (GH-145643)

---------
(cherry picked from commit 5a15a52)

Co-authored-by: James <snoopjedi@gmail.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Tutorial does not mention SyntaxWarning for invalid escape sequences

3 participants