From baacac8dff45b2a327ce1853195bdef67957c0a4 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 15 Jun 2024 08:05:30 +0800 Subject: [PATCH] gh-117398: Use the correct module loader for iOS in datetime CAPI test. (#120477) Use the correct loader for iOS. --- Lib/test/datetimetester.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 70e2e2cccdc55fa..e55b738eb4a9751 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -6786,6 +6786,13 @@ def test_datetime_from_timestamp(self): self.assertEqual(dt_orig, dt_rt) def test_type_check_in_subinterp(self): + # iOS requires the use of the custom framework loader, + # not the ExtensionFileLoader. + if sys.platform == "ios": + extension_loader = "AppleFrameworkLoader" + else: + extension_loader = "ExtensionFileLoader" + script = textwrap.dedent(f""" if {_interpreters is None}: import _testcapi as module @@ -6795,7 +6802,7 @@ def test_type_check_in_subinterp(self): import importlib.util fullname = '_testcapi_datetime' origin = importlib.util.find_spec('_testcapi').origin - loader = importlib.machinery.ExtensionFileLoader(fullname, origin) + loader = importlib.machinery.{extension_loader}(fullname, origin) spec = importlib.util.spec_from_loader(fullname, loader) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module)