deepcopy of DateWithMeta / TimeWithMeta / DateTimeWithMeta raises ValueError
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
Línea de trabajo
Empieza leyendo las definiciones de DateWithMeta, TimeWithMeta y DateTimeWithMeta en rune/runtime/metadata, especialmente new y serialise_meta. Reproduce el fallo informado con copy.deepcopy y luego comprueba cómo gestiona cada clase la copia. Se considera terminado cuando las copias superficiales y profundas conservan el valor y los metadatos sin generar ValueError; el issue no menciona ningún archivo de pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- Python
- Estrellas
- 0
- Forks
- 4
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de finos/rune-python-runtime
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
finos/rune-python-runtime#52 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
finos/rune-python-runtime#51 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
finos/rune-python-runtime#48 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
finos/rune-python-runtime#47 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
finos/rune-python-runtime#43 ·
Todos los issues de finos/rune-python-runtime
Issues similares
-
good first issue priority: low size: XS testing
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
cubrid-lab/cubrid-mcp-server#385 ·
Los mantenedores suelen responder en 1 día
-
good first issue priority: low size: S testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
cubrid-lab/cubrid-cookbook-python#447 ·
Los mantenedores suelen responder en 1 día
-
Python PointcloudAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ArduCAM/Arducam_tof_camera#125 ·
-
area:curator enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
CassioDalla/Scrinalia#150 ·
Los mantenedores suelen responder en 1 día
-
Tutorial notebook: Find the leakAbiertodocumentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100