]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46638: Makes registry virtualisation setting stable when building MSIX packages...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Feb 2022 17:37:01 +0000 (09:37 -0800)
committerGitHub <noreply@github.com>
Mon, 7 Feb 2022 17:37:01 +0000 (17:37 +0000)
(cherry picked from commit 3a5afc14e16370c1f4f72d43cb553298ad9a1fa4)

Misc/NEWS.d/next/Windows/2022-02-04-18-02-33.bpo-46638.mSJOSX.rst [new file with mode: 0644]
PC/layout/support/appxmanifest.py
PC/layout/support/constants.py

diff --git a/Misc/NEWS.d/next/Windows/2022-02-04-18-02-33.bpo-46638.mSJOSX.rst b/Misc/NEWS.d/next/Windows/2022-02-04-18-02-33.bpo-46638.mSJOSX.rst
new file mode 100644 (file)
index 0000000..536aae6
--- /dev/null
@@ -0,0 +1,4 @@
+Ensures registry virtualization is consistently disabled. For 3.10 and
+earlier, it remains enabled (some registry writes are protected), while for
+3.11 and later it is disabled (registry modifications affect all
+applications).
index 15119b02a802a7bdc7f37c6eab8ca4b36396c358..427a36f31c8f9edb5f1059d84235198cf63dc00c 100644 (file)
@@ -412,14 +412,22 @@ def get_appxmanifest(ns):
         if value:
             node.text = value
 
-    winver = sys.getwindowsversion()[:3]
+    try:
+        winver = tuple(int(i) for i in os.getenv("APPX_DATA_WINVER", "").split(".", maxsplit=3))
+    except (TypeError, ValueError):
+        winver = ()
+
+    # Default "known good" version is 10.0.22000, first Windows 11 release
+    winver = winver or (10, 0, 22000)
+
     if winver < (10, 0, 17763):
         winver = 10, 0, 17763
     find_or_add(xml, "m:Dependencies/m:TargetDeviceFamily").set(
-        "MaxVersionTested", "{}.{}.{}.0".format(*winver)
+        "MaxVersionTested", "{}.{}.{}.{}".format(*(winver + (0, 0, 0, 0)[:4]))
     )
 
-    if winver > (10, 0, 17763):
+    # Only for Python 3.11 and later. Older versions do not disable virtualization
+    if (VER_MAJOR, VER_MINOR) >= (3, 11) and winver > (10, 0, 17763):
         disable_registry_virtualization(xml)
 
     app = add_application(
index 6cf0fe1d34c4ac7be1e4a978af93e769a8995d07..6efd8bcd5cbb5ef41622b4530795ac9253491f95 100644 (file)
@@ -16,7 +16,7 @@ def _unpack_hexversion():
         hexversion = int(os.getenv("PYTHON_HEXVERSION"), 16)
     except (TypeError, ValueError):
         hexversion = sys.hexversion
-    return struct.pack(">i", sys.hexversion)
+    return struct.pack(">i", hexversion)
 
 
 def _get_suffix(field4):