Bug#1109030: python3-debian: Release.copy() fails trying to split multivalued fields that have already been split
Emanuele Aina
emanuele.aina at collabora.com
Wed Jul 9 23:10:18 BST 2025
Package: python3-debian
Version: 1.0.1
Severity: normal
X-Debbugs-Cc: emanuele.aina at collabora.com
When trying to copy a `Release` object or any `_multivalued` subclass
the code calls the constructor via `self.__class__(self)` and then the
`_multivalued.__init__()` treats fields in ``_multivalued_fields` as
strings, even though they have already been parsed in the source object.
This leads to the following exception:
Traceback (most recent call last):
File "//home/em/deb822-test.py", line 18, in <module>
r2 = r1.copy()
File "/usr/lib/python3.13/site-packages/debian/deb822.py", line 602, in copy
copy = self.__class__(self)
File "/usr/lib/python3.13/site-packages/debian/deb822.py", line 1761, in __init__
for line in filter(None, contents.splitlines()): # type: str
^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'splitlines'
-- System Information:
Debian Release: trixie/sid
APT prefers testing-security
APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 6.15.4-200.fc42.x86_64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
Versions of packages python3-debian depends on:
ii python3 3.13.3-1
ii python3-charset-normalizer 3.4.2-1
python3-debian recommends no packages.
Versions of packages python3-debian suggests:
pn gpgv <none>
ii python3-apt 3.0.0
pn zstd <none>
-- no debconf information
-------------- next part --------------
import debian
from debian.deb822 import Release
txt = """
Suite: testing
Codename: trixie
MD5Sum:
70ddf531b5b7dbd059eb3fdb88566d4b 1963340 contrib/Contents-all
"""
r1 = Release(txt)
assert "md5sum" in Release._multivalued_fields
assert r1["MD5Sum"] == [
{
"md5sum": "70ddf531b5b7dbd059eb3fdb88566d4b",
"size": "1963340",
"name": "contrib/Contents-all",
}
]
try:
r2 = r1.copy()
except:
print(f"BUG: {debian.__version__ = }")
raise
# BUG: debian.__version__ = '0.1.51.dev2+g67bda81'
# Traceback (most recent call last):
# File "//home/em/deb822-test.py", line 18, in <module>
# r2 = r1.copy()
# File "/usr/lib/python3.13/site-packages/debian/deb822.py", line 602, in copy
# copy = self.__class__(self)
# File "/usr/lib/python3.13/site-packages/debian/deb822.py", line 1761, in __init__
# for line in filter(None, contents.splitlines()): # type: str
# ^^^^^^^^^^^^^^^^^^^
# AttributeError: 'list' object has no attribute 'splitlines'
More information about the pkg-python-debian-maint
mailing list