Skip to content

Normalize bare drive letters in portable copy directory (#20159)#20446

Open
Mubashir78 wants to merge 1 commit into
nvaccess:masterfrom
Mubashir78:fix/20159-drive-path-normalization
Open

Normalize bare drive letters in portable copy directory (#20159)#20446
Mubashir78 wants to merge 1 commit into
nvaccess:masterfrom
Mubashir78:fix/20159-drive-path-normalization

Conversation

@Mubashir78

Copy link
Copy Markdown

Fixes #20159

Description of the change

When entering a bare drive letter (e.g. c:) as the destination directory in the Create Portable NVDA dialog, os.path.isabs returns False because a drive letter without a trailing separator is not considered an absolute path on Windows.

This change normalizes bare drive letters by appending os.sep before the os.path.isabs check, so that entering c: behaves the same as c:\.

Testing

Added 4 unit tests in Test_CreatePortableDirectoryNormalization:

  • test_bareDriveLetter_isAcceptedc: is now accepted
  • test_relativePath_showsErrorfoo still shows the error
  • test_driveLetterWithBackslash_isAcceptedc:\ still accepted (regression)
  • test_driveLetterWithPath_isAcceptedd:\\NVDA still accepted (regression)

When entering a bare drive letter (e.g. 'c:') as the destination
directory in the Create Portable NVDA dialog, os.path.isabs returns
False because 'c:' lacks a trailing separator. Normalize by appending
os.sep so the path is recognised as absolute and the portable copy
proceeds without error.

Adds unit tests for the normalization logic, mocking drive-letter
semantics to remain platform-independent.
@Mubashir78 Mubashir78 requested a review from a team as a code owner July 5, 2026 10:32
@Mubashir78 Mubashir78 requested a review from SaschaCowley July 5, 2026 10:32
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.

Failure to create portable copy when path is a top-level drive with no backslash

1 participant