From ab6c42bc61ecd6e387441e891d10ed8f4895de14 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Tue, 28 Feb 2023 14:07:01 -0800 Subject: [PATCH] Internal change only PiperOrigin-RevId: 513034361 --- .../protobuf/compiler/python/generator.cc | 25 ++++++------------- .../protobuf/compiler/python/generator.h | 2 -- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index 58ffe0726c..7cc7b324d7 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc @@ -262,9 +262,9 @@ bool Generator::Generate(const FileDescriptor* file, std::unique_ptr output(context->Open(filename)); io::Printer printer(output.get(), '$'); printer.Print( - "from $internal_package$ import descriptor_pb2\n" - "\n", - "internal_package", InternalPackage()); + "from google3.net.google.protobuf.python.internal import " + "descriptor_pb2\n" + "\n"); // For static checkers, we need to explicitly assign to the symbols we // publicly export. @@ -373,11 +373,10 @@ void Generator::PrintTopBoilerplate() const { printer_->Print("import google3\n"); } printer_->Print( - "from $internal_package$ import builder as _builder\n" - "from $public_package$ import descriptor as _descriptor\n" - "from $public_package$ import descriptor_pool as _descriptor_pool\n" - "from $public_package$ import symbol_database as _symbol_database\n", - "internal_package", InternalPackage(), "public_package", PublicPackage()); + "from google.protobuf import descriptor as _descriptor\n" + "from google.protobuf import descriptor_pool as _descriptor_pool\n" + "from google.protobuf import symbol_database as _symbol_database\n" + "from google.protobuf.internal import builder as _builder\n"); printer_->Print("# @@protoc_insertion_point(imports)\n\n"); printer_->Print("_sym_db = _symbol_database.Default()\n"); @@ -1206,16 +1205,6 @@ std::string Generator::ModuleLevelServiceDescriptorName( return name; } -std::string Generator::PublicPackage() const { - return opensource_runtime_ ? "google.protobuf" - : "google3.net.google.protobuf.python.public"; -} - -std::string Generator::InternalPackage() const { - return opensource_runtime_ ? "google.protobuf.internal" - : "google3.net.google.protobuf.python.internal"; -} - // Prints standard constructor arguments serialized_start and serialized_end. // Args: // descriptor: The cpp descriptor to have a serialized reference. diff --git a/src/google/protobuf/compiler/python/generator.h b/src/google/protobuf/compiler/python/generator.h index c5182c42c0..c203cfcba8 100644 --- a/src/google/protobuf/compiler/python/generator.h +++ b/src/google/protobuf/compiler/python/generator.h @@ -163,8 +163,6 @@ class PROTOC_EXPORT Generator : public CodeGenerator { std::string ModuleLevelMessageName(const Descriptor& descriptor) const; std::string ModuleLevelServiceDescriptorName( const ServiceDescriptor& descriptor) const; - std::string PublicPackage() const; - std::string InternalPackage() const; template void PrintSerializedPbInterval(const DescriptorT& descriptor,