Closed
Description
Encountered this issue while testing Python 3.13.0rc2
. To reproduce
import proto
__protobuf__ = proto.module(
package="some_module",
manifest={"View", "Encoding"},
)
class View(proto.Enum):
A = 0
class Encoding(proto.Enum):
B = 0
$ python test.py
Traceback (most recent call last):
File "/.../proto-plus-python/test.py", line 11, in <module>
class Encoding(proto.Enum):
B = 0
File "/.../proto-plus-python/proto/enums.py", line 105, in __new__
file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../proto-plus-python/proto/_file_info.py", line 104, in generate_file_pb
pool.Add(self.descriptor)
~~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'some_module.__firstlineno__'
$ pip list
Package Version
---------- -------
pip 24.2
proto-plus 1.24.0
protobuf 5.28.2
--
AFAICT the issue shows up as soon as two proto.Enum
are defined in one module. A quick experiment suggests that the reason might be here
proto-plus-python/proto/enums.py
Lines 72 to 78 in e5e8533
The attributes are only filtered by
if isinstance(number, int)
. Python 3.13 added the new __firstlineno__
attribute which is an integer and as such not filtered as it should be. Just changing the condition here would be enough to resolve it, just not sure that's the best option as I'm unfamiliar with the code base.
-if isinstance(number, int)
+if isinstance(number, int) and name != "__firstlineno__"