Regression: xenial: Uses apt_pkg.Error, which is only available in later versions

Bug #1830635 reported by Julian Andres Klode
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Xenial
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
The last SRU introduced a regression in error handling, where apt_pkg.Error is being caught - but that class is not available in xenial - it still uses SystemError

[Test case]

Run python3 -c "import apt; apt.Cache().update()" while running apt update.

You should see:

# <command>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 468, in update
    raise LockFailedException("Failed to lock %s" % lockfile)
apt.cache.LockFailedException: Failed to lock /var/lib/apt/lists/lock

Currently you see:
# <command>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 63, in __enter__
    return self._lock.__enter__()
SystemError: E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 481, in update
    with _WrappedLock(apt_pkg.config.find_dir("Dir::State::Lists")):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 64, in __enter__
    except apt_pkg.Error as e:
AttributeError: module 'apt_pkg' has no attribute 'Error'

[Regression potential]
It really can't get worse than this. But FWIW: This only affects code paths where we could not lock the lists/ or archives/ directory - they currently throw the AttributeError, and will then throw LockFailedException again - as they did before the SRU.

description: updated
Changed in python-apt (Ubuntu):
status: New → Invalid
Changed in python-apt (Ubuntu Xenial):
status: New → Triaged
tags: added: regression-update
Changed in python-apt (Ubuntu Xenial):
status: Triaged → In Progress
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello Julian, or anyone else affected,

Accepted python-apt into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-apt/1.1.0~beta1ubuntu0.16.04.5 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in python-apt (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-xenial
Revision history for this message
Julian Andres Klode (juliank) wrote :

Verified 1.1.0~beta1ubuntu0.16.04.5 by running the attached script. It does properly throw LockFailedException now. It does give you the cause of the LockFailedException, which we might want to change eventually, but um, that's just cosmetics, and might even be useful.

# python3 -c "import apt; apt.Cache().update()"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 63, in __enter__
    return self._lock.__enter__()
SystemError: E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 481, in update
    with _WrappedLock(apt_pkg.config.find_dir("Dir::State::Lists")):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 66, in __enter__
    (self._path, e))
apt.cache.LockFailedException: Failed to lock directory /var/lib/apt/lists/: E:Could not get lock /var/lib/apt/lists
/lock - open (11: Resource temporarily unavailable)

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Mathew Hodson (mhodson)
no longer affects: python-apt (Ubuntu)
Revision history for this message
Julian Andres Klode (juliank) wrote :

Looked at the report for xenial SRU

Regression in autopkgtest for ubuntu-make (ppc64el): test log
Regression in autopkgtest for ubuntu-make (s390x): test log
Regression in autopkgtest for ubuntu-make (amd64): test log
Regression in autopkgtest for ubuntu-make (i386): test log
Regression in autopkgtest for snapcraft (arm64): test log

These do not appear to be regressions, they are all happening with other runs as well.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-apt - 1.1.0~beta1ubuntu0.16.04.5

---------------
python-apt (1.1.0~beta1ubuntu0.16.04.5) xenial; urgency=medium

  * Fix erronous use of apt_pkg.Error
    apt_pkg.Error was introduced in later versions, and accidentally
    used when backporting fixes in the previous SRU. (LP: #1830635)
  * Update mirror lists

 -- Julian Andres Klode <email address hidden> Mon, 27 May 2019 18:05:12 +0200

Changed in python-apt (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for python-apt has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.