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

tzicaltvz cannot be pickled #1242

Open
daniele-athome opened this issue Nov 22, 2022 · 1 comment · May be fixed by #1243
Open

tzicaltvz cannot be pickled #1242

daniele-athome opened this issue Nov 22, 2022 · 1 comment · May be fixed by #1243

Comments

@daniele-athome
Copy link

daniele-athome commented Nov 22, 2022

I don't think this needs an example, the issue is quite straightforward. While trying to pickle any datetime object containing a time zone created by dateutil:

TypeError: cannot pickle '_thread.lock' object

The object in question is:

datetime.datetime(2022, 11, 20, 17, 55, tzinfo=<tzicalvtz 'Europe/Rome'>

I understand why this happens: it's caused by the presence of this lock object.

class _tzicalvtz(_tzinfo):
    def __init__(self, tzid, comps=[]):
        super(_tzicalvtz, self).__init__()

        [...]
        self._cache_lock = _thread.allocate_lock()

I understand the presence of the lock itself (#428), can anybody suggest a way to fix this?

P.S. datetime instances are being created by niccokunzmann/python-recurring-ical-events.

Thanks for your help!

@daniele-athome
Copy link
Author

Ok it might be enough to create the special methods that are used by the pickle module. I'll try and get back with a PR if successful.

daniele-athome added a commit to daniele-athome/dateutil that referenced this issue Nov 22, 2022
@daniele-athome daniele-athome linked a pull request Nov 22, 2022 that will close this issue
3 tasks
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 a pull request may close this issue.

1 participant