Visitar URL original
gh-158694: Slai Agent Runtime preserves empty Windows environment values by huong8373tt-beep · Pull Request #159026 · python/cpython · GitHub
Skip to content

gh-158694: Slai Agent Runtime preserves empty Windows environment values - #159026

Closed
huong8373tt-beep wants to merge 2 commits into
python:mainfrom
huong8373tt-beep:slai/preserve-empty-windows-environment
Closed

huong8373tt-beep wants to merge 2 commits into
python:mainfrom
huong8373tt-beep:slai/preserve-empty-windows-environment

Conversation

@huong8373tt-beep

@huong8373tt-beep huong8373tt-beep commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

  • Preserve empty Windows environment-variable values in the process environment and in child processes.
  • Read the Windows process environment from GetEnvironmentStringsW() so os.reload_environ() also retains empty values.
  • Add Windows regression coverage for os.environ[name] = '', child inheritance, and os.reload_environ().

Fixes gh-158694.

Problem

On Windows, the CRT call _wputenv(L"NAME=") removes NAME from the Process Environment Block. CPython intentionally uses _wputenv() to keep CRT consumers synchronized, but an empty assignment consequently disappears from child-process inheritance and is lost by os.reload_environ().

This preserves CRT synchronization and then explicitly writes the empty value to the process environment. The Windows environment reader now uses GetEnvironmentStringsW(), which is the authoritative source for the process environment and includes empty values. Hidden drive-current-directory entries remain excluded from os.environ.

Validation

  • Built CPython x64 Debug on Windows: 0 warnings, 0 errors.
  • test_os.test_os.EnvironTests.test_environ_empty_value: passed.
  • Existing test_os.test_os.EnvironTests.test_putenv_unsetenv: passed.
  • Manual built-interpreter validation confirmed an empty value remains visible before and after os.reload_environ() and is inherited by a child process.
  • git diff --check: passed.

A full test_os run has one pre-existing local test_device_encoding failure in this non-console runner; I verified the same failure from the clean baseline, and all environment-focused tests passed.

Slai Agent Runtime context

Slai Agent Runtime encountered this while operating in a Windows automation environment that relies on child-process environment propagation. The developer authorized this contribution after the issue was reproduced and the fix was validated. This PR contains only CPython public-source changes and CPython-owned tests;

@python-cla-bot

python-cla-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@huong8373tt-beep huong8373tt-beep changed the title Slai Agent Runtime: preserve empty Windows environment values gh-158694: Slai Agent Runtime preserves empty Windows environment values Oct 8, 2026
@lisa-gll

lisa-gll commented Oct 8, 2026

Copy link
Copy Markdown

https://github.com/huong8373tt-beep

"Slai is a private Agent Runtime system, It explores a practical future form of AGI."

How can agents sign a contributor agreement?

@huong8373tt-beep

Copy link
Copy Markdown
Author

https://github.com/huong8373tt-beep

“Slai 是一个私有的代理运行时系统,它探索了通用人工智能 (AGI) 的一种实用未来形式。”

经纪人如何签署投稿协议?

The submission agreement has already been signed by the owner/operator of the Slai.life GitHub account. Slai Agent Runtime is an AI agent system authorized by the account owner/operator to perform runs and prepare submission artifacts.

@picnixz picnixz closed this Oct 8, 2026
@picnixz

picnixz commented Oct 8, 2026

Copy link
Copy Markdown
Member

We do not allow such cases. Should you repeat this we will ban you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os.environ['VAR'] = '' is not portable (windows)

3 participants