From f8071c9a9753afefcd0a68ee786670a2e11eb4b3 Mon Sep 17 00:00:00 2001 From: slush Date: Thu, 14 Dec 2017 02:53:42 +0100 Subject: [PATCH] Added compatibility with CPython --- tools/pb2py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/pb2py b/tools/pb2py index ef61d7e9..6375858f 100755 --- a/tools/pb2py +++ b/tools/pb2py @@ -12,7 +12,12 @@ from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper def process_type(t, cls, msg_id, indexfile, is_upy): print(" * type %s" % t) - imports = [] + if is_upy: + imports = ['import protobuf as p'] + else: + imports = ['from __future__ import absolute_import', + 'from .. import protobuf as p'] + out = ["", "", "class %s(p.MessageType):" % t, ] if cls.DESCRIPTOR.fields_by_name: