From c261b49a9575226efc9e5d269f6e5319a05d526e Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Tue, 5 Nov 2024 11:30:32 -0800 Subject: [PATCH] Breaking change: Remove deprecated GetPrototype MessageFactory.GetPrototype(), MessageFactory.CreatePrototype(), MessageFactory.GetMessages(), SymbolDatabase.GetPrototype(), SymbolDatabase.CreatePrototype(), SymbolDatabase.GetMessages() Replacement APIs are: message_factory.GetMessages(), message_factory.GetMessageClass(), message_factory.GetMessageClassesForFiles() PiperOrigin-RevId: 693421414 --- .../Reflection/FeatureSetDescriptor.g.cs | 17 ----- python/google/protobuf/message_factory.py | 63 ------------------- python/google/protobuf/symbol_database.py | 22 ------- 3 files changed, 102 deletions(-) delete mode 100644 csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs deleted file mode 100644 index 208ce1fcb6319..0000000000000 --- a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs +++ /dev/null @@ -1,17 +0,0 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd -#endregion - -namespace Google.Protobuf.Reflection; - -internal sealed partial class FeatureSetDescriptor -{ - // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. - private const string DefaultsBase64 = - "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; -} diff --git a/python/google/protobuf/message_factory.py b/python/google/protobuf/message_factory.py index 05e330d076869..9b64ff05b846c 100644 --- a/python/google/protobuf/message_factory.py +++ b/python/google/protobuf/message_factory.py @@ -142,69 +142,6 @@ def __init__(self, pool=None): """Initializes a new factory.""" self.pool = pool or descriptor_pool.DescriptorPool() - def GetPrototype(self, descriptor): - """Obtains a proto2 message class based on the passed in descriptor. - - Passing a descriptor with a fully qualified name matching a previous - invocation will cause the same class to be returned. - - Args: - descriptor: The descriptor to build from. - - Returns: - A class describing the passed in descriptor. - """ - warnings.warn( - 'MessageFactory class is deprecated. Please use ' - 'GetMessageClass() instead of MessageFactory.GetPrototype. ' - 'MessageFactory class will be removed after 2024.', - stacklevel=2, - ) - return GetMessageClass(descriptor) - - def CreatePrototype(self, descriptor): - """Builds a proto2 message class based on the passed in descriptor. - - Don't call this function directly, it always creates a new class. Call - GetMessageClass() instead. - - Args: - descriptor: The descriptor to build from. - - Returns: - A class describing the passed in descriptor. - """ - warnings.warn( - 'Directly call CreatePrototype is wrong. Please use ' - 'GetMessageClass() method instead. Directly use ' - 'CreatePrototype will raise error after July 2023.', - stacklevel=2, - ) - return _InternalCreateMessageClass(descriptor) - - def GetMessages(self, files): - """Gets all the messages from a specified file. - - This will find and resolve dependencies, failing if the descriptor - pool cannot satisfy them. - - Args: - files: The file names to extract messages from. - - Returns: - A dictionary mapping proto names to the message classes. This will include - any dependent messages as well as any messages defined in the same file as - a specified message. - """ - warnings.warn( - 'MessageFactory class is deprecated. Please use ' - 'GetMessageClassesForFiles() instead of ' - 'MessageFactory.GetMessages(). MessageFactory class ' - 'will be removed after 2024.', - stacklevel=2, - ) - return GetMessageClassesForFiles(files, self.pool) - def GetMessages(file_protos, pool=None): """Builds a dictionary of all the messages available in a set of files. diff --git a/python/google/protobuf/symbol_database.py b/python/google/protobuf/symbol_database.py index e9a731a3c0a3b..a538d5d6da750 100644 --- a/python/google/protobuf/symbol_database.py +++ b/python/google/protobuf/symbol_database.py @@ -51,28 +51,6 @@ def __init__(self, pool=None): """Initializes a new SymbolDatabase.""" self.pool = pool or descriptor_pool.DescriptorPool() - def GetPrototype(self, descriptor): - warnings.warn( - 'SymbolDatabase.GetPrototype() is deprecated. Please ' - 'use message_factory.GetMessageClass() instead. ' - 'SymbolDatabase.GetPrototype() will be removed in Jan 2025.' - ) - return message_factory.GetMessageClass(descriptor) - - def CreatePrototype(self, descriptor): - warnings.warn('Directly call CreatePrototype() is wrong. Please use ' - 'message_factory.GetMessageClass() instead. ' - 'SymbolDatabase.CreatePrototype() will be removed in ' - 'Jan 2025.') - return message_factory._InternalCreateMessageClass(descriptor) - - def GetMessages(self, files): - warnings.warn('SymbolDatabase.GetMessages() is deprecated. Please use ' - 'message_factory.GetMessageClassedForFiles() instead. ' - 'SymbolDatabase.GetMessages() will be removed in ' - 'Jan 2025.') - return message_factory.GetMessageClassedForFiles(files, self.pool) - def RegisterMessage(self, message): """Registers the given message type in the local database.