From 3148a1c287eb69b397c940119cd44e5067357e17 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Mon, 2 May 2022 06:00:02 -0400 Subject: [PATCH] fix: default proto package name is the module name, not "" (#309) * fix: default proto package name is the module name, not "" * fix tests * lint --- proto/_package_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proto/_package_info.py b/proto/_package_info.py index d01dd79b..c53a6790 100644 --- a/proto/_package_info.py +++ b/proto/_package_info.py @@ -33,10 +33,11 @@ def compile(name, attrs): # Pull a reference to the module where this class is being # declared. module = sys.modules.get(attrs.get("__module__")) + module_name = module.__name__ if hasattr(module, __name__) else "" proto_module = getattr(module, "__protobuf__", object()) # A package should be present; get the marshal from there. - package = getattr(proto_module, "package", "") + package = getattr(proto_module, "package", module_name) marshal = Marshal(name=getattr(proto_module, "marshal", package)) # Done; return the data.