We do not print warnings on stderr in apt; the library logs them to the error handler, the python-apt code then translates them into Python warnings used in the warnings module using apt_pkg.Warning instances. Unless there is an error, in which case warnings are merged into the exception as context.
Consumers of apt_pkg can filter out apt_pkg.Warning warnings the usual way using the warnings module, including but not limited to: with warnings.catch_warnings(category=apt_pkg.Warning): do something The warnings addition is a new feature to ensure warnings don't get lost, previously warnings were only part of exceptions. A future version of APT may add error ids to the error logging framework, which then could be translated into apt_pkg.Error and apt_pkg.Warning subclasses. ** Changed in: apt (Ubuntu) Status: New => Invalid -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to apt in Ubuntu. https://bugs.launchpad.net/bugs/2064624 Title: Warning: W:Unable to read /var/lib/ubuntu-advantage/apt- esm/etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory) Status in apt package in Ubuntu: Invalid Status in ubuntu-advantage-tools package in Ubuntu: Fix Committed Status in update-notifier package in Ubuntu: Fix Released Status in apt source package in Oracular: New Status in ubuntu-advantage-tools source package in Oracular: New Status in update-notifier source package in Oracular: New Bug description: The following warnings are visible out of the box. /usr/lib/python3/dist-packages/uaclient/apt.py:288: Warning: W:Unable to read /var/lib/ubuntu-advantage/apt-esm/etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory) apt_pkg.init() /usr/lib/python3/dist-packages/uaclient/apt.py:270: Warning: W:Unable to read /var/lib/ubuntu-advantage/apt-esm/etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory) apt_pkg.init_system() $ apt policy ubuntu-pro-client ubuntu-pro-client: Installed: 31.2.3 Candidate: 31.2.3 Version table: *** 31.2.3 500 500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages 100 /var/lib/dpkg/status $ pro security-status /usr/lib/python3/dist-packages/uaclient/apt.py:288: Warning: W:Unable to read /var/lib/ubuntu-advantage/apt-esm/etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory) apt_pkg.init() /usr/lib/python3/dist-packages/uaclient/apt.py:270: Warning: W:Unable to read /var/lib/ubuntu-advantage/apt-esm/etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory) apt_pkg.init_system() 598 packages installed: 597 packages from Ubuntu Main/Restricted repository 1 package from Ubuntu Universe/Multiverse repository To get more information about the packages, run pro security-status --help for a list of available options. This machine is receiving security patching for Ubuntu Main/Restricted repository until 2029. This machine is NOT attached to an Ubuntu Pro subscription. Ubuntu Pro with 'esm-infra' enabled provides security updates for Main/Restricted packages until 2034. Ubuntu Pro with 'esm-apps' enabled provides security updates for Universe/Multiverse packages until 2034. Try Ubuntu Pro with a free personal subscription on up to 5 machines. Learn more at https://ubuntu.com/pro $ tree /var/lib/ubuntu-advantage/apt-esm/etc/ /var/lib/ubuntu-advantage/apt-esm/etc/ └── apt ├── sources.list └── sources.list.d └── ubuntu-esm-apps.sources 3 directories, 2 files ProblemType: Bug DistroRelease: Ubuntu 24.04 Package: ubuntu-pro-client 31.2.3 ProcVersionSignature: User Name 6.8.0-31.31-generic 6.8.1 Uname: Linux 6.8.0-31-generic x86_64 ApportVersion: 2.28.1-0ubuntu2 Architecture: amd64 CasperMD5CheckResult: unknown CloudArchitecture: x86_64 CloudBuildName: server CloudID: lxd CloudName: lxd CloudPlatform: lxd CloudSerial: 20240423 CloudSubPlatform: LXD socket API v. 1.0 (/dev/lxd/sock) Date: Thu May 2 13:28:48 2024 ProcEnviron: LANG=C.UTF-8 PATH=(custom, no user) SHELL=/bin/bash TERM=xterm-256color XDG_RUNTIME_DIR=<set> SourcePackage: ubuntu-advantage-tools UpgradeStatus: No upgrade log present (probably fresh install) apparmor_logs.txt: cloud-id.txt: lxd livepatch-status.txt-error: Invalid command specified '/snap/bin/canonical-livepatch status'. uaclient.conf: contract_url: https://contracts.canonical.com log_level: debug To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/2064624/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp