Unicode traceback saving empty SourcesList regression

Bug #1294531 reported by Adam Collard on 2014-03-19
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python-apt (Debian)
Fix Released
Unknown
python-apt (Ubuntu)
Undecided
Unassigned

Bug Description

Following the recent update to fix LP: #1069019 a regression was introduced when trying to save an empty SourcesList.

>>> from aptsources.sourceslist import SourcesList
>>> s = SourcesList(withMatcher=False)
>>> s.save()

/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyc in save(self)
    409
    410 with io.open(path, "w", encoding="utf-8") as f:
--> 411 f.write(header)
    412 return
    413

TypeError: must be unicode, not str

This is because the header that's added when there are no APT entries is a regular Python 2 string object, and not a unicode object.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: python-apt 0.9.3.3 [modified: usr/lib/python2.7/dist-packages/aptsources/sourceslist.py]
ProcVersionSignature: Ubuntu 3.13.0-18.38-generic 3.13.6
Uname: Linux 3.13.0-18-generic x86_64
ApportVersion: 2.13.3-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Wed Mar 19 10:11:04 2014
InstallationDate: Installed on 2012-08-17 (578 days ago)
InstallationMedia: Ubuntu 12.04.1 LTS "Precise Pangolin" - Release amd64 (20120817.1)
SourcePackage: python-apt
UpgradeStatus: Upgraded to trusty on 2014-02-08 (38 days ago)

Adam Collard (adam-collard) wrote :
tags: added: landscape
Julian Andres Klode (juliank) wrote :

Not only that, I also have a branch that fixes the issue:
   https://github.com/julian-klode/python-apt/tree/bugfix/unicode

But I do not know yet whether merging this force-utf-8 thing again is a sensible thing to do. It turns out that if you run your applications in a normal environment, you do not need to specify the encoding at all, Python will use the encoding of the locale. I did not notice that when I first merged the fix.

This basically only makes situations work where people use the "C" locale when running their python-apt-using tools, and another locale in normal use. And I do not think that should be supported. There is C.UTF-8 for language agnostic environments, and every system has a default locale that system-wide dbus services should use.

Julian Andres Klode (juliank) wrote :

(Note: I keep wip stuff on github before merging them to git.d.o, because my github repository is connected to travis-ci.org and runs continous integration tests).

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Julian Andres Klode (juliank) wrote :

Upstream release 0.9.3.4 reverted the commit.

Adam Collard (adam-collard) wrote :

python-apt (0.9.3.4) fixed this in Trusty.

Confirmed that it's no longer reproducible.

Changed in python-apt (Ubuntu):
status: Confirmed → Fix Released
Changed in python-apt (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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