Repository navigation
Fixed BucketPath using backslash separators on Windows - #325
Open
Ramnath0521 wants to merge 1 commit into
Open
Ramnath0521 wants to merge 1 commit into
Ramnath0521 wants to merge 1 commit into
Conversation
BucketPath stored its path as PurePath, which is a PureWindowsPath on Windows, so read(), write(), rm(), iterdir() and as_udf_path() sent backslash paths to BucketFS. Store a PurePosixPath instead, converting PurePath arguments with as_posix(). Closes exasol#322 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #322
Cause
BucketPathstored its path asPurePath(path), which is aPureWindowsPathon Windows. Only_get_relative_posix()converted it back to forward slashes.read(),write(),rm(),__str__,iterdir()andas_udf_path()usedstr(self._path)directly and so sent backslash paths to BucketFS, as described in the issue.Change
Following the suggestion in the issue,
BucketPathnow stores aPurePosixPath:__init__builds aPurePosixPath. APurePathargument (for example aPureWindowsPathorWindowsPath) is converted withas_posix()first, sojoinpath()with Windows path objects also works._get_relative_posix()no longer needs itsPureWindowsPathspecial case.as_udf_path()builds the result withPurePosixPath, so the UDF path uses/on every platform.Behaviour on Linux and macOS is unchanged, because
PurePathis alreadyPurePosixPaththere.Two things on Windows are different now and worth a look:
PureWindowsPath/WindowsPathobjects are still accepted and converted.relative_to()returns aPurePosixPathinstead of aPureWindowsPath. I updated the one existing assertion that compared againstPurePath(...)accordingly.Tests
New
test/unit/test_bucket_path_separators.py(7 tests) uses a recording fake bucket API andPureWindowsPathinputs, so it runs the same on every OS and does not need to patchPurePaththe way the issue's Linux emulation does. It coversstr(),write()/read()/rm(),joinpath(),iterdir()andas_udf_path().On the unfixed code (Windows 11, Python 3.12) 5 of the new tests fail, with the backslash paths from the issue (
'dir\sub\a.txt' == 'dir/sub/a.txt'); with the fix all 7 pass.I also ran the whole
test/unitfolder on Windows. It does not pass on Windows even before this change (17 failures). With this change it is 14 failures, none new, andtest_joinpath,test_truedivandtest_archive_as_udf_pathnow pass. The remaining 14 come from thebucket_fakefixture:MountedBucket.fileson a local directory returns backslash paths on Windows. I left that out because it is a separate code path (a locally mounted bucket) from the one in this issue, but I'm happy to look at it in a follow-up if you want it.black --check,isort --checkandmypyare clean on the changed files. I did not run the integration tests or the fullnoxsessions.Checklist
doc/changes/unreleased.mdWritten with AI assistance (Claude Code). I reproduced the failure on my own Windows machine, read the fix, and verified the added tests fail before it and pass after. Errors are mine.
🤖 Generated with Claude Code