Skip to content

Commit

Permalink
Internal change only
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 513034361
  • Loading branch information
anandolee authored and copybara-github committed Feb 28, 2023
1 parent 10cb456 commit ab6c42b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
25 changes: 7 additions & 18 deletions src/google/protobuf/compiler/python/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ bool Generator::Generate(const FileDescriptor* file,
std::unique_ptr<io::ZeroCopyOutputStream> 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.
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/compiler/python/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename DescriptorT, typename DescriptorProtoT>
void PrintSerializedPbInterval(const DescriptorT& descriptor,
Expand Down

0 comments on commit ab6c42b

Please sign in to comment.