par2+webdav raises TypeError on Python 3

Bug #1848783 reported by Jacob Middag
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Duplicity
Fix Released
Medium
Unassigned

Bug Description

Duplicity: 0.8.05
Python: 3.7.4
OS: macOS 10.15 (Catalina)

Backtrace of previous error: Traceback (innermost last):
  File "/Users/jacobmiddag/Work/duplicity-0.8.05/duplicity/backend.py", line 371, in inner_retry
    return fn(self, *args)
  File "/Users/jacobmiddag/Work/duplicity-0.8.05/duplicity/backend.py", line 580, in list
    return [tobytes(x) for x in self.backend._list()]
  File "/Users/jacobmiddag/Work/duplicity-0.8.05/duplicity/backends/par2backend.py", line 198, in list
    if c.match(filename):
 TypeError: cannot use a bytes pattern on a string-like object

Attempt 1 failed. TypeError: cannot use a bytes pattern on a string-like object

If I change the code with the following patch it works my case, but I am unsure if `list` should give back strings or bytes.

diff --git a/duplicity/backends/par2backend.py b/duplicity/backends/par2backend.py
index 1b41274..4376195 100644
--- a/duplicity/backends/par2backend.py
+++ b/duplicity/backends/par2backend.py
@@ -131,7 +131,7 @@ class Par2Backend(backend.Backend):

             if returncode:
                 log.Warn(u"File is corrupt. Try to repair %s" % remote_filename)
- par2volumes = list(filter(re.compile(b'%s\\.vol[\\d+]*\\.par2' % remote_filename).match,
+ par2volumes = list(filter(re.compile('%s\\.vol[\\d+]*\\.par2' % remote_filename).match,
                                           self.wrapped_backend._list()))

                 for filename in par2volumes:
@@ -192,7 +192,7 @@ class Par2Backend(backend.Backend):
         """
         remote_list = self.wrapped_backend._list()

- c = re.compile(b'(?!.*\\.par2$)')
+ c = re.compile('(?!.*\\.par2$)')
         filtered_list = []
         for filename in remote_list:
             if c.match(filename):

Jacob Middag (jmiddag)
description: updated
summary: - par2+webdav throws TypeError on Python 3
+ par2+webdav raises TypeError on Python 3
Changed in duplicity:
importance: Undecided → Medium
milestone: none → 0.8.06
status: New → Fix Committed
Changed in duplicity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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