gh-152433: Windows: Allow build winreg module for UWP - #154918
Conversation
|
Out of interest, what would it look like to make those imports conditional? They ought to be anyway, and I suspect we'll end up with better overall behaviour if they handle this as "no registry access exists" rather than "registry accesses always fail". |
|
I don't really know how it would be done because it requires modifying a lot of Python code and introduce helper functions or constants to identify UWP / GAMES builds as "another platform". This is beyond the scope of this PR. In addition to this, I want to avoid modifying the behavior of This PR allows compile the current code for UWP and is actually a simplification because it removes 185 lines of code. Without this PR, the resulting UWP builds won't work because they try to import a module that doesn't exist --> hard crash. With this PR, you can use the rest of the Python code in UWP, and even if a Python script includes Previously, Windows Registry was available for "Windows Phone" in the |
|
Having had a quick look, it seems like Some of the test suite also assumes the module will be there, and those ought to be handled either at the There's no need to modify anything conditionally on the build, it's just going to be something like: try:
import winreg
except ImportError:
winreg = None
...
if winreg:
# do the thing requiring the registry
else:
# fallback behaviour if neededFor |
In current code,
winregmodule is not build because code guards not includeMS_WINDOWS_APP.Instead of add
MS_WINDOWS_APPcondition, guards removed when is:(as includes all Windows families)
Or replaced with
MS_WINDOWSwhen code is for all platforms.The clinic's code also regenerated, resulting in the removal of many redundant conditions.
Note that Windows Registry is not accessible from UWP Apps (or Games) but for consistency is necessary build module as is imported in many places at Python initialization. The same logic was already being applied with
MS_WINDOWS_GAMESbuild.