diff --git a/src/reuse/_util.py b/src/reuse/_util.py index 4b29ff0ae..3d4d83b16 100644 --- a/src/reuse/_util.py +++ b/src/reuse/_util.py @@ -7,6 +7,7 @@ # SPDX-FileCopyrightText: 2022 Pietro Albini # SPDX-FileCopyrightText: 2023 DB Systel GmbH # SPDX-FileCopyrightText: 2023 Johannes Zarl-Zierl +# SPDX-FileCopyrightText: 2023 Matthias Riße # # SPDX-License-Identifier: GPL-3.0-or-later @@ -476,6 +477,10 @@ def _check_read(self, path: Path) -> None: _("'{}' is not a directory").format(path) ) return + if not path.exists() and path.is_symlink(): + # If the path is a broken symlink we can continue, allowing usage of + # --force-dot-license even if the link target is not readable. + return raise ArgumentTypeError(_("can't open '{}'").format(path)) def _check_write(self, path: Path) -> None: diff --git a/src/reuse/header.py b/src/reuse/header.py index 8725c94f6..07382c802 100644 --- a/src/reuse/header.py +++ b/src/reuse/header.py @@ -9,6 +9,7 @@ # SPDX-FileCopyrightText: 2022 Florian Snow # SPDX-FileCopyrightText: 2022 Yaman Qalieh # SPDX-FileCopyrightText: 2022 Carmen Bianca Bakker +# SPDX-FileCopyrightText: 2023 Matthias Riße # # SPDX-License-Identifier: GPL-3.0-or-later @@ -392,7 +393,7 @@ def _is_uncommentable(path: Path) -> bool: registered as an UncommentableCommentStyle. """ is_uncommentable = _get_comment_style(path) == UncommentableCommentStyle - return is_uncommentable or is_binary(str(path)) + return is_uncommentable or path.is_symlink() or is_binary(str(path)) def _verify_paths_line_handling(