# Buggy code
def open(cls, time_string, compress=1):
    """Open the error log, prepare for writing"""
    if not Globals.isbackup_writer:
        return Globals.backup_writer.log.ErrorLog.open(time_string, compress)
    assert not cls._log_fileobj, "log already open"
    assert Globals.isbackup_writer

    base_rp = Globals.rbdir.append("error_log.%s.data" % (time_string,))
    if compress:
        cls._log_fileobj = rpath.MaybeGzip(base_rp)
    else:
        cls._log_fileobj = base_rp.open("wb", compress=0)


# Traceback (TypeError)
UpdateError: 'data/some/sub/dir/changed-file/rdiff-backup.tmp.266' does not match source
Exception 'a bytes-like object is required, not 'str'' raised of class '<class 'TypeError'>':
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 390, in error_check_Main
Main(arglist)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 412, in Main
take_action(rps)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 348, in take_action
Backup(rps[0], rps[1])
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 434, in Backup
backup.Mirror_and_increment(rpin, rpout, incdir)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 55, in Mirror_and_increment
DestS.patch_and_increment(dest_rpath, source_diffiter, inc_rpath)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 281, in patch_and_increment
ITR(diff.index, diff)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/rorpiter.py", line 313, in __call__
last_branch.fast_process(*args)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 781, in fast_process
if self.patch_to_temp(mirror_rp, diff_rorp, tf):
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 637, in patch_to_temp
return self.matches_cached_rorp(diff_rorp, new)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 691, in matches_cached_rorp
"temp file '%s' does not match source" % new_rp.get_safepath())
File "/usr/lib64/python3.6/site-packages/rdiff_backup/log.py", line 313, in write_if_open
cls.write(error_type, rp, exc)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/log.py", line 293, in write
cls._log_fileobj.write(logstr)

Traceback (most recent call last):
File "/usr/bin/rdiff-backup", line 32, in <module>
rdiff_backup.Main.error_check_Main(sys.argv[1:])
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 390, in error_check_Main
Main(arglist)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 412, in Main
take_action(rps)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 348, in take_action
Backup(rps[0], rps[1])
File "/usr/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 434, in Backup
backup.Mirror_and_increment(rpin, rpout, incdir)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 55, in Mirror_and_increment
DestS.patch_and_increment(dest_rpath, source_diffiter, inc_rpath)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 281, in patch_and_increment
ITR(diff.index, diff)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/rorpiter.py", line 313, in __call__
last_branch.fast_process(*args)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 781, in fast_process
if self.patch_to_temp(mirror_rp, diff_rorp, tf):
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 637, in patch_to_temp
return self.matches_cached_rorp(diff_rorp, new)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/backup.py", line 691, in matches_cached_rorp
"temp file '%s' does not match source" % new_rp.get_safepath())
File "/usr/lib64/python3.6/site-packages/rdiff_backup/log.py", line 313, in write_if_open
cls.write(error_type, rp, exc)
File "/usr/lib64/python3.6/site-packages/rdiff_backup/log.py", line 293, in write
cls._log_fileobj.write(logstr)
TypeError: a bytes-like object is required, not 'str'

# Fixed code
def open(cls, time_string, compress=1):
    """Open the error log, prepare for writing"""
    if not Globals.isbackup_writer:
        return Globals.backup_writer.log.ErrorLog.open(time_string, compress)
    assert not cls._log_fileobj, "log already open"
    assert Globals.isbackup_writer

    base_rp = Globals.rbdir.append("error_log.%s.data" % time_string)
    if compress:
        cls._log_fileobj = rpath.MaybeGzip(base_rp)
    else:
        cls._log_fileobj = base_rp.open("wb", compress=0)