8000 gh-89039: call subclass constructors in datetime.*.replace by eltoder · Pull Request #114780 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged

Conversation

eltoder
Copy link
Contributor
@eltoder eltoder commented Jan 31, 2024

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.

8000
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.
@eltoder eltoder force-pushed the feature/datetime-replace-subclass branch from ac7f8e2 to b5ebbc5 Compare January 31, 2024 02:33
@eltoder
Copy link
Contributor Author
eltoder commented Jan 31, 2024

@serhiy-storchaka This is a follow-up to #112921 to fix another issue. Would appreciate if you could take a look.

Copy link
Member
@serhiy-storchaka serhiy-storchaka left a 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.

@serhiy-storchaka serhiy-storchaka merged commit 46190d9 into python:main Feb 12, 2024
@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 12, 2024
@miss-islington-app
Copy link

Thanks @eltoder for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @eltoder for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @eltoder and @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 46190d9ea8a878a03d95b4e1bdcdc9ed576cf3fa 3.12

@miss-islington-app
Copy link

Sorry, @eltoder and @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 46190d9ea8a878a03d95b4e1bdcdc9ed576cf3fa 3.11

@serhiy-storchaka
Copy link
Member

Thank you for your contribution @eltoder. Do you mind to create a backport for 3.12?

@eltoder
Copy link
Contributor Author
eltoder commented Feb 12, 2024

@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?

@eltoder eltoder deleted the feature/datetime-replace-subclass branch February 12, 2024 13:31
@serhiy-storchaka
Copy link
Member

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.

@eltoder
Copy link
Contributor Author
eltoder commented Feb 12, 2024

@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?

@serhiy-storchaka
Copy link
Member

It does not allow to merge the PR without sanction of the Release Manager.

8000

@eltoder
Copy link
Contributor Author
eltoder commented Feb 12, 2024

@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
Maybe pyruntimestate is not really a part of the ABI?

@ericsnowcurrently
Copy link
Member

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
Maybe pyruntimestate is not really a part of the ABI?

Correct. The runtime state struct is strictly internal, so we do sometimes change the related (internal) ABI in bug fix releases.

@eltoder
Copy link
Contributor Author
eltoder commented Feb 13, 2024

@ericsnowcurrently Do you think it is acceptable to change pyruntimestate to backport #112921? I used argument clinic and it added some new string constants.

@ericsnowcurrently
Copy link
Member

I don't see a problem with it, but release manager makes the final decision.

fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
…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.
@ZeroIntensity ZeroIntensity removed the needs backport to 3.11 only security fixes label Feb 17, 2025
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Mar 14, 2025
…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>
@bedevere-app
Copy link
bedevere-app bot commented Mar 14, 2025

GH-131239 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 14, 2025
serhiy-storchaka added a commit that referenced this pull request Apr 2, 2025
…-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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0