Fix regression in apt.py

This fixes a regression introduced in a43a2af a few days ago.

Fixes #6090.