~ubuntu-branches/ubuntu/natty/aptdaemon/natty-security

« back to all changes in this revision

Viewing changes to aptdaemon/errors.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-04-12 13:25:49 UTC
  • mfrom: (1.1.47 upstream)
  • Revision ID: james.westby@ubuntu.com-20110412132549-8rc74dfr01jil7vm
Tags: 0.41+bzr629-0ubuntu1
* New bzr bugfix snapshot:
  - improve utf8 encoding handling tests
  - lp:~mvo/aptdaemon/relax-lintian-checks merged
  - improve terminal handling, LP: #741260, #693290, #741260,  
    #738056,  #742780, #743818, #744444, #746727, #747539, #753700,
    #753762, #753927, #754134, #754174, #754205, #754206, #754220
  - fix refactoring lefovers (LP: #752220)
  - don't segfault if we cannot read the status of the process holding 
    a lock (LP: #745517)
* debian/patches/01_relax_lintian_checks.patch:
  - removed, taken upstream
* debian/patches/02_fix_unicode_in_convert_struct.patch:
  - removed, taken usptream
* debian/patches/04_import_logging.patch:
  - removed, fixed usptream

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        if not args:
72
72
            # Avoid string replacements if not used
73
73
            details = details.replace("%", "%%")
 
74
        args = [_convert_unicode(arg) for arg in args]
 
75
        details = _convert_unicode(details)
74
76
        AptDaemonError.__init__(self, "%s: %s" % (code, details % args))
75
77
        self.code = code
76
78
        self.details = details
184
186
            return error_cls(dbus_msg)
185
187
    return error
186
188
 
 
189
def _convert_unicode(text, encoding="UTF-8"):
 
190
    """Always return an unicode."""
 
191
    if not isinstance(text, unicode):
 
192
        text = unicode(text, encoding, errors="ignore")
 
193
    return text
 
194
 
187
195
# vim:ts=4:sw=4:et