diff --git a/b2sdk/_internal/scan/folder.py b/b2sdk/_internal/scan/folder.py index 38dda43f..54b3ca2f 100644 --- a/b2sdk/_internal/scan/folder.py +++ b/b2sdk/_internal/scan/folder.py @@ -13,6 +13,7 @@ import os import platform import re +import stat import sys from abc import ABCMeta, abstractmethod from pathlib import Path @@ -274,14 +275,19 @@ def _walk_relative_paths( reporter.invalid_name(str(local_path), str(e)) continue + # Deliberately don't use Path.is_dir here: for directories + # without search permission, Python 3.13 raises PermissionError + # while Python 3.14 returns False. try: - is_dir = local_path.is_dir() + is_dir = stat.S_ISDIR(local_path.stat().st_mode) except PermissionError: # `chmod -x dir` can trigger this if reporter is not None and not policies_manager.should_exclude_local_directory( str(relative_file_path) ): reporter.local_permission_error(str(local_path)) continue + except (OSError, ValueError): + is_dir = False if is_dir: if policies_manager.should_exclude_local_directory(str(relative_file_path)): diff --git a/changelog.d/+py314-test.fixed.md b/changelog.d/+py314-test.fixed.md new file mode 100644 index 00000000..ab9421bd --- /dev/null +++ b/changelog.d/+py314-test.fixed.md @@ -0,0 +1 @@ +Fix `TestFolderTraversal.test_dir_without_exec_permission` on Python 3.14.