Skip to content

Commit 323c9ea

Browse files
authored
Merge pull request #1904 from wkentaro/fix/natsort-os-sorted-macos-unicode
fix: handle natsort.os_sorted OSError on macOS with Unicode paths
2 parents 89a615e + cf0b371 commit 323c9ea

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

labelme/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,4 +2562,11 @@ def _scan_image_files(root_dir: str) -> list[str]:
25622562
images.append(relativePath)
25632563

25642564
logger.debug("found {:d} images in {!r}", len(images), root_dir)
2565-
return natsort.os_sorted(images)
2565+
try:
2566+
return natsort.os_sorted(images)
2567+
except OSError:
2568+
logger.warning(
2569+
"natsort.os_sorted failed (known macOS strxfrm bug), "
2570+
"falling back to locale-unaware natural sort"
2571+
)
2572+
return natsort.natsorted(images)

0 commit comments

Comments
 (0)