Bug#1086512: python3-debian: deb822.iter_paragraphs with use_apt_pkg should be possible with file path as sequence

Daniel Dehennin daniel.dehennin at baby-gnu.org
Thu Oct 31 16:00:50 GMT 2024


Package: python3-debian
Version: 0.1.49
Severity: normal

Dear Maintainer,

I'm trying to parse Packages and let apt handle any compression instead
of writing complex code.

It's segfaulting when I open the file before calling the
`deb822.Packages.iter_paragraphs`:

#+begin_src
ipython3 
Python 3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from debian import deb822

In [2]: index_path = "/tmp/bookworm-updates.main.Packages.xz"

In [3]: with open(index_path, "rb") as index:
   ...:     pkgs = deb822.Packages.iter_paragraphs(index, use_apt_pkg=True)
   ...:     for pkg in pkgs:
   ...:         print(pkg["Package"])
   ...:         break
   ...: 
Segmentation fault
#+end_src

As a work around, I remove the `_has_fileno()` in the compute of
`apt_pkg_allowed` to accept passing the file path instead of an opened
file descriptor:


#+begin_src
ipython3 
Python 3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from debian import deb822

In [2]: index_path = "/tmp/bookworm-updates.main.Packages.xz"

In [3]: pkgs = deb822.Packages.iter_paragraphs(index_path, use_apt_pkg=True)

In [4]: for pkg in pkgs:
   ...:     print(pkg["Package"])
   ...:     break
   ...: 
ikiwiki-hosting-common
#+end_src

Regards.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.10.9-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3-debian depends on:
ii  python3          3.12.6-1
ii  python3-chardet  5.2.0+dfsg-1

Versions of packages python3-debian recommends:
ii  python3-apt  2.9.0+b1
ii  zstd         1.5.6+dfsg-1

Versions of packages python3-debian suggests:
ii  gpgv  2.2.43-8+b1

-- no debconf information

-- 
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6  2AAD CC1E 9E5B 7A6F E2DF



More information about the pkg-python-debian-maint mailing list