Skip to content

Normalize absolute Windows paths with forward slashes - #124

Open
M-Colley wants to merge 1 commit into
arsenetar:masterfrom
M-Colley:fix/issue-84-win-path-slashes
Open

M-Colley wants to merge 1 commit into
arsenetar:masterfrom
M-Colley:fix/issue-84-win-path-slashes

Conversation

@M-Colley

Copy link
Copy Markdown

Calling send2trash on Windows failed for absolute paths containing forward or mixed slashes. Specifically, os.path.isabs returns True for forward-slash drive paths, so both Windows backends skipped os.path.abspath and left forward slashes unnormalized. Consequently, get_short_path_name in the legacy backend prepended the \\?\ prefix to a forward-slash path and caused GetShortPathNameW to raise FileNotFoundError, while the modern backend passed unnormalized paths to SHCreateItemFromParsingName. Fixes #84.

This change passes every input path through os.path.abspath unconditionally in send2trash/win/legacy.py and send2trash/win/modern.py. As a result, both backends normalize forward and mixed slashes to backslashes while preserving original_paths for error reporting. In addition, regression tests in tests/test_win_path_normalization.py cover forward-slash, mixed-slash, and \\?\-prefixed paths across both backends.

Signed-off-by: Mark Colley <39366189+M-Colley@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileNotFound error

1 participant