unicode problem in tempdir.py

Bug #1851668 reported by Wolfgang Rohdewald on 2019-11-07
This bug affects 3 people
Affects Status Importance Assigned to Milestone

Bug Description

Version Before I had 0.7* which worked.
Running with Python2.7

  File "/usr/local/lib/python2.7/dist-packages/duplicity/tempdir.py", line 164, in __init__
    log.Info(_(u"Using temporary directory %s") % self.__dir)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)

Problem seems to be that _() returns str while self.__dir is unicode.
_() in my case returns:

Temporäres Verzeichnis %s wird benutzt

I am assuming of course that duplicity still supports Python2

After commenting that out, the same problem appears in commandline.py:

  File "/usr/local/lib/python2.7/dist-packages/duplicity/commandline.py", line 1003, in usage
    """ % dict
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)

So I tried

python3 setup.py install

but the shebang in /usr/local/bin/duplicity still wants python, not python3. My python defaults to Python2. So the error stays.

Next I changed the shebang to /usr/bin/env python3, now it works.

The same here on 0.8.07.
_() function (alias of gettext module) is returning translation as strings not unicode, so when env LANGUAGE=en there is no error but if you set it to language that has accented words you have the error (e.g. 'de' or 'pl').
I fix it for me on Ubuntu 16.04 by changing duplicity/__init__.py:27 to:

    gettext.install(u'duplicity', names=[u'ngettext'], unicode=1)

and disabling OPHelpFix by changing duplicity/commandline.py:284 to:

    parser = OptionParser(option_class=DupOption, usage=usage())

Now it works for me on Python 2 and 3.

now it should be:

    parser = optparse.OptionParser(option_class=DupOption, usage=usage())

Changed in duplicity:
assignee: nobody → Kenneth Loafman (kenneth-loafman)
importance: Undecided → Medium
milestone: none → 0.8.08
status: New → In Progress
Changed in duplicity:
assignee: Kenneth Loafman (kenneth-loafman) → nobody
status: In Progress → Fix Committed

I've seen you committed my fix, I'm glad I could help.

I appreciate any help! Thanks!

Changed in duplicity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers