Skip to content

sys.platform android & ios #5921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2025
Merged
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
7 changes: 5 additions & 2 deletions vm/src/stdlib/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ mod sys {
#[pyattr(name = "platform")]
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
Copy link
Member

Choose a reason for hiding this comment

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

Ok, unlike this link, it is finally changed!

if #[cfg(target_os = "linux")] {
"linux"
} else if #[cfg(target_os = "android")] {
"android"
} else if #[cfg(target_os = "macos")] {
"darwin"
} else if #[cfg(target_os = "ios")] {
"ios"
Comment on lines +72 to +77

Choose a reason for hiding this comment

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

medium

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 ios

Adding tests would improve the robustness of this change.

} else if #[cfg(windows)] {
"win32"
} else if #[cfg(target_os = "wasi")] {
Expand Down
Loading