Remove iOS-specific code from platform.py and webbrowser.py

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-28 21:12:11 +00:00
parent c919018c78
commit 6f5cb9488c
3 changed files with 5 additions and 112 deletions

11
.gitignore vendored
View File

@@ -70,17 +70,6 @@ Lib/test/data/*
/_bootstrap_python
/Makefile
/Makefile.pre
/iOSTestbed.*
iOS/Frameworks/
iOS/Resources/Info.plist
iOS/testbed/build
iOS/testbed/Python.xcframework/ios-*/bin
iOS/testbed/Python.xcframework/ios-*/include
iOS/testbed/Python.xcframework/ios-*/lib
iOS/testbed/Python.xcframework/ios-*/Python.framework
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
Mac/Makefile
Mac/PythonLauncher/Info.plist
Mac/PythonLauncher/Makefile

View File

@@ -505,28 +505,6 @@ def mac_ver(release='', versioninfo=('', '', ''), machine=''):
return release, versioninfo, machine
# A namedtuple for iOS version information.
IOSVersionInfo = collections.namedtuple(
"IOSVersionInfo",
["system", "release", "model", "is_simulator"]
)
def ios_ver(system="", release="", model="", is_simulator=False):
"""Get iOS version information, and return it as a namedtuple:
(system, release, model, is_simulator).
If values can't be determined, they are set to values provided as
parameters.
"""
if sys.platform == "ios":
import _ios_support
result = _ios_support.get_platform_ios()
if result is not None:
return IOSVersionInfo(*result)
return IOSVersionInfo(system, release, model, is_simulator)
def _java_getprop(name, default):
"""This private helper is deprecated in 3.13 and will be removed in 3.15"""
@@ -1058,10 +1036,6 @@ def uname():
system = 'Android'
release = android_ver().release
# Normalize responses on iOS
if sys.platform == 'ios':
system, release, _, _ = ios_ver()
vals = system, node, release, version, machine
# Replace 'unknown' values with the more portable ''
_uname_cache = uname_result(*map(_unknown_as_blank, vals))
@@ -1347,14 +1321,11 @@ def platform(aliased=False, terse=False):
system, release, version = system_alias(system, release, version)
if system == 'Darwin':
# macOS and iOS both report as a "Darwin" kernel
if sys.platform == "ios":
system, release, _, _ = ios_ver()
else:
macos_release = mac_ver()[0]
if macos_release:
system = 'macOS'
release = macos_release
# macOS reports as a "Darwin" kernel
macos_release = mac_ver()[0]
if macos_release:
system = 'macOS'
release = macos_release
if system == 'Windows':
# MS platforms

View File

@@ -488,9 +488,6 @@ def register_standard_browsers():
# macOS can use below Unix support (but we prefer using the macOS
# specific stuff)
if sys.platform == "ios":
register("iosbrowser", None, IOSBrowser(), preferred=True)
if sys.platform == "serenityos":
# SerenityOS webbrowser, simply called "Browser".
register("Browser", None, BackgroundBrowser("Browser"))
@@ -652,70 +649,6 @@ if sys.platform == 'darwin':
rc = osapipe.close()
return not rc
#
# Platform support for iOS
#
if sys.platform == "ios":
from _ios_support import objc
if objc:
# If objc exists, we know ctypes is also importable.
from ctypes import c_void_p, c_char_p, c_ulong
class IOSBrowser(BaseBrowser):
def open(self, url, new=0, autoraise=True):
sys.audit("webbrowser.open", url)
# If ctypes isn't available, we can't open a browser
if objc is None:
return False
# All the messages in this call return object references.
objc.objc_msgSend.restype = c_void_p
# This is the equivalent of:
# NSString url_string =
# [NSString stringWithCString:url.encode("utf-8")
# encoding:NSUTF8StringEncoding];
NSString = objc.objc_getClass(b"NSString")
constructor = objc.sel_registerName(b"stringWithCString:encoding:")
objc.objc_msgSend.argtypes = [c_void_p, c_void_p, c_char_p, c_ulong]
url_string = objc.objc_msgSend(
NSString,
constructor,
url.encode("utf-8"),
4, # NSUTF8StringEncoding = 4
)
# Create an NSURL object representing the URL
# This is the equivalent of:
# NSURL *nsurl = [NSURL URLWithString:url];
NSURL = objc.objc_getClass(b"NSURL")
urlWithString_ = objc.sel_registerName(b"URLWithString:")
objc.objc_msgSend.argtypes = [c_void_p, c_void_p, c_void_p]
ns_url = objc.objc_msgSend(NSURL, urlWithString_, url_string)
# Get the shared UIApplication instance
# This code is the equivalent of:
# UIApplication shared_app = [UIApplication sharedApplication]
UIApplication = objc.objc_getClass(b"UIApplication")
sharedApplication = objc.sel_registerName(b"sharedApplication")
objc.objc_msgSend.argtypes = [c_void_p, c_void_p]
shared_app = objc.objc_msgSend(UIApplication, sharedApplication)
# Open the URL on the shared application
# This code is the equivalent of:
# [shared_app openURL:ns_url
# options:NIL
# completionHandler:NIL];
openURL_ = objc.sel_registerName(b"openURL:options:completionHandler:")
objc.objc_msgSend.argtypes = [
c_void_p, c_void_p, c_void_p, c_void_p, c_void_p
]
# Method returns void
objc.objc_msgSend.restype = None
objc.objc_msgSend(shared_app, openURL_, ns_url, None, None)
return True
def parse_args(arg_list: list[str] | None):
import argparse