GeezerVison is showing github.com — gh-98963: Restore the ability to have a dict-less property. by gpshead · Pull Request #105262 · python/cpython
Conversation
gpshead
commented
Jun 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
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.)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This behavior is weird but it's consistent with how 3.11 works, so let's merge it.
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 getter.__doc__ feels weird, but that behavior might honestly be what we want in all cases in the long run so removing it as my initial version of this PR did felt unwise as it could lead to people unintentionally writing code that doesn't work across multiple versions if we ever choose to do that.
|
JelleZijlstra reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @gpshead for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gpshead
commented
Jun 5, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
I wish github would've preserved the much longer commit message I authored for later when auto merge was disabled. :(
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gpshead
added a commit
that referenced
this pull request
Jun 5, 2023
…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 <[email protected]>
I wish github would've preserved the much longer commit message I authored for later when auto merge was disabled. :(
Sorry for that!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
encukou
Awaiting requested review from encukou
Yhg1s
Awaiting requested review from Yhg1s
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|