Skip to content

Commit 292f964

Browse files
anandoleecopybara-github
authored andcommitted
Breaking Change: Remove deprecated reflection methods
See https://protobuf.dev/news/2024-10-02/#reflection-methods for detail PiperOrigin-RevId: 688656103
1 parent 12c87c9 commit 292f964

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

python/google/protobuf/reflection.py

-49
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,3 @@
3434
GeneratedProtocolMessageType = message_factory._GENERATED_PROTOCOL_MESSAGE_TYPE
3535

3636
MESSAGE_CLASS_CACHE = {}
37-
38-
39-
# Deprecated. Please NEVER use reflection.ParseMessage().
40-
def ParseMessage(descriptor, byte_str):
41-
"""Generate a new Message instance from this Descriptor and a byte string.
42-
43-
DEPRECATED: ParseMessage is deprecated because it is using MakeClass().
44-
Please use MessageFactory.GetMessageClass() instead.
45-
46-
Args:
47-
descriptor: Protobuf Descriptor object
48-
byte_str: Serialized protocol buffer byte string
49-
50-
Returns:
51-
Newly created protobuf Message object.
52-
"""
53-
warnings.warn(
54-
'reflection.ParseMessage() is deprecated. Please use '
55-
'MessageFactory.GetMessageClass() and message.ParseFromString() instead. '
56-
'reflection.ParseMessage() will be removed in Jan 2025.',
57-
stacklevel=2,
58-
)
59-
result_class = MakeClass(descriptor)
60-
new_msg = result_class()
61-
new_msg.ParseFromString(byte_str)
62-
return new_msg
63-
64-
65-
# Deprecated. Please NEVER use reflection.MakeClass().
66-
def MakeClass(descriptor):
67-
"""Construct a class object for a protobuf described by descriptor.
68-
69-
DEPRECATED: use MessageFactory.GetMessageClass() instead.
70-
71-
Args:
72-
descriptor: A descriptor.Descriptor object describing the protobuf.
73-
Returns:
74-
The Message class object described by the descriptor.
75-
"""
76-
warnings.warn(
77-
'reflection.MakeClass() is deprecated. Please use '
78-
'MessageFactory.GetMessageClass() instead. '
79-
'reflection.MakeClass() will be removed in Jan 2025.',
80-
stacklevel=2,
81-
)
82-
# Original implementation leads to duplicate message classes, which won't play
83-
# well with extensions. Message factory info is also missing.
84-
# Redirect to message_factory.
85-
return message_factory.GetMessageClass(descriptor)

0 commit comments

Comments
 (0)