# Buggy code
def wrapper(self, *args, **kwargs):
    try:
        res = func(self, *args, **kwargs)
        if res is None:
            res = True
    except SyncError as exc:
        file_name = os.path.basename(exc.dbx_path)
        logger.warning("Could not sync %s", file_name, exc_info=True)
        if exc.dbx_path is not None:
            if exc.local_path is None:
                exc.local_path = self.to_local_path(exc.dbx_path)
            self.sync_errors.put(exc)
            if any(isinstance(a, Metadata) for a in args):
                self.download_errors.add(exc.dbx_path)

        res = False

    return res


# Traceback (maestral.errors.PathError)
Traceback (most recent call last):
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 343, in wrapper
res = func(self, *args, **kwargs)
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 1524, in create_remote_entry
self._on_created(event)
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 1621, in _on_created
if self._handle_selective_sync_conflict(event):
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 1435, in _handle_selective_sync_conflict
raise os_to_maestral_error(exc, local_path=local_path_cc)
maestral.errors.PathError: Could not create local file. The file name (including path) is too long.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 2679, in startup_worker
sync.upload_local_changes_while_inactive()
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 1053, in upload_local_changes_while_inactive
self.apply_local_changes(events, local_cursor)
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 1495, in apply_local_changes
success.append(f.result())
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/charles/tf/lib/python3.7/site-packages/maestral/sync.py", line 347, in wrapper
file_name = os.path.basename(exc.dbx_path)
File "/home/charles/tf/lib/python3.7/posixpath.py", line 146, in basename
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

# Fixed code
def wrapper(self, *args, **kwargs):
    try:
        res = func(self, *args, **kwargs)
        if res is None:
            res = True
    except SyncError as exc:
        # fill out missing dbx_path or local_path
        if exc.dbx_path or exc.local_path:
            if not exc.local_path:
                exc.local_path = self.to_local_path(exc.dbx_path)
            if not exc.dbx_path:
                exc.dbx_path = self.to_dbx_path(exc.local_path)

        if exc.dbx_path_dst or exc.local_path_dst:
            if not exc.local_path_dst:
                exc.local_path_dst = self.to_local_path(exc.dbx_path_dst)
            if not exc.dbx_path:
                exc.dbx_path_dst = self.to_dbx_path(exc.local_path_dst)

        if exc.dbx_path:
            # we have a file / folder associated with the sync error
            file_name = osp.basename(exc.dbx_path)
            logger.warning("Could not sync %s", file_name, exc_info=True)
            self.sync_errors.put(exc)

            # save download errors to retry later
            if download:
                self.download_errors.add(exc.dbx_path)

        res = False

    return res