Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126782: Support qualified referencing for ntpath.abspath() #126784

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

nineteendo
Copy link
Contributor

@nineteendo nineteendo commented Nov 13, 2024

@nineteendo nineteendo marked this pull request as ready for review November 13, 2024 19:26
@nineteendo nineteendo marked this pull request as draft November 13, 2024 19:57
@nineteendo nineteendo marked this pull request as ready for review November 13, 2024 22:10
@nineteendo
Copy link
Contributor Author

cc @zooba, @eryksun

@@ -839,6 +839,20 @@ def test_abspath(self):
tester('ntpath.abspath("")', cwd_dir)
tester('ntpath.abspath(" ")', cwd_dir + "\\ ")
tester('ntpath.abspath("?")', cwd_dir + "\\?")
tester('ntpath.abspath("con")', r"\\.\con")
# bpo-45354: Windows 11 changed MS-DOS device name handling
if sys.getwindowsversion()[:3] < (10, 0, 22000):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we test on Windows 10 and 11?

@zooba
Copy link
Member

zooba commented Dec 2, 2024

How close do we get just by swapping the order of the normpath call?

If we can't do that, I'd prefer to see more of the logic on the Python side of things, and better naming than "explicit" and "curdir".

@nineteendo
Copy link
Contributor Author

nineteendo commented Dec 2, 2024

How close do we get just by swapping the order of the normpath call?

You get other problems (and just replacing '/' with '\\' isn't enough), see: #30571

I'd prefer to see more of the logic on the Python side of things

It's the same idea, detect whether the path contained '.' or '..' and is not relative to the cwd, then prepend './'. It'll just be slower.

better naming than "explicit" and "curdir"

I'm bad at naming things, but we're doing something complicated here. It's just an internal option though.

  • Parameter explicit_curdir: do the thing I described above
  • Variable explicit: the original path contained '.' or '..'

Edit: Some other options are alternative_path, disambiguate, qualified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants