-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-89039: call subclass constructors in datetime.*.replace #114780
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-89039: call subclass constructors in datetime.*.replace #114780
Conversation
When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called. Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored.
ac7f8e2
to
b5ebbc5
Compare
@serhiy-storchaka This is a follow-up to #112921 to fix another issue. Would appreciate if you could take a look. |
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.
LGTM. I have only few style nitpicks.
Thanks @eltoder for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @eltoder for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, @eltoder and @serhiy-storchaka, I could not cleanly backport this to
|
Sorry, @eltoder and @serhiy-storchaka, I could not cleanly backport this to
|
Thank you for your contribution @eltoder. Do you mind to create a backport for 3.12? |
@serhiy-storchaka Thank you for merging. Can we just backport #112921? Then this will work automatically. Or should I write a version of this change that doesn't use argument clinic? |
Usually we do not backport conversions to Argument Clinic and pure optimizations. Although if it is a straightforward backport that helps future backports, there may be exceptions. But seems that this is not the case. There are some conflicts in backporting of #112921, so they may be not so trivial. It may be safer to not backport it. |
@serhiy-storchaka The conflicts were very easy to resolve. I did it here: #115344 But I get a complaint from CI that the ABI changed. Is that correct or a false positive? |
It does not allow to merge the PR without sanction of the Release Manager. |
@serhiy-storchaka What would you recommend? The backport itself is trivial, but it does change the size of pyruntimestate. Does this really affect the ABI? I see that there were some updates to it on the 3.12 branch by @ericsnowcurrently after 3.12 was released: https://github.com/python/cpython/commits/3.12/Doc/data/python3.12.abi |
Correct. The runtime state struct is strictly internal, so we do sometimes change the related (internal) ABI in bug fix releases. |
@ericsnowcurrently Do you think it is acceptable to change pyruntimestate to backport #112921? I used argument clinic and it added some new string constants. |
I don't see a problem with it, but release manager makes the final decision. |
…honGH-114780) When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called. Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored.
…ce (pythonGH-114780) When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called. Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored. (cherry picked from commit 46190d9) Co-authored-by: Eugene Toder <eltoder@users.noreply.github.com>
GH-131239 is a backport of this pull request to the 3.12 branch. |
…-114780) (GH-131239) When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called. Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored. (cherry picked from commit 46190d9) Co-authored-by: Eugene Toder <eltoder@users.noreply.github.com>
When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called.
Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored.