Merge pull request #2692 from mdklab/fix-issue-1802-unicode-error

Fix issue #1802: Handle UnicodeDecodeError in repo file paths
This commit is contained in:
paul-gauthier 2024-12-26 10:12:33 -05:00 committed by GitHub
commit 9befec5cd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 0 deletions

View file

@ -393,6 +393,12 @@ def sanity_check_repo(repo, io):
if not repo.git_repo_error:
return True
error_msg = str(repo.git_repo_error)
except UnicodeDecodeError as exc:
error_msg = (
f"Failed to read the Git repository. This issue is likely caused by a path encoded "
f"in a format different from the expected encoding \"{sys.getfilesystemencoding()}\".\n"
f"Internal error: {str(exc)}"
)
except ANY_GIT_ERROR as exc:
error_msg = str(exc)
bad_ver = "version in (1, 2)" in error_msg