Skip to content

DateTime of version 3.0+ cannot be pickled without timezone #899

Open
@georgpfolz

Description

@georgpfolz
  • I am on the latest Pendulum version.

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

  • OS version and name: MacOS Sonoma 14.6.1, FreeBSD 13.2

  • Python: 3.11

  • Pendulum version: 2.1.2, 3.0, 3.1.0

Issue

Pickling a pendulum DateTime does not work anymore.

import pickle, pendulum
dt = pendulum.now()
with open("datetime.pkl", "wb") as f:
    pickle.dump(dt, f)

This works fine with pendulum 2.1.2, but in 3.0 or 3.1.0 I get:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
_pickle.PicklingError: Cannot pickle a ZoneInfo file from a file stream.

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