Skip to content

bug(python): _AddEqualsMethod calls _InternalUnpackAny which uses deprecated python MessageFactory #17345

@parthea

Description

@parthea

What version of protobuf and what language are you using?
Version: main/v3.6.0/v3.5.0 etc. (NOTE: please try updating to the latest version of protoc/runtime possible beforehand to attempt to resolve your problem)
Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript
Protobuf @ HEAD
Python

What operating system (Linux, Windows, ...) and version?
Linux 6.6.15-2rodete2-amd64

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.9.16
gcc 13.2.0

What did you do?
Steps to reproduce the behavior:

  1. Clone https://github.com/googleapis/python-logging.git
  2. Install the library with pip install .
  3. Run PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python pytest tests/unit/test__gapic.py::Test__log_entry_mapping_to_pb
  4. See warning below which shows that deprecated function is used in the protobuf API in equals operation
>       self.assertEqual(result, entry_pb)

tests/unit/test__gapic.py:709: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.pyenv/versions/3.9.16/envs/py392/lib/python3.9/site-packages/proto/message.py:871: in __eq__
    return self._pb == other._pb
../../.pyenv/versions/3.9.16/envs/py392/lib/python3.9/site-packages/google/protobuf/internal/python_message.py:980: in __eq__
    if not self.ListFields() == other.ListFields():
../../.pyenv/versions/3.9.16/envs/py392/lib/python3.9/site-packages/google/protobuf/internal/python_message.py:975: in __eq__
    any_a = _InternalUnpackAny(self)
../../.pyenv/versions/3.9.16/envs/py392/lib/python3.9/site-packages/google/protobuf/internal/python_message.py:957: in _InternalUnpackAny
    message_class = factory.GetPrototype(descriptor)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <google.protobuf.symbol_database.SymbolDatabase object at 0x7f417fd17040>, descriptor = <google.protobuf.descriptor.Descriptor object at 0x7f417e4114f0>

    def GetPrototype(self, descriptor):
>     warnings.warn('SymbolDatabase.GetPrototype() is deprecated. Please '
                    'use message_factory.GetMessageClass() instead. '
                    'SymbolDatabase.GetPrototype() will be removed soon.')
E     UserWarning: SymbolDatabase.GetPrototype() is deprecated. Please use message_factory.GetMessageClass() instead. SymbolDatabase.GetPrototype() will be removed soon.

../../.pyenv/versions/3.9.16/envs/py392/lib/python3.9/site-packages/google/protobuf/symbol_database.py:55: UserWarning
==================================================================================================== short test summary info =====================================================================================================
FAILED tests/unit/test__gapic.py::Test__log_entry_mapping_to_pb::test_registered_type - UserWarning: SymbolDatabase.GetPrototype() is deprecated. Please use message_factory.GetMessageClass() instead. SymbolDatabase.GetPrototype() will be removed soon.
===========================

See usage of function MessageFactory.GetPrototype below which was deprecated in c80e7ef

message_class = factory.GetPrototype(descriptor)

What did you expect to see

I didn't expect to see any warnings as my application code does not contain usage of the functions deprecated in c80e7ef

What did you see instead?

I saw

SymbolDatabase.GetPrototype() is deprecated. Please use message_factory.GetMessageClass() instead. SymbolDatabase.GetPrototype() will be removed soon.

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

Please let me know if more information is required.

Metadata

Metadata

Assignees

Labels

inactiveDenotes the issue/PR has not seen activity in the last 90 days.python

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions