Skip to content

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

@Gamrix

Description

@Gamrix

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions