Skip to content

gh-148750: Fix embed layout pythoninfo failure and guard missing test-results publish in Azure - #149926

Closed
emixor wants to merge 2 commits into
python:mainfrom
emixor:main
Closed

emixor wants to merge 2 commits into
python:mainfrom
emixor:main

Conversation

@emixor

@emixor emixor commented May 16, 2026 •

Copy link
Copy Markdown

Summary

This PR fixes the Windows embed-layout CI failure and reduces related Azure test-result publishing noise.

The root cause is in test.pythoninfo on Windows. collect_windows() launches wmic with encoding="oem", which can raise LookupError: unknown encoding: oem in embed-layout environments. This PR switches to an explicit codec built from _winapi.GetOEMCP().

It also keeps Azure layout jobs resilient by skipping the test.pythoninfo step for kind: embed, and by publishing layout test results only when the XML file exists.

Changes

1. Lib/test/pythoninfo.py

  • Use the OEM code page from _winapi.GetOEMCP().
  • Record it with info_add("windows.oem_code_page", ...).
  • Decode wmic output with an explicit codec (cp{OEMCP}) instead of "oem".
  • Use a local wmic_encoding variable for the Popen(..., encoding=...) call.

2. .azure-pipelines/windows-layout-steps.yml

  • Run .\python.exe -m test.pythoninfo only when parameters.kind != 'embed'.
  • For parameters.kind == 'embed', keep the step slot but emit a clear skip message.
  • Update PublishTestResults@2 condition to:
  and(succeededOrFailed(), exists('$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml'))

so publishing is attempted only when the XML file is present.

Why this approach

  • The Python change addresses the codec failure directly.
  • The pipeline changes prevent a known embed-layout diagnostic step from failing the job and avoid warning-only noise when no JUnit XML is produced.

Testing

  • python -m py_compile Lib/test/pythoninfo.py

  • Local codec sanity check:

    • codecs.lookup("oem") fails with LookupError
    • codecs.lookup("cp437") resolves
  • Pipeline behavior validated by template inspection for both embed and non-embed paths.

@emixor
emixor requested a review from AA-Turner as a code owner May 16, 2026 21:55
@bedevere-app

bedevere-app Bot commented May 16, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented May 16, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@emixor emixor changed the title gh-148750: Fix embed layout pythoninfo failure and guard missing test-results publish in Azure May 16, 2026
@emixor emixor changed the title gh-149926: Fix embed layout pythoninfo failure and guard missing test-results publish in Azure May 16, 2026
@emixor

emixor commented May 26, 2026

Copy link
Copy Markdown
Author

This commit does not edit Python's code, thus it should not affect the tests. I have no idea why they fail.

@zooba

zooba commented Aug 11, 2026

Copy link
Copy Markdown
Member

This is not the PR we need for this issue - it's going to be related to getpath.py changes I would expect, if not something in Lib/encodings.

Fixing the test isn't sufficient, as it breaks in real use.

@ambv

ambv commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

This was addressed in #156183.

@ambv ambv closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants