Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/stdlib/src/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ mod _locale {
fn check_locale_name(locale: &str) -> bool {
if let Some(dot_pos) = locale.find('.') {
let encoding_part = &locale[dot_pos + 1..];
// Find the end of encoding (could be followed by '@' modifier)
let encoding_len = encoding_part.find('@').unwrap_or(encoding_part.len());
encoding_len <= MAX_CP_LEN
encoding_part.len() <= MAX_CP_LEN
} else {
true
}
Expand Down
14 changes: 14 additions & 0 deletions extra_tests/snippets/stdlib_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import locale
import sys

from testutils import assert_raises

# Windows counts the modifier toward the code-page length before calling the CRT.
if sys.platform == "win32":
for category, name in (
(locale.LC_CTYPE, "English.1252@" + "x" * 16),
(locale.LC_ALL, "LC_CTYPE=English.1252@" + "x" * 16),
Comment on lines +9 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the prohibited new locale test

This new snippet adds test logic and data, but the root AGENTS.md restricts test-file changes to adding or removing expected-failure decorators and associated TODO comments; these new LC_CTYPE/LC_ALL cases therefore violate the repository's critical test-modification policy and should be removed from this change.

AGENTS.md reference: AGENTS.md:L273-L279

Useful? React with 👍 / 👎.

):
with assert_raises(locale.Error) as caught:
locale.setlocale(category, name)
assert caught.exception.args == ("unsupported locale setting",)
Loading