UnicodeDecodeError when reporting exceptions

Bug #1797928 reported by Pete Zaitcev on 2018-10-15
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Duplicity
Undecided
Unassigned

Bug Description

This place was a problem before, see bug 1386373. We used to have the plain old str(e), but that obviously threw the "UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)". Ken L. replaced it with unicode(e), as suggested by Eugene Morozov.

Unfortunately, unicode(e) does not work either for some exceptions. The symptom is the same:

Traceback (innermost last):
  File "/usr/bin/duplicity", line 1560, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1546, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1398, in main
    do_backup(action)
  File "/usr/bin/duplicity", line 1419, in do_backup
    sync_archive()
  File "/usr/bin/duplicity", line 1209, in sync_archive
    copy_to_local(fn)
  File "/usr/bin/duplicity", line 1151, in copy_to_local
    fileobj = globals.backend.get_fileobj_read(fn)
  File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 676, in get_fileobj_read
    self.get(filename, tdp)
  File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 395, in inner_retry
    % (n, e.__class__.__name__, util.uexc(e)))
  File "/usr/lib64/python2.7/site-packages/duplicity/util.py", line 79, in uexc
    return ufn(unicode(e).encode('utf-8'))
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 21: ordinal not in range(128)

I'm going to attach a patch that fell out of my py3 work and unicode struggles - but without an actual port to py3.

Pete Zaitcev (zaitcev) wrote :
ausboffin (sdanaesthesia) wrote :

I have a similar error output:
Traceback (innermost last):
  File "/usr/bin/duplicity", line 1560, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1546, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1398, in main
    do_backup(action)
  File "/usr/bin/duplicity", line 1516, in do_backup
    full_backup(col_stats)
  File "/usr/bin/duplicity", line 577, in full_backup
    globals.backend)
  File "/usr/bin/duplicity", line 459, in write_multivol
    (tdp, dest_filename, vol_num)))
  File "/usr/lib/python2.7/dist-packages/duplicity/asyncscheduler.py", line 146, in schedule_task
    return self.__run_synchronously(fn, params)
  File "/usr/lib/python2.7/dist-packages/duplicity/asyncscheduler.py", line 172, in __run_synchronously
    ret = fn(*params)
  File "/usr/bin/duplicity", line 458, in <lambda>
    vol_num: put(tdp, dest_filename, vol_num),
  File "/usr/bin/duplicity", line 347, in put
    backend.put(tdp, dest_filename)
  File "/usr/lib/python2.7/dist-packages/duplicity/backend.py", line 395, in inner_retry
    % (n, e.__class__.__name__, util.uexc(e)))
  File "/usr/lib/python2.7/dist-packages/duplicity/util.py", line 79, in uexc
    return ufn(unicode(e).encode('utf-8'))

Any suggestions would be appreciated.

Sorry that I missed this, Pete. I lost it because this one was duped against others, but you have given a lot of helpful detail.

Many thanks for the proposed patch. I will take a look.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers