Repository navigation
Preserve float-subclass values in time.sleep conversion - #9292
Conversation
Follow CPython PyFloat_AsDouble without calling float-subclass overrides. Keep index precedence and other conversion behavior unchanged. Assisted-by: OpenAI Codex
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
✨ Finishing Touches
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. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Read the stored value of float instances and subclasses in time.sleep instead of calling an overridden float. This follows CPython 3.15.0 PyFloat_AsDouble behavior. Keep index precedence and the existing non-float conversion path, rounding, range checks, audit ordering and platform sleep implementation unchanged.
A float subclass can currently change whether sleep rejects a negative value by overriding float, or raise an exception that CPython never requests. This narrow native fix extracts that behavior from #8954 without adding an unused PyTime helper module or moving the surrounding conversion code. No Lib changes or new Rust Python-behavior tests.
Validation
Tested base:
43368209c505c8807f5efdf3a39729bb30866722.self.t = time.time()was omitted because this method does not use it; the method and assertions are unchanged. This is selected-method evidence, not whole-module coverage.Full workspace/CAPI runtime suites, release test_time, the whole time test module and positive-duration sleep tests were not run locally. The external observations do not establish cross-platform scheduling behavior or broad PyTime parity.
AI assistance
AI assistance was used for source analysis, implementation and validation preparation.