Bug#1108035: python3-apt: Accept os.PathLike

Colin Watson <[email protected]>
Newsgroups gmane.linux.debian.apt.devel
Message-ID <aFQL3PZz_PWAca0m__49542.4552400195$1750338686$gmane$org@camorr.rosewood.vpn.ucam.org>
Package: python3-apt
Version: 3.0.0
Severity: wishlist

Nowadays most Python libraries tend to accept objects implementing the 
os.PathLike abstract base class where they accept file names.  The 
apt_pkg functions that go through PyApt_Filename don't seem to.  Here's 
a contrived example:

  >>> from pathlib import Path
  >>> import apt_pkg
  >>> release_path = Path("/var/lib/apt/lists/deb.debian.org_debian_dists_trixie_InRelease")
  >>> apt_pkg.open_maybe_clear_signed_file(release_path)
  Traceback (most recent call last):
    File "<python-input-4>", line 1, in <module>
      apt_pkg.open_maybe_clear_signed_file(release_path)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  SystemError: argument 1 (unspecified)
  >>> apt_pkg.open_maybe_clear_signed_file(release_path.as_posix())
  6

It would be nice if this worked.

Thanks,

-- 
Colin Watson (he/him)                              [[email protected]]

-- System Information:
Debian Release: 13.0
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.27-amd64 (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-apt depends on:
ii  distro-info-data   0.64
ii  libapt-pkg7.0      3.0.2
ii  libc6              2.41-8
ii  libgcc-s1          14.2.0-19
ii  libstdc++6         14.2.0-19
ii  python-apt-common  3.0.0
ii  python3            3.13.3-1

Versions of packages python3-apt recommends:
ii  iso-codes    4.18.0-1
ii  lsb-release  12.1-1

Versions of packages python3-apt suggests:
ii  apt             3.0.2
pn  python-apt-doc  <none>

-- no debconf information
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.