#1108035 python3-apt: Accept os.PathLike

Package:
python3-apt
Source:
python3-apt
Description:
Python 3 interface to libapt-pkg
Submitter:
Colin Watson
Date:
2025-06-19 13:11:02 UTC
Severity:
normal
#1108035#5
Date:
2025-06-19 13:08:44 UTC
From:
To:
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,