{"id":15973709,"url":"https://github.com/c-bata/grpc-issue-proto-finder","last_synced_at":"2025-04-04T16:21:04.020Z","repository":{"id":76859385,"uuid":"383737078","full_name":"c-bata/grpc-issue-proto-finder","owner":"c-bata","description":"A repository for an issue report of gRPC Python library.","archived":false,"fork":false,"pushed_at":"2021-07-08T11:40:55.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-10T01:46:08.391Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/grpc/grpc/issues/26631","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-bata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-07T09:03:18.000Z","updated_at":"2021-07-08T11:40:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"933560c6-962e-4107-9419-f6a956583d26","html_url":"https://github.com/c-bata/grpc-issue-proto-finder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fgrpc-issue-proto-finder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fgrpc-issue-proto-finder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fgrpc-issue-proto-finder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fgrpc-issue-proto-finder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-bata","download_url":"https://codeload.github.com/c-bata/grpc-issue-proto-finder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208404,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T21:06:35.096Z","updated_at":"2025-04-04T16:21:03.992Z","avatar_url":"https://github.com/c-bata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# for https://github.com/grpc/grpc/issues/26631\n\n## Problem Details\n\nI found a bug that it raises ModuleNotFoundError by importing a protoc-generated module after upgraded `grpcio` to `1.38.1` from `1.33.2`.\nAn error trace is like this:\n\n```python\n# Although this program won't raise an ModuleNotFoundError on grpcio==1.33.2,\n# this program will raise an ModuleNotFoundError on grpcio==1.38.1.\nfrom foo import a_pb2_grpc\n\nprint(\"success\")\n```\n\n```\n$ pip freeze | grep grpcio\ngrpcio==1.33.2\ngrpcio-tools==1.33.2\n$ python example1.py \nsuccess\n\n$ pip install -U grpcio grpcio-tools\n$ pip freeze | grep grpcio\ngrpcio==1.38.1\ngrpcio-tools==1.38.1\n$ python example1.py \nTraceback (most recent call last):\n  File \"/Users/a14737/sandbox/protoc-bug-report-proto-finder/example1.py\", line 5, in \u003cmodule\u003e\n    from foo import a_pb2_grpc\n  File \"/Users/a14737/sandbox/protoc-bug-report-proto-finder/foo/a_pb2_grpc.py\", line 5, in \u003cmodule\u003e\n    import a_pb2 as a__pb2\nModuleNotFoundError: No module named 'a_pb2'\n```\n\nThis error is raised by an import lines in `a_pb2_grpc.py`, protoc-generated Python module:\n\n```python\n# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!\n\"\"\"Client and server classes corresponding to protobuf-defined services.\"\"\"\nimport grpc\n\nimport a_pb2 as a__pb2   # ModuleNotFoundError is raised here!!!\n```\n\nIn `grpcio==1.33.2`, it won't raise an exception because `grpc_tools.protoc.ProtoFinder` is set on `sys.meta_path` at `import grpc`.\nBut ProtoFinder is not at `grpcio==1.38.1` due to the change of https://github.com/grpc/grpc/pull/24993.  If I explicitly imports `grpc_tools.protoc` before importing `a_pb2_grpc`, ModuleNotFoundError won't be raised.\n\n```python\n# This works fine with grpcio==1.38.1 because this program explicitly imports\n# \"grpc_tools.protoc\" so that \"grpc_tools.protoc.ProtoFinder\" is set in sys.meta_path.\nimport grpc_tools.protoc\n\nfrom foo import a_pb2_grpc\n\nprint(\"success\")\n```\n\n```\n(venv) $ pip freeze | grep grpcio\ngrpcio==1.38.1\ngrpcio-tools==1.38.1\n\n(venv) $ python example2.py \nsuccess\n```\n\nI think this is a regression bug which introduced by https://github.com/grpc/grpc/pull/24993,\nand we need to import `grpc_tools.protoc` from the `grpc` package as in the previous version.\n\n## Solution\n\nThis problem will be resolved by the following patch:\nhttps://github.com/grpc/grpc/compare/master...c-bata:python-proto-finder?expand=1\n\nBut I'm not sure if it is the correct solution.\n\n\n## Related issues and pull requests.\n\n* https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-772720912\n* https://github.com/protocolbuffers/protobuf/pull/7470\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fgrpc-issue-proto-finder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-bata%2Fgrpc-issue-proto-finder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fgrpc-issue-proto-finder/lists"}