diff --git a/grpc-1.48.4-find_module.patch b/grpc-1.48.4-find_module.patch index 351ef53..f925d54 100644 --- a/grpc-1.48.4-find_module.patch +++ b/grpc-1.48.4-find_module.patch @@ -1,32 +1,16 @@ -From 2dfcc35ae7429ed2c8e12939ff1c845f80c82b18 Mon Sep 17 00:00:00 2001 +From 01d7101b39dd9049ae3cb9c30195b42ed9c76579 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 20 Jun 2023 11:36:40 -0400 -Subject: [PATCH] Do not use importlib find_module API +Subject: [PATCH 1/2] Do not use importlib find_module API This API was removed in Python 3.12 (https://github.com/python/cpython/issues/98040). Fixes Python 3.12 support in grpcio tests. --- - bazel/_gevent_test_main.py | 4 +++- src/python/grpcio_tests/tests/_loader.py | 4 +++- - 2 files changed, 6 insertions(+), 2 deletions(-) + 1 file changed, 3 insertions(+), 1 deletion(-) -diff --git a/bazel/_gevent_test_main.py b/bazel/_gevent_test_main.py -index f7936daaf0..fabde3a2ba 100644 ---- a/bazel/_gevent_test_main.py -+++ b/bazel/_gevent_test_main.py -@@ -73,7 +73,9 @@ class SingleLoader(object): - tests = [] - for importer, module_name, is_package in pkgutil.walk_packages([os.path.dirname(os.path.relpath(__file__))]): - if pattern in module_name: -- module = importer.find_module(module_name).load_module(module_name) -+ spec = importer.find_spec(module_name) -+ module = importlib.util.module_from_spec(spec) -+ spec.loader.exec_module(module) - tests.append(loader.loadTestsFromModule(module)) - if len(tests) != 1: - raise AssertionError("Expected only 1 test module. Found {}".format(tests)) diff --git a/src/python/grpcio_tests/tests/_loader.py b/src/python/grpcio_tests/tests/_loader.py index 80c107aa8e..c497a9aabd 100644 --- a/src/python/grpcio_tests/tests/_loader.py @@ -45,3 +29,43 @@ index 80c107aa8e..c497a9aabd 100644 -- 2.40.1 + +From a7191f6781674340740896d5a284ab856e596b2e Mon Sep 17 00:00:00 2001 +From: "Benjamin A. Beasley" +Date: Tue, 20 Jun 2023 12:38:23 -0400 +Subject: [PATCH 2/2] More importlib find_module migration + +Do not use importlib find_module API in bazel/_gevent_test_main.py + +This API was removed in Python 3.12 +(https://github.com/python/cpython/issues/98040). +--- + bazel/_gevent_test_main.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/bazel/_gevent_test_main.py b/bazel/_gevent_test_main.py +index f7936daaf0..bec31a911b 100644 +--- a/bazel/_gevent_test_main.py ++++ b/bazel/_gevent_test_main.py +@@ -42,6 +42,7 @@ import unittest + import sys + import os + import pkgutil ++import importlib + + def trace_callback(event, args): + if event in ("switch", "throw"): +@@ -73,7 +74,9 @@ class SingleLoader(object): + tests = [] + for importer, module_name, is_package in pkgutil.walk_packages([os.path.dirname(os.path.relpath(__file__))]): + if pattern in module_name: +- module = importer.find_module(module_name).load_module(module_name) ++ spec = importer.find_spec(module_name) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) + tests.append(loader.loadTestsFromModule(module)) + if len(tests) != 1: + raise AssertionError("Expected only 1 test module. Found {}".format(tests)) +-- +2.40.1 +