-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -1596,6 +1597,9 @@ _winapi_GetLongPathName_impl(PyObject *module, LPCWSTR path) | |
PyErr_SetFromWindowsErr(0); | ||
} | ||
return result; | ||
#else | ||
return PyUnicode_FromWideChar(path, wcslen(path)); | ||
#endif | ||
} | ||
|
||
/*[clinic input] | ||
|
@@ -1649,6 +1653,7 @@ static PyObject * | |
_winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path) | ||
/*[clinic end generated code: output=dab6ae494c621e81 input=43fa349aaf2ac718]*/ | ||
{ | ||
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) | ||
DWORD cchBuffer; | ||
PyObject *result = NULL; | ||
|
||
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 be 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell we don't use this anywhere |
||
return NULL; | ||
#endif | ||
} | ||
|
||
/*[clinic input] | ||
|
@@ -2883,13 +2892,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 | ||
} | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.