Skip to content

Remove unnecessary trailing backslashes #135781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

rffontenelle
Copy link
Contributor

@rffontenelle rffontenelle commented Jun 21, 2025

The trailing backlash doesn't seem to be needed. Besides, they are extracted by Sphinx gettext builder as part of the translation string, which can lead to wrong translation.


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

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any noticeable change in the rendered documentation, but if this affects translations then it's worthwhile. @StanFromIreland, can you confirm?

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When gettext extracts it, it escapes the \. The result looks like this:

#: ../../c-api/extension-modules.rst:245
msgid ""
"``_testsinglephase`` is an internal module used \\ in CPython's self-test "
"suite; your installation may or may not \\ include it."
msgstr ""

This will confuse translators, and they may leave it in, which will result in them appearing in the build. A prior similar pr: #135013 We should probably note this in the devguide, I will add it to my list.

@tomasr8
Copy link
Member

tomasr8 commented Jun 21, 2025

Off-topic, but maybe also something to be fixed in Sphinx's gettext extraction? ISTM the backslashes should not be extracted, what do you think?

@StanFromIreland
Copy link
Member

I agree the behaviour is weird and there is a bug in Sphinx which should also be fixed, but I’m not quite sure what we would want exactly, I will look into what GNU xgettext does.

@ZeroIntensity
Copy link
Member

Ok, I'm going to merge this. @picnixz, as a Sphinx wizard, could you possibly look into fixing this upstream?

@ZeroIntensity ZeroIntensity merged commit 6a16b3c into python:main Jun 21, 2025
40 checks passed
@miss-islington-app
Copy link

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

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jun 21, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 21, 2025
This fixes Sphinx's gettext extraction for translations.
(cherry picked from commit 6a16b3c)

Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 21, 2025

GH-135791 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 Jun 21, 2025
ZeroIntensity pushed a commit that referenced this pull request Jun 21, 2025
…135791)

Docs: Remove unnecessary trailing backslashes (GH-135781)

This fixes Sphinx's gettext extraction for translations.
(cherry picked from commit 6a16b3c)

Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
@picnixz
Copy link
Member

picnixz commented Jun 21, 2025

as a Sphinx wizard, could you possibly look into fixing this upstream?

Yes, I can. IIRC it should be in https://github.com/sphinx-doc/sphinx/blob/c384ab96c328c3abc91b39c9e3e527863df30af1/sphinx/util/nodes.py#L292. I'll make the heuristic of only removing trailing backslashes from it.

@picnixz
Copy link
Member

picnixz commented Jun 21, 2025

@ZeroIntensity or @rffontenelle could you open a Sphinx issue and tag me there? (just check that there isn't one existing)

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 issue skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants