@@ -482,100 +482,6 @@ static PyObject* FindAllExtensions(PyObject* self, PyObject* arg) {
482482 return result.release ();
483483}
484484
485- // These functions should not exist -- the only valid way to create
486- // descriptors is to call Add() or AddSerializedFile().
487- // But these AddDescriptor() functions were created in Python and some people
488- // call them, so we support them for now for compatibility.
489- // However we do check that the existing descriptor already exists in the pool,
490- // which appears to always be true for existing calls -- but then why do people
491- // call a function that will just be a no-op?
492- // TODO: Need to investigate further.
493-
494- static PyObject* AddFileDescriptor (PyObject* self, PyObject* descriptor) {
495- const FileDescriptor* file_descriptor =
496- PyFileDescriptor_AsDescriptor (descriptor);
497- if (!file_descriptor) {
498- return nullptr ;
499- }
500- if (file_descriptor !=
501- reinterpret_cast <PyDescriptorPool*>(self)->pool ->FindFileByName (
502- file_descriptor->name ())) {
503- PyErr_Format (PyExc_ValueError,
504- " The file descriptor %s does not belong to this pool" ,
505- file_descriptor->name ().c_str ());
506- return nullptr ;
507- }
508- Py_RETURN_NONE;
509- }
510-
511- static PyObject* AddDescriptor (PyObject* self, PyObject* descriptor) {
512- const Descriptor* message_descriptor =
513- PyMessageDescriptor_AsDescriptor (descriptor);
514- if (!message_descriptor) {
515- return nullptr ;
516- }
517- if (message_descriptor !=
518- reinterpret_cast <PyDescriptorPool*>(self)->pool ->FindMessageTypeByName (
519- message_descriptor->full_name ())) {
520- PyErr_Format (PyExc_ValueError,
521- " The message descriptor %s does not belong to this pool" ,
522- message_descriptor->full_name ().c_str ());
523- return nullptr ;
524- }
525- Py_RETURN_NONE;
526- }
527-
528- static PyObject* AddEnumDescriptor (PyObject* self, PyObject* descriptor) {
529- const EnumDescriptor* enum_descriptor =
530- PyEnumDescriptor_AsDescriptor (descriptor);
531- if (!enum_descriptor) {
532- return nullptr ;
533- }
534- if (enum_descriptor !=
535- reinterpret_cast <PyDescriptorPool*>(self)->pool ->FindEnumTypeByName (
536- enum_descriptor->full_name ())) {
537- PyErr_Format (PyExc_ValueError,
538- " The enum descriptor %s does not belong to this pool" ,
539- enum_descriptor->full_name ().c_str ());
540- return nullptr ;
541- }
542- Py_RETURN_NONE;
543- }
544-
545- static PyObject* AddExtensionDescriptor (PyObject* self, PyObject* descriptor) {
546- const FieldDescriptor* extension_descriptor =
547- PyFieldDescriptor_AsDescriptor (descriptor);
548- if (!extension_descriptor) {
549- return nullptr ;
550- }
551- if (extension_descriptor !=
552- reinterpret_cast <PyDescriptorPool*>(self)->pool ->FindExtensionByName (
553- extension_descriptor->full_name ())) {
554- PyErr_Format (PyExc_ValueError,
555- " The extension descriptor %s does not belong to this pool" ,
556- extension_descriptor->full_name ().c_str ());
557- return nullptr ;
558- }
559- Py_RETURN_NONE;
560- }
561-
562- static PyObject* AddServiceDescriptor (PyObject* self, PyObject* descriptor) {
563- const ServiceDescriptor* service_descriptor =
564- PyServiceDescriptor_AsDescriptor (descriptor);
565- if (!service_descriptor) {
566- return nullptr ;
567- }
568- if (service_descriptor !=
569- reinterpret_cast <PyDescriptorPool*>(self)->pool ->FindServiceByName (
570- service_descriptor->full_name ())) {
571- PyErr_Format (PyExc_ValueError,
572- " The service descriptor %s does not belong to this pool" ,
573- service_descriptor->full_name ().c_str ());
574- return nullptr ;
575- }
576- Py_RETURN_NONE;
577- }
578-
579485// The code below loads new Descriptors from a serialized FileDescriptorProto.
580486static PyObject* AddSerializedFile (PyObject* pself, PyObject* serialized_pb) {
581487 PyDescriptorPool* self = reinterpret_cast <PyDescriptorPool*>(pself);
@@ -689,17 +595,6 @@ static PyMethodDef Methods[] = {
689595 {" SetFeatureSetDefaults" , SetFeatureSetDefaults, METH_O,
690596 " Sets the default feature mappings used during the build." },
691597
692- {" AddFileDescriptor" , AddFileDescriptor, METH_O,
693- " No-op. Add() must have been called before." },
694- {" AddDescriptor" , AddDescriptor, METH_O,
695- " No-op. Add() must have been called before." },
696- {" AddEnumDescriptor" , AddEnumDescriptor, METH_O,
697- " No-op. Add() must have been called before." },
698- {" AddExtensionDescriptor" , AddExtensionDescriptor, METH_O,
699- " No-op. Add() must have been called before." },
700- {" AddServiceDescriptor" , AddServiceDescriptor, METH_O,
701- " No-op. Add() must have been called before." },
702-
703598 {" FindFileByName" , FindFileByName, METH_O,
704599 " Searches for a file descriptor by its .proto name." },
705600 {" FindMessageTypeByName" , FindMessageByName, METH_O,
0 commit comments