Repository navigation
Conversation
The inplace launcher passes each comma-separated entry of PYTHONWARNINGS to the interpreter as `-W<entry>`. An empty entry, from `PYTHONWARNINGS=` or a trailing comma, became a bare `-W`, which takes the next argument as its value: `-c`, so the interpreter tried to open the startup code as a script and every inplace binary failed to start. Before another entry, it swallowed that entry instead. Leave empty entries out, as Python itself does when it reads the variable.
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D134829297. (Because this pull request was imported automatically, there will not be any future comments.) |
Contributor
|
This pull request has been merged in 7f2701c. |
meta-codesync Bot
pushed a commit
to meta/buck2-prelude
that referenced
this pull request
Nov 28, 2026
Summary: The inplace launcher (`prelude/python/tools/run_inplace.py.in`) passes each comma-separated entry of `PYTHONWARNINGS` to the interpreter as `-W<entry>`. An empty entry, from `PYTHONWARNINGS=` or a trailing comma, becomes a bare `-W`. That option takes the next argument as its value. When the empty entry comes last, the next argument is `-c`: the interpreter then tries to open the startup code as a script, and the `python_binary` or `python_test` never starts. When another entry follows, the bare `-W` swallows that entry instead, and its filter is lost. CPython accepts both values: it skips empty entries when it reads the variable. This PR does the same. ## Affected version origin/main 00c2ee4f74. The loop is unchanged since the initial commit. ## Reproduction ```python python_binary(name = "bin", main = "main.py") ``` ``` PYTHONWARNINGS= buck2 run :bin PYTHONWARNINGS='ignore::DeprecationWarning,' buck2 run :bin ``` ## Expected The binary runs, as `PYTHONWARNINGS= python3 main.py` does. ## Actual ``` Invalid -W option ignored: invalid action: '-c' .../bin/python: can't open file '.../# .../bin.par\n# Wrap everything in a private function ...': [Errno 63] File name too long ``` With `PYTHONWARNINGS=' , default'`, the binary runs but prints `Invalid -W option ignored: invalid action: '-Wdefault'`. X-link: meta/buck2#1667 Reviewed By: dtolnay Differential Revision: D134829297 fbshipit-source-id: ffc6b11045b09fb3129b91d840a29f9c16f181e5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The inplace launcher (
prelude/python/tools/run_inplace.py.in) passes each comma-separated entry ofPYTHONWARNINGSto the interpreter as-W<entry>. An empty entry, fromPYTHONWARNINGS=or a trailing comma, becomes a bare-W. That option takes the next argument as its value. When the empty entry comes last, the next argument is-c: the interpreter then tries to open the startup code as a script, and thepython_binaryorpython_testnever starts. When another entry follows, the bare-Wswallows that entry instead, and its filter is lost.CPython accepts both values: it skips empty entries when it reads the variable. This PR does the same.
Affected version
origin/main 00c2ee4. The loop is unchanged since the initial commit.
Reproduction
Expected
The binary runs, as
PYTHONWARNINGS= python3 main.pydoes.Actual
With
PYTHONWARNINGS=' , default', the binary runs but printsInvalid -W option ignored: invalid action: '-Wdefault'.Test plan
prelude/python/tools/tests/make_py_package_inplace_test.py: the newWarningsTestlaunches the real template withPYTHONWARNINGSset to"","ignore::DeprecationWarning,"and" , default". It expects a successful run with no "Invalid -W option". All three cases fail without the fix and pass with it._launchmoves out ofSafePathTestto module level so both test classes share it.buck2 runof apython_binarywith the prelude's demo toolchains on macOS: both values above failed before the change and run after it.TrampolineRuntimeTestcases fail on origin/main unlessTMPDIRis set to its resolved path. They compare against/var/...while the launcher reports/private/var/.... That is unrelated to this change; with a resolvedTMPDIR, all 13 tests pass.