-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-98963: Restore the ability to have a dict-less property. #105262
gh-98963: Restore the ability to have a dict-less property. #105262
Conversation
Ignore doc string assignment failures in `property` as has been the behavior of all past Python releases. One behavior change: The longstanding tested behavior of raising an `AttributeError` when using a slotted no-dict property subclass as a decorator on a getter sporting a docstring is now consistent with the subclassing behavior and does not produce an error.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is weird but it's consistent with how 3.11 works, so let's merge it. (Apart from what I think is an extraneous DECREF.)
Yeah... I can't say this is the overall set of behavior anyone would ever choose. I'm mostly aiming for minimum behavior change vs older Pythons so if we ever want to bother with changing this semi-esoteric edge case we can do it in a planned API change fashion. adding that extra code to retain the AttributeError only when the docstring comes from |
Thanks @gpshead for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
GH-105297 is a backport of this pull request to the 3.12 branch. |
…thonGH-105262) Ignore doc string assignment failures in `property` as has been the behavior of all past Python releases. (cherry picked from commit 418befd) Co-authored-by: Gregory P. Smith <greg@krypto.org>
I wish github would've preserved the much longer commit message I authored for later when auto merge was disabled. :( |
…H-105262) (#105297) gh-98963: Restore the ability to have a dict-less property. (GH-105262) Ignore doc string assignment failures in `property` as has been the behavior of all past Python releases. (the docstring is discarded) (cherry picked from commit 418befd) This fixes a behavior regression in 3.12beta1 where an AttributeError was being raised in a situation it has never been in the past. It keeps the existing unusual single situation where AttributeError does get raised. Existing widely deployed projects depend on this not raising an exception. Co-authored-by: Gregory P. Smith <greg@krypto.org>
Sorry for that! |
Ignore doc string assignment failures in
property
as has been the behavior of all past Python releases.Preserves the one situation in which the AttributeError has always been raised for this property subclass situation:
If the docstring would be applied from a getter function it raises rather than remaining silent. (see the existing test and code comments)
This undoes a behavior regression present in 3.12beta1 that was causing existing widely used library code (Google protobuf) to fail.
property
assumes that its subclasses have __dict__ #98963