Discussion:
Bug#1095574: bookworm-pu: package dacite/dacite
Add Reply
Valentin Vidic
2025-02-09 12:50:01 UTC
Reply
Permalink
Package: release.debian.org
Severity: normal
Tags: bookworm
User: ***@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 <***@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?= <***@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
Debian Bug Tracking System
2025-02-18 21:30:02 UTC
Reply
Permalink
tag -1 confirmed
Bug #1095574 [release.debian.org] bookworm-pu: package dacite/dacite
Added tag(s) confirmed.
--
1095574: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095574
Debian Bug Tracking System
Contact ***@bugs.debian.org with problems
Jonathan Wiltshire
2025-02-18 21:30:02 UTC
Reply
Permalink
Control: tag -1 confirmed

Please go ahead.

Thanks,
--
Jonathan Wiltshire ***@debian.org
Debian Developer http://people.debian.org/~jmw

4096R: 0xD3524C51 / 0A55 B7C5 1223 3942 86EC 74C3 5394 479D D352 4C51
ed25519/0x196418AAEB74C8A1: CA619D65A72A7BADFC96D280196418AAEB74C8A1
Valentin Vidic
2025-02-19 20:40:01 UTC
Reply
Permalink
Post by Jonathan Wiltshire
Control: tag -1 confirmed
Please go ahead.
Thanks, just uploaded.
--
Valentin
Jonathan Wiltshire
2025-02-28 22:30:01 UTC
Reply
Permalink
package release.debian.org
tags 1095574 = bookworm pending
thanks

Hi,

The upload referenced by this bug report has been flagged for acceptance into the proposed-updates queue for Debian bookworm.

Thanks for your contribution!

Upload details
==============

Package: dacite
Version: 1.8.0-1+deb12u1

Explanation: do not cache result of get_default_value_for_field

Loading...