Package: python3-apt
Severity: important
--- Please enter the report below this line. ---
When using `apt.cache.Cache.update()` with specifying a sourcelist file,
two errors happen:
- On one hand, because of a return inside the `try` block, `finally`
is not executed sometimes.
- When executing finally, apt_pkg settings are rolled back, so `open`
function reverts the new sources when the new `Cache` instance is
created, updating again without the parameters set.
It's important to say that I found the same bug on python3-apt 1.4~beta4 (sid) and 0.9.3.12 (stable)
Patch:
@@ -454,6 +454,8 @@
else:
slist = self._list
+ res = None
+
try:
if fetch_progress is None:
fetch_progress = apt.progress.base.AcquireProgress()
@@ -462,17 +464,19 @@
pulse_interval)
except SystemError as e:
raise FetchFailedException(e)
- if not res and raise_on_error:
- raise FetchFailedException()
- else:
- return res
finally:
+ self.open()
os.close(lock)
if sources_list:
apt_pkg.config.set("Dir::Etc::sourcelist", old_sources_list)
apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d)
apt_pkg.config.set("APT::List-Cleanup", old_cleanup)
+ if not res and raise_on_error:
+ raise FetchFailedException()
+ else:
+ return res
+
--- System information. ---
Architecture:
Kernel: Linux 4.8.0-0.bpo.2-amd64
Debian Release: 9.0
--- Package information. ---
Depends (Version) | Installed
====================================-+-===============
python3 (<< 3.6) | 3.5.1-4
python3 (>= 3.5~) | 3.5.1-4
python3:any (>= 3.3.2-2~) |
libapt-inst2.0 (>= 1.4~beta3) | 1.4~beta4
libapt-pkg5.0 (>= 1.4~beta3) | 1.4~beta4
libc6 (>= 2.14) |
libgcc1 (>= 1:3.0) |
libstdc++6 (>= 5.2) |
python-apt-common |
Recommends (Version) | Installed
==========================-+-===========
lsb-release | 4.1+Debian13+nmu1
iso-codes | 3.74-1
Suggests (Version) | Installed
==============================-+-===========
python3-apt-dbg |
python-apt-doc |
apt | 1.4~beta4