sys.platform android & ios#5921
Conversation
WalkthroughThe update modifies the conditional compilation logic for the Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md) List of files the instruction was applied to:
🧠 Learnings (2)📓 Common learningsvm/src/stdlib/sys.rs (3)✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Summary of Changes
Hello @ShaharNaveh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refines the sys.platform constant within the sys module to provide more accurate and distinct operating system identification. It separates Android from the generic Linux classification and introduces specific support for iOS, ensuring better compatibility and alignment with standard Python behavior on mobile platforms.
Highlights
- Android Platform Identification: The
sys.platformconstant has been updated to return'android'when the code is compiled for an Android target operating system. Previously, Android targets were identified as'linux', aligning with Python 3.13's updated behavior forsys.platform. - iOS Platform Support: New conditional compilation logic has been introduced to correctly identify and return
'ios'for thesys.platformconstant when the code is compiled for an iOS target.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request updates sys.platform to return 'android' on Android devices and 'ios' on iOS devices, aligning with CPython 3.13 and 3.9 specifications respectively. The implementation correctly uses conditional compilation flags. My main feedback is to suggest adding test cases to Lib/test/test_sys.py to cover these new platforms, which will help ensure correctness and prevent future regressions.
| } else if #[cfg(target_os = "android")] { | ||
| "android" | ||
| } else if #[cfg(target_os = "macos")] { | ||
| "darwin" | ||
| } else if #[cfg(target_os = "ios")] { | ||
| "ios" |
There was a problem hiding this comment.
This change correctly implements the sys.platform value for Android and iOS, aligning with modern CPython behavior. To ensure these changes are validated and to prevent future regressions, it would be beneficial to add corresponding test cases in Lib/test/test_sys.py.
For example, you could add checks similar to existing ones for other platforms in SysModuleTest.test_thread_info:
# In Lib/test/test_sys.py
elif sys.platform == "android":
# assertions for android
elif sys.platform == "ios":
# assertions for iosAdding tests would improve the robustness of this change.
| pub(crate) const PLATFORM: &str = { | ||
| cfg_if::cfg_if! { | ||
| if #[cfg(any(target_os = "linux", target_os = "android"))] { | ||
| // Android is linux as well. see https://bugs.python.org/issue32637 |
There was a problem hiding this comment.
Ok, unlike this link, it is finally changed!
Starting from 3.13,
sys.platformnow returns 'android' if running on an android device. See notes at https://docs.python.org/3/library/sys.html#sys.platformAdded "ios" support as well
Summary by CodeRabbit