From 7d71f8a98a15347be74a680258c6e76362ea94d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95mir=20=D0=92=2E?= <224896369+emixor@users.noreply.github.com> Date: Sat, 16 May 2026 21:43:17 +0000 Subject: [PATCH 1/3] gh-148750: avoid _winapi dependency leak in pythoninfo wmic codec Use a local wmic_encoding variable derived from GetOEMCP() when _winapi is available. This keeps the OEM code page fix while avoiding a NameError risk from referencing _winapi directly in Popen() arguments. --- Lib/test/pythoninfo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 7f735d75b318e7..af8b11ae0b0c3f 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -929,6 +929,7 @@ def collect_windows(info_add): IsUserAnAdmin.argtypes = () info_add('windows.is_admin', IsUserAnAdmin()) + wmic_encoding = None try: import _winapi except ImportError: @@ -941,7 +942,9 @@ def collect_windows(info_add): pass call_func(info_add, 'windows.ansi_code_page', _winapi, 'GetACP') - call_func(info_add, 'windows.oem_code_page', _winapi, 'GetOEMCP') + oem_code_page = _winapi.GetOEMCP() + info_add('windows.oem_code_page', oem_code_page) + wmic_encoding = f"cp{oem_code_page}" # windows.version_caption: "wmic os get Caption,Version /value" command import subprocess @@ -951,7 +954,7 @@ def collect_windows(info_add): proc = subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, - encoding="oem", + encoding=wmic_encoding, text=True) output, stderr = proc.communicate() if proc.returncode: From f18f924fa0ded8bf25d7b9c1208ce6829ca2c999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95mir=20=D0=92=2E?= <224896369+emixor@users.noreply.github.com> Date: Sat, 16 May 2026 21:44:42 +0000 Subject: [PATCH 2/3] Azure: skip pythoninfo for embed layout and gate appx results publish --- .azure-pipelines/windows-layout-steps.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/windows-layout-steps.yml b/.azure-pipelines/windows-layout-steps.yml index afd89781790494..f64271ffdd741c 100644 --- a/.azure-pipelines/windows-layout-steps.yml +++ b/.azure-pipelines/windows-layout-steps.yml @@ -7,9 +7,14 @@ steps: - script: .\python.bat PC\layout -vv -s "$(Build.SourcesDirectory)" -b "$(Py_OutDir)\$(arch)" -t "$(Build.BinariesDirectory)\layout-tmp-${{ parameters.kind }}-$(arch)" --copy "$(Build.BinariesDirectory)\layout-${{ parameters.kind }}-$(arch)" ${{ parameters.extraOpts }} --preset-${{ parameters.kind }} --include-tests displayName: Create ${{ parameters.kind }} layout -- script: .\python.exe -m test.pythoninfo - workingDirectory: $(Build.BinariesDirectory)\layout-${{ parameters.kind }}-$(arch) - displayName: Show layout info (${{ parameters.kind }}) +- ${{ if ne(parameters.kind, 'embed') }}: + - script: .\python.exe -m test.pythoninfo + workingDirectory: $(Build.BinariesDirectory)\layout-${{ parameters.kind }}-$(arch) + displayName: Show layout info (${{ parameters.kind }}) + +- ${{ if eq(parameters.kind, 'embed') }}: + - script: echo Skipping test.pythoninfo for embed layout because the embeddable package intentionally omits parts of the standard library used by pythoninfo. + displayName: Show layout info (${{ parameters.kind }}) - ${{ if eq(parameters.fulltest, 'true') }}: - script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml" --tempdir "$(Build.BinariesDirectory)\tmp-${{ parameters.kind }}-$(arch)" -i test_launcher @@ -25,4 +30,4 @@ steps: mergeTestResults: true testRunTitle: ${{ parameters.kind }}-$(testRunTitle) platform: $(testRunPlatform) - condition: succeededOrFailed() + condition: and(succeededOrFailed(), exists('$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml')) From 5cc0643d72b1ce0ffeefdffab54f3733acea5301 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 16 May 2026 22:02:36 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2026-05-16-22-02-35.gh-issue-148750.UHu9mL.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-05-16-22-02-35.gh-issue-148750.UHu9mL.rst diff --git a/Misc/NEWS.d/next/Tests/2026-05-16-22-02-35.gh-issue-148750.UHu9mL.rst b/Misc/NEWS.d/next/Tests/2026-05-16-22-02-35.gh-issue-148750.UHu9mL.rst new file mode 100644 index 00000000000000..b330811595f28a --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-05-16-22-02-35.gh-issue-148750.UHu9mL.rst @@ -0,0 +1 @@ +Windows embed-layout Azure jobs no longer fail when collecting ``test.pythoninfo``. The ``wmic`` output is now decoded with the Windows OEM code page returned by ``_winapi.GetOEMCP()``, and the Azure layout pipeline skips the diagnostic step for the embeddable build while publishing test results only when the XML file exists.