rev 1515: TypeError: can't concat str to bytes

Bug #1855195 reported by Mark Grandi on 2019-12-04
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Déjà Dup

Bug Description

due to this bug ( i tried to download the latest trunk and run that, but now i am getting "TypeError: can't concat str to bytes"

i am running the latest revision (as of this point), 1515, with the only thing changed being the version number manually changed to and changing the shebang line for the duplicity script that gets put into ~/.local/bin/duplicity to be python3 instead of python (seems to be a bug since you changed it in a recent revision i noticed)

i installed duplicity by doing `bzr branch`, editing the files above, `python3 bdist_wheel` and then `pip3 install <whatever>.whl`

the command line is:

/usr/bin/time duplicity incremental --encrypt-sign-key "<KEY>" --log-file "/mnt/c/Users/auror/Temp/Logs/duplicity/duplicity_log_file_$(date --utc '+%FT%H_%M_%S.%N%z').log" --name "mgrandi_lenovo_x1_carbon_win10_20191120" --exclude-device-files --progress --progress-rate 60 --volsize 1024 --file-prefix "mgrandi_lenovo_x1_carbon_win10_20191120-" --exclude-filelist "/mnt/c/Users/auror/duplicity_exclude_list_linux_filepaths.txt" "/mnt/c/Users/auror/" "dpbx:///Backups/duplicity/mgrandi_lenovo_x1_carbon_win10_20191120/"

see attached log file


Mark Grandi (markgrandi) wrote :
description: updated
description: updated

What OS version? What version of librsync?

$ apt show librsync1


$ apt show librsync2


your distro's equivalent.

Changed in duplicity:
importance: Undecided → High
milestone: none → 0.8.09
status: New → In Progress
assignee: nobody → Kenneth Loafman (kenneth-loafman)
Changed in duplicity:
status: In Progress → Incomplete
Mark Grandi (markgrandi) wrote :

It is ubuntu 18.10 running on windows 10 WSL, the uname string:

Linux <HOSTNAME> 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

this did work in a previous version of duplicity (0.8.06) that i downloaded from the website

python3 version:

~$ python3 -VV Python 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0]

since i compiled it from the source code, i did not install librsync from apt, but it compiled it using the script, the location is:


i am testing a previously installed version (0.8.6) to make sure that works still, and the problem is just 0.8.7+

Mark Grandi (markgrandi) wrote :

and the backup just finished, version 0.8.6 works fine

Changed in duplicity:
status: Incomplete → Opinion
status: Opinion → In Progress

Try this:

$ PYTHONPATH='.' duplicity incremental --encrypt-sign-key "<KEY>"

Looks like the current directory is not in the path. It should be.

BTW, the normal install is '$ sudo install'. I'm wondering if the bdist_wheel setup is causing a problem.

Mark Grandi (markgrandi) wrote :

i use bdist_wheel because whatever the normal install does is not hooking into the normal packaging framework , it shows up in `pip3 list` but then when you try and uninstall it, it doesn't remove the entire installation, which is annoying to manually go through and remove the files one by one, and has the benefit of having the librsync shared library included (for uploading onto pypi for example.)

Compare the removal when using a wheel vs the normal install:

anyway, i did some debugging and it seems that its encountering a locked file, or there is some interaction with a file being locked on windows and a linux process via WSL is trying to access it but can't

the full error message (i printed out the full exception):

Error Invalid argument getting delta for /mnt/c/Users/auror/.android/metrics/spool/3e68d120-cc5a-4d7c-a4b0-131782ec79bd.trk, [Errno 22] Invalid argument

i can see in Process Explorer that android studio indeed has that file open

so maybe duplicity is just expecting 1 type of exception but in this case its a different type, so it falls through and doesn't use the normal "file is locked" code path?

Looked at WSL. Not a virtual machine. Have you tried this under a VM? Docker? VirtualBox works well and provides a real Linux environment, not an emulation.

Mark Grandi (markgrandi) wrote :

WSL is not emulation, and is correctly running ELF binaries just fine, the only problem here is that duplicity is not handling an IOError exception properly

i would love to run this natively under windows but there is so much python code that uses linux specific stdlib stuff that it became too much work to just get a backup solution working

but i will say that if a file is not locked then duplicity works perfectly, i would not consider this a WSL issue at all.

Andrew Smith (andrew-smith) wrote :

At the risk of adding noise I'll observe that I think duplicity contains a number of bugs around string/byte handling when running under Python 3 instead of Python 2, e.g. I raised upstream just now because the WebDAV backend is broken (using Basic auth) since Ubuntu 19.10 when Python default switched to 3.

I run the current Snap version from Snapcraft: on Ubuntu 19.10 and I get this bug. I opted for the Snap version because of this bug ( as well.

Sorry for the double post. There seems no way to edit posts though. So here is the full error message I get:

Traceback (innermost last):
  File "/snap/deja-dup/252/bin/duplicity", line 101, in <module>
  File "/snap/deja-dup/252/bin/duplicity", line 87, in with_tempdir
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 1539, in main
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 1663, in do_backup
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 569, in full_backup
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 426, in write_multivol
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 393, in GPGWriteFile
    data = block_iter.__next__().data
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 541, in __next__
    result = self.process_continued() # pylint: disable=assignment-from-no-return
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 725, in process_continued
    data, last_block = self.get_data_block(self.process_fp)
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 709, in get_data_block
    buf =
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 452, in read
  File "/snap/deja-dup/252/lib/python3.6/site-packages/duplicity/", line 224, in update
    self.buffer += buf
 TypeError: can't concat str to bytes

That contains, I think, the stable version of duplicity, 0.8.08. You want the edge version:

$ sudo snap refresh --classic --edge duplicity

Thanks for your quick reply.

You are correct with your assumption that it deja-dup 40.6 contains duplicity 0.8.08. However I will have to wait for Michael Terry to update the deja-dup snap (at least the edge version of it) with duplicity 0.8.09 so I can fully replicate my issue and see if it is fixed. (Also I have a giant backup that takes almost 7 hours to complete which I want to manage with deja-dup. I'm honestly too scared to touch this with a "naked" duplicity.)

Maybe Mark Grandi can do a quick test of the edge version since he used duplicity without deja-dup before?

Tim Starling (tstarling) wrote :

This looks like a duplicate of #1855636. I came here because I'm seeing an identical backtrace to the one reported here, but on closer investigation it appears to be the same issue which was fixed by

Vej (vej) on 2019-12-26
Changed in deja-dup:
status: New → Triaged
importance: Undecided → High
Changed in duplicity:
status: In Progress → Fix Committed
assignee: Kenneth Loafman (kenneth-loafman) → nobody
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

Remote bug watches

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