GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-87281: Improve documentation for locale.setlocale() and locale.getlocale() by serhiy-storchaka · Pull Request #137313 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 1, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: locale.getlocale fails if locale is set #87281

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-87281: Improve documentation for locale.setlocale() and loca…
60a26f7
…le.getlocale()
@serhiy-storchaka
serhiy-storchaka requested a review from malemburg August 1, 2025 18:35
@serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir skip news needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Aug 1, 2025
@github-project-automation github-project-automation Bot added this to Docs PRs Aug 1, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Aug 1, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 1, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 1, 2025
locale.getlocale fails if locale is set #87281
Open
@serhiy-storchaka

serhiy-storchaka commented Aug 1, 2025

Copy link
Copy Markdown
Member Author

Reference to RFC 1766 was incorrect -- RFC 1766 specifies language and territory separated by a minus instead of underscore, and it does not contain much useful information anyway. Also, getlocale() returns the language code in other format on Windows and some other platforms.

getlocale() does not return code "C", it returns (None, None) for the "C" locale.

Added specification of universally accepted formats. Late @modifier will be added for the language code. This will be made less vague when we guarantee these formats.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Aug 1, 2025
View reviewed changes
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Outdated

The format of the *locale* and the language code strings is platform
depended, but the forms ``language[_territory][.encoding][@modifier]``
and ``language[_territory]`` respectively are typically accepted on all

@StanFromIreland StanFromIreland Aug 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
and ``language[_territory]`` respectively are typically accepted on all
and ``language[_territory]`` are typically accepted on all

I'm not sure what this is referring to?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Aug 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It refers to the locale and the language code strings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Aug 2, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If this is not clear, we can only specify format for locale, and then say that the language code has the same format, but without encoding and modifier (support for modifiers will be added in #137253).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@malemburg malemburg Aug 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd write: "the form language[_territory][.encoding][@modifier] is typically accepted".

The second version you mention is already included in this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka @StanFromIreland
Apply suggestions from code review
b78ca1b
Co-authored-by: Stan Ulbrych <[email protected]>
serhiy-storchaka
serhiy-storchaka commented Aug 1, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you for your grammar fixes @StanFromIreland.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Outdated

The format of the *locale* and the language code strings is platform
depended, but the forms ``language[_territory][.encoding][@modifier]``
and ``language[_territory]`` respectively are typically accepted on all

@serhiy-storchaka serhiy-storchaka Aug 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It refers to the locale and the language code strings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
malemburg
malemburg approved these changes Aug 3, 2025
View reviewed changes

@malemburg malemburg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM modulo the small change requests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/locale.rst Outdated

The format of the *locale* and the language code strings is platform
depended, but the forms ``language[_territory][.encoding][@modifier]``
and ``language[_territory]`` respectively are typically accepted on all

@malemburg malemburg Aug 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd write: "the form language[_territory][.encoding][@modifier] is typically accepted".

The second version you mention is already included in this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Aug 3, 2025
@serhiy-storchaka
Add a section for locale names.
10228bc
StanFromIreland
StanFromIreland reviewed Aug 4, 2025
View reviewed changes
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka @StanFromIreland
Apply suggestions from code review
53d7bcb
Co-authored-by: Stan Ulbrych <[email protected]>
StanFromIreland
StanFromIreland reviewed Aug 4, 2025
View reviewed changes
Comment thread Doc/library/locale.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka @StanFromIreland
Update Doc/library/locale.rst
1a16363
Co-authored-by: Stan Ulbrych <[email protected]>
StanFromIreland
StanFromIreland approved these changes Aug 4, 2025
View reviewed changes

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
Add more links.
d3aa0bd
@serhiy-storchaka

serhiy-storchaka commented Aug 12, 2025

Copy link
Copy Markdown
Member Author

I am going to merge this PR tomorrow if there are no new comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka merged commit 15ab457 into python:main Aug 13, 2025
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Aug 13, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 13, 2025
@miss-islington-app

miss-islington-app Bot commented Aug 13, 2025

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka deleted the locale-docs branch August 13, 2025 17:49
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 13, 2025
@serhiy-storchaka @miss-islington
pythongh-87281: Improve documentation for locale.setlocale() and loca…
caea563
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 13, 2025
@serhiy-storchaka @miss-islington
pythongh-87281: Improve documentation for locale.setlocale() and loca…
c85f0d7
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app

bedevere-app Bot commented Aug 13, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2025
@bedevere-app

bedevere-app Bot commented Aug 13, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 13, 2025
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2025
@miss-islington @serhiy-storchaka
[3.13] gh-87281: Improve documentation for locale.setlocale() and loc…
9417ea5
…ale.getlocale() (GH-137313) (GH-137723)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <[email protected]>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@serhiy-storchaka @Agent-Hellboy
pythongh-87281: Improve documentation for locale.setlocale() and loca…
4059f2d
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
hugovk pushed a commit that referenced this pull request Sep 11, 2025
@miss-islington @serhiy-storchaka
[3.14] gh-87281: Improve documentation for locale.setlocale() and loc…
374b242
…ale.getlocale() (GH-137313) (#137722)

Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@malemburg malemburg malemburg approved these changes
@StanFromIreland StanFromIreland StanFromIreland approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @malemburg @StanFromIreland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.