python / python/cpython

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

未關閉
#135,201 10 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

3.13 stdlib type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 copyreg.py 第 44 行附近開始,使用 dateutil.tz.tzutc 在 Python 3.13 上重現附帶的 pickle 失敗。將協定 0 和 1 的行為與 Python 3.12 進行比較,然後驗證所選變更能保留正常運作的情況,並正確載入提供的 pickle。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。