deepcopy of DateWithMeta / TimeWithMeta / DateTimeWithMeta raises ValueError
まだ誰も着手していません。
評価
調査の方向性
まず rune/runtime/metadata にある DateWithMeta、TimeWithMeta、DateTimeWithMeta の定義、特に new と serialise_meta を読んでください。copy.deepcopy で報告された失敗を再現し、各クラスがコピーをどのように処理するか確認してください。浅いコピーと深いコピーのどちらでも、ValueError を発生させずに値とメタデータが保持されれば完了です。issue ではテストファイルは指定されていません。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
Steps to Reproduce:
- Create a DateWithMeta (or TimeWithMeta / DateTimeWithMeta) instance.
- Call copy.deepcopy() on it — this occurs internally whenever
_clone_for_write or model_copy(deep=True) is used on an object that
contains a date/time-with-meta field.
Expected Result:
A new DateWithMeta (or TimeWithMeta / DateTimeWithMeta) is returned with
the same value and metadata as the original.
Actual Result:
ValueError is raised:
"DateWithMeta can be instantiated only with one of the following type(s):
(<class 'datetime.date'>, <class 'str'>), however the value is of type
<class 'bytes'>."
Environment:
rune-python-runtime 2.2.2, pydantic 2.14.1, Python 3.11
Additional Context:
datetime.date.reduce_ex returns a raw-bytes representation for pickling.
Python's deepcopy uses this protocol, calling
DateWithMeta.new(DateWithMeta, bytes). DateWithMeta.new calls
_check_type, which rejects bytes. The same crash affects TimeWithMeta and
DateTimeWithMeta.
Fix: add deepcopy (and copy) overrides to each class that reconstruct
via cls(value, **self.serialise_meta()), bypassing the C-level pickling path.
import copy
import datetime
import pytest
from rune.runtime.metadata import DateWithMeta, TimeWithMeta, DateTimeWithMeta
def test_r4_datewithmeta_deepcopy_raises():
'''copy.deepcopy(DateWithMeta(...)) raises ValueError because
datetime.date.__reduce_ex__ passes raw bytes to DateWithMeta.__new__,
which _check_type rejects.'''
d = DateWithMeta('2024-01-15')
with pytest.raises(ValueError, match='bytes'):
copy.deepcopy(d)
def test_r4_timewithmeta_deepcopy_raises():
'''copy.deepcopy(TimeWithMeta(...)) raises ValueError for the same reason.'''
t = TimeWithMeta('10:30:00')
with pytest.raises(ValueError, match='bytes'):
copy.deepcopy(t)
def test_r4_datetimewithmeta_deepcopy_raises():
'''copy.deepcopy(DateTimeWithMeta(...)) raises ValueError for the same reason.'''
dt = DateTimeWithMeta('2024-01-15T10:30:00')
with pytest.raises(ValueError, match='bytes'):
copy.deepcopy(dt)
- 主要言語
- Python
- スター
- 0
- フォーク
- 4
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
finos/rune-python-runtime のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
finos/rune-python-runtime#52 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
finos/rune-python-runtime#51 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
finos/rune-python-runtime#48 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
finos/rune-python-runtime#47 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
finos/rune-python-runtime#43 ·
finos/rune-python-runtime の issue をすべて見る
似ている issue
-
good first issue priority: low size: XS testing
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
cubrid-lab/cubrid-mcp-server#385 ·
メンテナーはふだん 1 日以内に返信
-
good first issue priority: low size: S testing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
cubrid-lab/cubrid-cookbook-python#447 ·
メンテナーはふだん 1 日以内に返信
-
Python Pointcloudオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ArduCAM/Arducam_tof_camera#125 ·
-
area:curator enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
CassioDalla/Scrinalia#150 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100