[3.13] copyreg._reconstructor failures for protocol 0 and 1 for `dateutil.tz.tzutc` · Issue #135201 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

[3.13] copyreg._reconstructor failures for protocol 0 and 1 for dateutil.tz.tzutc #135201

Open
@moorchegue

Description

@moorchegue

Bug description:

In [25]: pickle.load(open('taskwarrior/f91b9e98-7586-4317-ae52-b516e97209e5', 'rb'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[25], line 1
----> 1 pickle.load(open('taskwarrior/f91b9e98-7586-4317-ae52-b516e97209e5', 'rb'))

File /usr/lib/python3.13/copyreg.py:44, in _reconstructor(cls, base, state)
     41 def _reconstructor(cls, base, state):
     42     if base is object:
     43         #obj = cls.__new__(cls)
---> 44         obj = object.__new__(cls)
     45     else:
     46         obj = base.__new__(cls, state)

TypeError: object.__new__(tzutc) is not safe, use tzutc.__new__()

It seems that cls.__new__(cls) is the correct way to achieve the desired effect for any type of object?

This issue was not present in 3.12, or at least same code on same pickles used to work.

I was not able to reproduce this with arbitrary data serialization/deserialization (e.g. pickle.dump(tzutc(), f); pickle.load(f) works), which suggests this is dependent on how exactly data is structured, and so I'm including the culprit pickle here: 74b9da0a-ab54-437f-9ab5-549e886d3c83.txt

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.