Package: release.debian.org
Severity: normal
Tags: bookworm
User: release.debian....@packages.debian.org
Usertags: pu

[ Reason ]
Library included in bookworm contains an important bug causing
it to work incorrectly in some cases.

[ Impact ]
As described in the upstream bug report, the library does not
work correctly when default factory is specified:
https://github.com/konradhalas/dacite/issues/215

[ Tests ]
Unit test for the library pass correctly.

[ Risks ]
Patch removes caching from one call so the risk should be small.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
Remove caching from one call as it results in incorrect behavior:
https://github.com/konradhalas/dacite/pull/216


diff -Nru dacite-1.8.0/debian/changelog dacite-1.8.0/debian/changelog
--- dacite-1.8.0/debian/changelog       2023-02-09 00:37:08.000000000 +0100
+++ dacite-1.8.0/debian/changelog       2025-02-09 13:25:40.000000000 +0100
@@ -1,3 +1,9 @@
+dacite (1.8.0-1+deb12u1) bookworm; urgency=medium
+
+  * Add upstream fix for caching bug (Closes: #1069304)
+
+ -- Valentin Vidic <vvi...@debian.org>  Sun, 09 Feb 2025 13:25:40 +0100
+
 dacite (1.8.0-1) unstable; urgency=medium
 
   * New upstream version 1.8.0
diff -Nru dacite-1.8.0/debian/patches/Fix-cache-bug.patch 
dacite-1.8.0/debian/patches/Fix-cache-bug.patch
--- dacite-1.8.0/debian/patches/Fix-cache-bug.patch     1970-01-01 
01:00:00.000000000 +0100
+++ dacite-1.8.0/debian/patches/Fix-cache-bug.patch     2025-02-09 
13:23:07.000000000 +0100
@@ -0,0 +1,54 @@
+From 02ee99348d4c8354fa309b8d1f3525dafda592e6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Mateusz=20Ciszczo=C5=84?= <cont...@mciszczon.pl>
+Date: Wed, 8 Feb 2023 10:06:26 +0100
+Subject: [PATCH] Remove @cache decorator from get_default_value_for_field
+ (#216)
+
+* Remove @cache decorator from get_default_value_for_field
+
+* Fix default factory identity test for older Python versions
+---
+ dacite/dataclasses.py   |  1 -
+ tests/core/test_base.py | 15 ++++++++++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/dacite/dataclasses.py b/dacite/dataclasses.py
+index d70f423..c06ddc0 100644
+--- a/dacite/dataclasses.py
++++ b/dacite/dataclasses.py
+@@ -11,7 +11,6 @@ class DefaultValueNotFoundError(Exception):
+     pass
+ 
+ 
+-@cache
+ def get_default_value_for_field(field: Field, type_: Type) -> Any:
+     if field.default != MISSING:
+         return field.default
+diff --git a/tests/core/test_base.py b/tests/core/test_base.py
+index 8d82788..a866d57 100644
+--- a/tests/core/test_base.py
++++ b/tests/core/test_base.py
+@@ -1,5 +1,5 @@
+ from dataclasses import dataclass, field
+-from typing import Any, NewType, Optional
++from typing import Any, NewType, Optional, List
+ 
+ import pytest
+ 
+@@ -191,3 +191,16 @@ class X:
+     result = from_dict(X, {"s": "test"})
+ 
+     assert result == X(s=MyStr("test"))
++
++
++def test_dataclass_default_factory_identity():
++    # https://github.com/konradhalas/dacite/issues/215
++    @dataclass
++    class A:
++        name: str
++        items: List[str] = field(default_factory=list)
++
++    a1 = from_dict(A, {"name": "a1"})
++    a2 = from_dict(A, {"name": "a2"})
++
++    assert a1.items is not a2.items
diff -Nru dacite-1.8.0/debian/patches/series dacite-1.8.0/debian/patches/series
--- dacite-1.8.0/debian/patches/series  2023-02-09 00:17:02.000000000 +0100
+++ dacite-1.8.0/debian/patches/series  2025-02-09 13:23:26.000000000 +0100
@@ -1,2 +1,3 @@
 Fix-PKG-INFO-encoding.patch
 Disable-benchmark-autosave.patch
+Fix-cache-bug.patch

Reply via email to