Skip to content

gh-152433: Windows: use CreateFile2 on Windows UWP build - #153021

Open
thexai wants to merge 2 commits into
python:mainfrom
thexai:uwp-createfile
Open

thexai wants to merge 2 commits into
python:mainfrom
thexai:uwp-createfile

Conversation

@thexai

@thexai thexai commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Windows: use CreateFile2 on Windows UWP build.

UWP does not support CreateFileW because it is only compatible with the Win32 desktop API.

CreateFile2 is available in all supported Windows versions (it could be used for everything) but for now created a wrapper to use only in UWP and avoid side effects or unexpected behavior changes on regular Windows builds.

UWP also needs convert absolute paths to relative paths due the security restrictions, so the wrapper solution is good because it does both things at the same time.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 6, 2026
UWP does not support ``CreateFileW`` because it is only compatible
with the Win32 desktop API.
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Nov 7, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Nov 11, 2026
@cmaloney

Copy link
Copy Markdown
Contributor

Please don't force push (https://devguide.python.org/getting-started/pull-request-lifecycle/index.html#don-t-force-push).

In my first high level look this seems to change behavior of existing cases which we need to separate out from "use the new function". 1-1 move is a lot simpler to get in than move and change behavior.

@thexai

thexai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Well, for Windows Desktop is no behavior change:

CreateFileW is replaced by _Py_WinCreateFile and inside is called CreateFileW again with the same parameters.

For UWP CreateFileW calls are translated to CreateFile2 and absolute paths converted to relative paths when makes sense (e.g. loading Python modules).

The second commit is only a small refactor.

This has tested and works for Apps with embedded Python like Kodi on Xbox.

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

Labels

awaiting review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants