From e835d368bd504761ac47142f063b731daa02a4f2 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 10 Sep 2020 19:26:43 -0400 Subject: [PATCH] Fix import errors on Windows --- tools/distrib/python/grpcio_tools/grpc_tools/protoc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py b/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py index e03acb69f9d..d07daba2c06 100644 --- a/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py +++ b/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py @@ -146,12 +146,14 @@ if sys.version_info >= (3, 5, 0): self._codegen_fn = codegen_fn def find_spec(self, fullname, path, target=None): + if not fullname.endswith(self._suffix): + return None filepath = _module_name_to_proto_file(self._suffix, fullname) for search_path in sys.path: try: prospective_path = os.path.join(search_path, filepath) os.stat(prospective_path) - except (FileNotFoundError, NotADirectoryError): + except (FileNotFoundError, NotADirectoryError, OSError): continue else: return importlib.machinery.ModuleSpec(