GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — gh-155245: Fix calendar failing to import when strftime rejects %OB by Sudeep-A-Kulkarni · Pull Request #155317 · python/cpython ConversationSummary
FixWrap the TestingAdded I reproduced the original failure locally first (confirmed the uncaught Fixes gh-155245
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions… %OB
The strftime() call for standalone month names ('%OB'/'%Ob') is evaluated lazily inside set(), outside the try/except that guards the initial _localized_month construction. On platforms where '%O' is accepted at construction but rejected when actually formatting (e.g. under Wine), this raised an uncaught ValueError. Wrap the set() comparisons in their own try/except so we fall back to month_name/month_abbr in that case too.
Adds test_standalone_month_name_survives_lazy_OB_failure to OutputTestCase. It simulates a platform (like Wine) where strftime() accepts '%OB' when a _localized_month is constructed but raises ValueError once the lazy strftime call actually happens inside set(), by reloading the calendar module with a patched datetime.date. Without the fix in calendar.py this test fails with an uncaught ValueError.
|
There was an error while loading. Please reload this page.
|
Hello, I wanted to follow up on this pull request, which has been awaiting review for some time. Please let me know if any changes are needed, or if there is additional information I can provide to help move it forward. Thank you for your time and consideration. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi picnixz, sorry for the delay in answering this directly. I looked into whether a real locale could exercise this instead of mocking, and I don't think one exists for this case. The root cause here isn't locale-specific — it's that Wine's strftime() doesn't support the %O modifier at all, on any locale. glibc, macOS's libc, and Windows's CRT all support %O, so on any environment CI actually runs on, %OB just works and never raises. The only way to get the real ValueError is to run under Wine itself, which isn't something we can do in standard CI. That's why I went with subclassing datetime.date to make strftime raise on %O, rather than picking a locale — it's simulating Wine's missing feature, not a locale quirk. If there's a way to spin up a Wine-based CI job for this I'm open to it, but I don't think a locale swap alone gets us there. I'll also fix the indentation simitana flagged. I have made the requested changes; please review again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please don't hit the button "Update branch", it makes useless notifications: https://devguide.python.org/getting-started/pull-request-lifecycle/#update-branch-button. As for the PR: don't use importlib, use mocks and import_fresh_module helpers. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…portlib.reload Address review feedback from picnixz: rather than monkeypatching datetime.date directly and reloading the shared calendar module with importlib.reload() (which mutated the module for the rest of the test process), patch the 'datetime.date' name with mock.patch() and use test.support.import_helper.import_fresh_module() to get an isolated copy of calendar for the assertion.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
This test doesn't look very useful: it relies on the internals, so even with the test, changes to calendar's logic can still break things on Wine.
Per PEP 11 we can accept their patches that make CPython work on Wine, but testing/supporting/backporting is on whomever builds/runs there.
I'd delete the test from here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if len(set(standalone_month_name)) != len(set(month_name)): | ||
| standalone_month_name = month_name | ||
| if len(set(standalone_month_abbr)) != len(set(month_abbr)): | ||
| standalone_month_abbr = month_abbr |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
AFAICS, you can put these lines in the try block, instead of adding a new block.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
calendar module fails to import on Wine due to incomplete %OB error handling
There was an error while loading. Please reload this page.