deepcopy of DateWithMeta / TimeWithMeta / DateTimeWithMeta raises ValueError
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Inizia leggendo le definizioni di DateWithMeta, TimeWithMeta e DateTimeWithMeta in rune/runtime/metadata, in particolare new e serialise_meta. Riproduci l’errore segnalato con copy.deepcopy, poi verifica come ogni classe gestisce la copia. Il lavoro è concluso quando le copie superficiali e profonde mantengono il valore e i metadati senza sollevare ValueError; l’issue non indica alcun file di test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- Python
- Stelle
- 0
- Fork
- 4
- Merge medio
- 1g 11h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di finos/rune-python-runtime
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
finos/rune-python-runtime#52 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
finos/rune-python-runtime#51 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
finos/rune-python-runtime#48 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
finos/rune-python-runtime#47 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
finos/rune-python-runtime#43 ·
Tutte le issue di finos/rune-python-runtime
Issue simili
-
resource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
hesreallyhim/awesome-claude-code#3214 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
doobidoo/mcp-memory-service#1650 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ml-explore/mlx-lm#2002 ·
I maintainer di solito rispondono entro 2 giorni