8000 gh-134041: Avoid usage of unavailable windows path apis by maxbachmann · Pull Request #134042 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ static PyObject *
_winapi_GetLongPathName_impl(PyObject *module, LPCWSTR path)
/*[clinic end generated code: output=c4774b080275a2d0 input=9872e211e3a4a88f]*/
{
#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
DWORD cchBuffer;
PyObject *result = NULL;

Expand All @@ -1596,6 +1597,9 @@ _winapi_GetLongPathName_impl(PyObject *module, LPCWSTR path)
PyErr_SetFromWindowsErr(0);
}
return result;
#else
return PyUnicode_FromWideChar(path, -1);
#endif
}

/*[clinic input]
Expand Down Expand Up @@ -1632,6 +1636,8 @@ _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle)
return PyUnicode_FromWideChar(filename, wcslen(filename));
}

#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)

/*[clinic input]
_winapi.GetShortPathName

Expand Down Expand Up @@ -1674,6 +1680,8 @@ _winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path)
return result;
}

#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */

/*[clinic input]
_winapi.GetStdHandle -> HANDLE

Expand Down Expand Up @@ -2883,13 +2891,17 @@ _winapi_NeedCurrentDirectoryForExePath_impl(PyObject *module,
LPCWSTR exe_name)
/*[clinic end generated code: output=a65ec879502b58fc input=972aac88a1ec2f00]*/
{
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
BOOL result;

Py_BEGIN_ALLOW_THREADS
result = NeedCurrentDirectoryForExePathW(exe_name);
Py_END_ALLOW_THREADS

return result;
#else
return TRUE;
#endif
}


Expand Down
10 changes: 9 additions & 1 deletion Modules/clinic/_winapi.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0