Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134041: Avoid usage of unavailable windows path apis#134042

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
zooba merged 3 commits intopython:mainfrommaxbachmann:patch-8
May 15, 2025

Conversation

maxbachmann
Copy link
Contributor

@maxbachmannmaxbachmann commentedMay 15, 2025
edited by bedevere-appbot
Loading

This doesn't contain a doc entry yet, since I wasn't sure about some of the changes yet:
Right now I have the following changes:

  • _winapi.GetLongPathName: I believe in the gaming partition you simply don't have short name support and so returning the path should be fine
  • _winapi.GetShortPathName: throws an exception as unsupported
  • _winapi.NeedCurrentDirectoryForExePath: I have absolutely no clue whether this should be True or False. Really I don't usually start different executables on these targets. Even if I do, I would always use a full path or have the exe placed next to my main executable. So really no clue whether this should: return True, False, throw an exception or be unavailable

@maxbachmann
Copy link
ContributorAuthor

maxbachmann commentedMay 15, 2025
edited
Loading

@zooba I found some more cases that I was working around by explicitly linking the kernel32 lib (which shouldn't be done).

It's the three done in here and the newos.get_blocking/os.set_blocking on windows.
That one is also weird because it looks likeGetNamedPipeHandleStateW is unavailable butSetNamedPipeHandleState is available 😕

@@ -1672,6 +1677,10 @@ _winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path)
PyErr_SetFromWindowsErr(0);
}
return result;
#else
PyErr_SetString(PyExc_OSError, "GetShortPathName unavailable on this platform");
Copy link
Member

Choose a reason for hiding this comment

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

Your call here, but if you put the ifdef around the entire function definition and regenerate the clinic headers (should bepython Tools\clinic\clinic.py Modules\_winapi.c unless someone finally moved the clinic.py script) then it should entirely omit the function when you build.

Or maybe it'd make sense just to return the original string again? I'm not sure where this function gets used, but in general, unconditional errors are harder to detect than a missing function, and are less convenient than sensible-but-technically-incorrect behaviours. This is an internal module, so we only really need to consider stdlib uses, though of course we want to avoid breaking existing third-party code as well.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

As far as I can tell we don't use this anywhere

@zooba
Copy link
Member

That one is also weird because it looks likeGetNamedPipeHandleStateW is unavailable butSetNamedPipeHandleState is available

IIUC, the game API functions are basically decided by what is requested, so I guess someone needed to set the state but not read it (which seems reasonable - you'd normally set the state to what you need rather than what's "best").

If they're needed by other internal functions, we might just need to get the Get one directly from the DLL (which is fine as long as wesafely handle the case where we can't get it). If you prefer to just omit the entire function then that's fine by me.

@maxbachmann
Copy link
ContributorAuthor

If they're needed by other internal functions, we might just need to get the Get one directly from the DLL (which is fine as long as we safely handle the case where we can't get it). If you prefer to just omit the entire function then that's fine by me.

Would be fine with me as long as I know which dll to retrieve it from. In my original xbox change (https://github.com/python/cpython/pull/102256/files#diff-27e9033ac552bd8208213a2d5a0a294312e3918cd81c4da822ab32c382e392c4) we did the same forPathCchSkipRoot andPathCchCombineEx by retrieving it fromapi-ms-win-core-path-l1-1-0.dll.

@zooba
Copy link
Member

_winapi.NeedCurrentDirectoryForExePath: I have absolutely no clue whether this should be True or False.

I thinkTRUE is probably better. I'm thinking of cases where you might launch a script that runs a few processes, and is expecting to find tools in the script directory (probably CWD, likely not the "application" directory where python.exe is). But because it only affects the stdlib it probably only matters forshutil.which, so low impact in any case.

@zooba
Copy link
Member

Would be fine with me as long as I know which dll to retrieve it from

Docs say kernel32.dll. The path APIs are a bit special, as I don't think they were ever in kernel32 to begin with (they were advapi32 or shell32, IIRC), but really core stuff has always been accessible from kernel32.

It might also be in an API set, but that shouldn't matter. This API isn't going to change at any rate we care about, and if the dynamic load is limited to the non-desktop partitions than devs have a much better chance of being able to manage breakage than regular users on desktop.

@zooba
Copy link
Member

Skipping NEWS because it's an internal module and won't affect normal releases.

maxbachmann reacted with thumbs up emoji

@zoobazoobaenabled auto-merge (squash)May 15, 2025 11:38
@zoobazooba merged commit1c4b34c intopython:mainMay 15, 2025
40 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobazooba left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@maxbachmann@zooba

[8]ページ先頭

©2009-2025 Movatter.jp