# Buggy code
def _handle_case_conflict(self, event):
    """
    Checks for other items in the same directory with same name but a different
    case. Renames items if necessary.Only needed for case sensitive file systems.

    :param FileSystemEvent event: Created or moved event.
    :returns: ``True`` or ``False``.
    :rtype: bool
    """

    if not IS_FS_CASE_SENSITIVE:
        return False

    if event.event_type not in (EVENT_TYPE_CREATED, EVENT_TYPE_MOVED):
        return False

    # get the created path (src_path or dest_path)
    dest_path = get_dest_path(event)
    dirname, basename = osp.split(dest_path)

    # check number of paths with the same case
    if len(path_exists_case_insensitive(basename, root=dirname)) > 1:
        dest_path_cc = generate_cc_name(dest_path, suffix="case conflict")
        with self.fs_events.ignore(
            dest_path,
            recursive=osp.isdir(dest_path),
            event_types=(EVENT_TYPE_DELETED, EVENT_TYPE_MOVED),
        ):
            exc = move(dest_path, dest_path_cc)
            if exc:
                raise os_to_maestral_error(exc, local_path=dest_path_cc)

        logger.info('Case conflict: renamed "%s" to "%s"', dest_path, dest_path_cc)

        return True
    else:
        return False


# 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 _handle_case_conflict(self, event):
    """
    Checks for other items in the same directory with same name but a different
    case. Renames items if necessary.Only needed for case sensitive file systems.

    :param FileSystemEvent event: Created or moved event.
    :returns: ``True`` or ``False``.
    :rtype: bool
    """

    if not IS_FS_CASE_SENSITIVE:
        return False

    if event.event_type not in (EVENT_TYPE_CREATED, EVENT_TYPE_MOVED):
        return False

    # get the created path (src_path or dest_path)
    local_path = get_dest_path(event)
    dirname, basename = osp.split(local_path)

    # check number of paths with the same case
    if len(path_exists_case_insensitive(basename, root=dirname)) > 1:
        local_path_cc = generate_cc_name(local_path, suffix="case conflict")
        with self.fs_events.ignore(
            local_path,
            recursive=osp.isdir(local_path),
            event_types=(EVENT_TYPE_DELETED, EVENT_TYPE_MOVED),
        ):
            exc = move(local_path, local_path_cc)
            if exc:
                raise os_to_maestral_error(exc, local_path=local_path_cc)

        logger.info('Case conflict: renamed "%s" to "%s"', local_path, local_path_cc)

        return True
    else:
        return False