GeezerVison is showing github.com — Preserve Unicode strftime output in non-UTF-8 locales by youknowdot · Pull Request #9050 · RustPython/RustPython
Conversation
youknowdot
commented
Oct 10, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Extract the independent Linux/macOS strftime locale-output fix from #8954 (43065e79ddc46eafeca58cb39398ac007b5d25f7) onto Python 3.14 main (3af5f8a15314446d2b28a90e429c938dc7b8beeb).
Use wcsftime on Linux and macOS rather than interpreting narrow libc output as UTF-8. This preserves localized month/day text when the selected locale uses another encoding. Windows is unchanged, and other Unix targets retain the existing narrow fallback, including OpenBSD.
The production hunks are taken directly from the pinned mega PR and match CPython 3.14.7's wide-formatting path. No Python 3.15 behavior or unrelated migration changes are included. Searches found no dedicated duplicate; merged #7090 is Windows-specific, and #7671 covers earlier Unicode literal passthrough.
Add bounded coverage to the existing time snippet for localized output, Unicode/surrogate/NUL composition, and buffer growth. Save/set/restore LC_ALL, since macOS's libc conversion also depends on LC_CTYPE. Locales remain optional for hosts where they are not installed; the local verification explicitly exercised both rather than silently skipping them.
Validation
- Exact CPython 3.14.7: complete updated snippet passes; both French ISO-8859-1 and UTF-8 locale paths executed.
- Unchanged native main fails the new localized-month assertion; this head passes the full snippet and its pytest entry.
- Native proof explicitly verifies both
LC_TIME and LC_CTYPE are set to each requested locale and produces the correct Unicode month in both encodings.
- All 5 existing canonical
TimeTestCase strftime tests pass, including Unicode/surrogate/NUL and format/bounds checks.
- Host-environment Clippy and separate C-API Clippy with warnings denied; normal repository commit hooks.
- Independent source review checked the FFI signature, platform
wchar_t layout, initialized buffers, lengths, lifetimes and growth, and caught/corrected the macOS locale-category test assumption.
No canonical assertions, implementation-name guards, or README text were changed; no Rust behavioral tests were added. Native validation is Linux-only, not a complete workspace or macOS execution claim. Full hosted CI is pending; this remains a draft for review.
AI-assisted implementation and validation with OpenAI Codex; model identifier unavailable. No human review is implied.
Summary by CodeRabbit
- Bug Fixes
- Date and time formatting on Linux and macOS now better supports Unicode, including non-English month names and emoji in format strings.
- Invalid characters in formatted output are replaced safely, and longer formatted results are supported.
- Embedded NUL characters in format strings are rejected. Other Unix platforms retain their existing formatting behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Assisted-by: OpenAI Codex:model identifier unavailable
coderabbitai
Bot
commented
Oct 10, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b29e5231-7e55-40e7-b708-1d969380b8c9
📥 Commits
-
Reviewing files that changed from the base of the PR and between 3af5f8a and fd23fb6.
📒 Files selected for processing (2)
-
crates/host_env/src/time.rs
extra_tests/snippets/stdlib_time.py
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
📝 Walkthrough
-
Walkthrough
Linux and macOS now use wcsftime for strftime formatting. The implementation handles embedded NUL formats, grows the output buffer, and replaces values that cannot be represented as Unicode. Tests cover available French locales.
Changes
Unicode strftime
| Layer / File(s) |
Summary |
Wide-character formatting and validation crates/host_env/src/time.rs, extra_tests/snippets/stdlib_time.py |
Linux and macOS use wcsftime; other Unix targets retain narrow strftime. Tests check formatting with available French locales, including Unicode and special characters. |
Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: youknowone
Merge Risk: ⚪ Minimal · up to fd23f
This change preserves localized Unicode strftime output on Linux and macOS. No actionable merge-blocking risk was identified; hosted CI and macOS validation remain pending.
Pre-merge checks | 5
-
✅ Passed checks (5 passed)
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title clearly and concisely describes the main change: preserving Unicode output from strftime in non-UTF-8 locales. |
| Docstring Coverage |
 |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-10T11:04:19.851627Z |
fd23fb6 |
Draft marked ready |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd23fb61de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
}
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
// These Unix platforms provide wcsftime, which returns locale text as Unicode.
|
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.
Add the required AI-assistance trailer
This commit states that it was AI-assisted, but its message ends with prose rather than the mandatory Assisted-by: AGENT_NAME:MODEL_VERSION trailer, so it does not meet the repository's critical disclosure policy; add the prescribed trailer before landing.
AGENTS.md reference: AGENTS.md:L20-L23
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
except locale.Error:
|
|
|
continue
|
|
|
february = (2024, 2, 1, 12, 0, 0, 3, 32, 0)
|
|
|
assert time.strftime("%B", february) == "février"
|
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.
Remove the prohibited test logic
The newly added locale block changes test data, control flow, and assertions in an existing snippet test, but the repository's critical test-file policy permits only expected-failure decorator and associated TODO edits. Drop this regression block rather than modifying stdlib_time.py as part of the fix.
AGENTS.md reference: AGENTS.md:L273-L279
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|