Switch to python3 is causing mediafire backend to fail

Bug #1863018 reported by Jose Riha on 2020-02-12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Duplicity
Medium
Unassigned

Bug Description

Since switch to `python3` (`duplicity 0.8.10`) there's an issue with mediafire backend.

```
duplicity full -v9 --no-encryption /etc/resolv.conf mf://use.rlo@g.in:<email address hidden>/
..
..
Backtrace of previous error: Traceback (innermost last):
  File "/usr/lib/python3.8/site-packages/duplicity/backend.py", line 376, in inner_retry
    return fn(self, *args)
  File "/usr/lib/python3.8/site-packages/duplicity/backend.py", line 547, in put
    self.__do_put(source_path, remote_filename)
  File "/usr/lib/python3.8/site-packages/duplicity/backend.py", line 533, in __do_put
    self.backend._put(source_path, remote_filename)
  File "/usr/lib/python3.8/site-packages/duplicity/backends/mediafirebackend.py", line 85, in _put
    uri = self._build_uri(remote_filename)
  File "/usr/lib/python3.8/site-packages/duplicity/backends/mediafirebackend.py", line 137, in _build_uri
    (u'/' + filename if filename else u'')
 TypeError: can only concatenate str (not "bytes") to str

Attempt 1 failed. TypeError: can only concatenate str (not "bytes") to str

```

the issue is that `filename` is bytes object and while python2 happily accepts it, python3 throws an exception:

```
python2 -c "b'' + ''" # all good
python3 -c "b'' + ''" # can't concat str to bytes!!
```

duplicity 0.8.10fin
Python 3.8.1 (default, Jan 22 2020, 06:38:00)
Arch Linux, current

Jose Riha (jose1711) wrote :

a quick (and untested) way to fix the problem is modification of _build_uri function in mediafirebackend.py:

    def _build_uri(self, filename=None):
        u"""Build relative URI"""
        filename = filename.decode() if filename else None
        return (
            u'mf:' + self.folder[u"folderkey"] +
            (u'/' + filename if filename else u'')
        )

As a workaround you can override python3 by executing duplicity with python2 like so:

$ python2 duplicity [opts] src dst

Changed in duplicity:
importance: Undecided → Medium
milestone: none → 0.8.11
status: New → In Progress
Jose Riha (jose1711) wrote :

This workaround is not possible on Arch Linux as duplicity does not support python2 there.

Changed in duplicity:
status: In Progress → Fix Committed
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.

Other bug subscribers