Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c4b34c

Browse files
authored
gh-134041: Make _winapi functions compatible with non-desktop API partitions (GH-134042)
1 parent 4341095 commit 1c4b34c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Modules/_winapi.c

+12
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ static PyObject *
15731573
_winapi_GetLongPathName_impl(PyObject *module, LPCWSTR path)
15741574
/*[clinic end generated code: output=c4774b080275a2d0 input=9872e211e3a4a88f]*/
15751575
{
1576+
#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
15761577
DWORD cchBuffer;
15771578
PyObject *result = NULL;
15781579

@@ -1596,6 +1597,9 @@ _winapi_GetLongPathName_impl(PyObject *module, LPCWSTR path)
15961597
PyErr_SetFromWindowsErr(0);
15971598
}
15981599
return result;
1600+
#else
1601+
return PyUnicode_FromWideChar(path, -1);
1602+
#endif
15991603
}
16001604

16011605
/*[clinic input]
@@ -1632,6 +1636,8 @@ _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle)
16321636
return PyUnicode_FromWideChar(filename, wcslen(filename));
16331637
}
16341638

1639+
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
1640+
16351641
/*[clinic input]
16361642
_winapi.GetShortPathName
16371643
@@ -1674,6 +1680,8 @@ _winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path)
16741680
return result;
16751681
}
16761682

1683+
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
1684+
16771685
/*[clinic input]
16781686
_winapi.GetStdHandle -> HANDLE
16791687
@@ -2883,13 +2891,17 @@ _winapi_NeedCurrentDirectoryForExePath_impl(PyObject *module,
28832891
LPCWSTR exe_name)
28842892
/*[clinic end generated code: output=a65ec879502b58fc input=972aac88a1ec2f00]*/
28852893
{
2894+
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
28862895
BOOL result;
28872896

28882897
Py_BEGIN_ALLOW_THREADS
28892898
result = NeedCurrentDirectoryForExePathW(exe_name);
28902899
Py_END_ALLOW_THREADS
28912900

28922901
return result;
2902+
#else
2903+
return TRUE;
2904+
#endif
28932905
}
28942906

28952907

Modules/clinic/_winapi.c.h

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)