Skip to content
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

Deepcopy of Month-based Duration produces a different duration #714

Closed
2 tasks done
Gamrix opened this issue Jun 14, 2023 · 0 comments
Closed
2 tasks done

Deepcopy of Month-based Duration produces a different duration #714

Gamrix opened this issue Jun 14, 2023 · 0 comments

Comments

@Gamrix
Copy link

Gamrix commented Jun 14, 2023

Checks:

  • I am on the latest Pendulum version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • OS version and name: MacOS Ventura 13.4 (22F66)

  • ** Python Version** '3.9.16 (main, Feb 14 2023, 12:36:00) \n[Clang 14.0.0 (clang-1400.0.29.202)]'

  • Pendulum version: 2.1.2

Issue

When a Duration object with a month attribute copied using copy.deepcopy, the result is a Duration that has day-based intervals instead of month-based intervals.

Repro:

from copy import deepcopy
from pendulum.datetime import DateTime
from pendulum.duration import Duration

cycle_interval = Duration(months=1)
cycle_interval
# Duration(months=1)

copy_attempt = deepcopy(Duration(months=1))
copy_attempt
# Duration(weeks=4, days=2)

I would expect copy_attempt to also be a Duration(months=1)

sdispater added a commit that referenced this issue Aug 15, 2023
@Secrus Secrus closed this as completed in 071bf63 Aug 15, 2023
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

No branches or pull requests

1 participant