-
Notifications
You must be signed in to change notification settings - Fork 15.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure-Python extension does not work with Python 3.12 #12187
Comments
Hello @haberman, have you had a chance to look into this? Unblocking this would allow us to test about 60 other packages depending on protobuf with upcoming Python 3.12. |
What is the right fix here? Would you be able to send a PR? |
I am sorry, but I've no idea. I pinged you because you were assigned to this issue. |
I think this python/cpython#98963 |
The only docstrings ever set via a doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name which does not sound meaningfully informative. I suspect we could just stop passing doc=doc to the property super class constructor in the - property.__init__(self, getter, setter, doc=doc)
+ super().__init__(getter, setter) |
For whatever reasons... that doesn't really work. What I think I'm seeing so far is that 3.12 a class inheriting from property cannot use |
Okay, we've restored the no-AttributeError behavior upstream, 3.12beta2 should include the fix. |
As _FieldProperty instance docstrings are silently never set anyways, I do recommend that the protobuf code simplify itself and not bother constructing and passing the meaningless doc= parameter in python_message.py: - doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name
- setattr(cls, property_name, _FieldProperty(field, getter, setter, doc=doc))
+ setattr(cls, property_name, _FieldProperty(field, getter, setter)) |
I tried to remove doc=doc but it raises:
|
Will close this issue as python team has restored the no-AttributeError behavior upstream. Python 3.12beta2 and above will not have this issue. Feel free to reopen if this is not fixed after Python 3.12beta2 |
What version of protobuf and what language are you using?
Version: 3.19.6
The line that sets the docstring is present in the current release (22.1) and
main
, so I suspect that they will also be affected:protobuf/python/google/protobuf/internal/python_message.py
Line 708 in 6545c67
Language: Python
What operating system (Linux, Windows, ...) and version?
Fedora Linux Rawhide/39, plus experimental Python 3.12: https://copr.fedorainfracloud.org/coprs/g/python/python3.12/
What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.12.0a5, GCC 13.0.1
What did you do?
Steps to reproduce the behavior:
from google.protobuf import descriptor_pb2
This import occurred in the generated proto bindings in
googleapis-common-protos
; see downstream bug https://bugzilla.redhat.com/show_bug.cgi?id=2176158.What did you expect to see
Successful import with no output.
What did you see instead?
Anything else we should know about your project / environment
See also: #12186
The text was updated successfully, but these errors were encountered: