Skip to content

fix: report stderr as None when it is merged into stdout - #8

Merged
cuinixam merged 2 commits into
cuinixam:mainfrom
LeMollinger:feat/fix-stderr-always-empty
Sep 10, 2026
Merged

cuinixam merged 2 commits into
cuinixam:mainfrom
LeMollinger:feat/fix-stderr-always-empty

Conversation

@LeMollinger

Copy link
Copy Markdown
Contributor

Problem

execute(handle_errors=False) returns a CompletedProcess whose .stderr is always empty, whatever the command wrote. Everything the command printed is in .stdout.

CHILD = "import sys; sys.stderr.write('boom'); sys.exit(1)"
result = SubprocessExecutor(["python", "-c", CHILD]).execute(handle_errors=False)
print(repr(result.returncode), repr(result.stderr), repr(result.stdout))
# before: 1 '' 'boom'
# after:  1 None 'boom'

"" claims the command wrote nothing to stderr, so code like logger.warning(f"failed:\n{result.stderr}") reads as correct and stays permanently blank.

Why this fix

The streams are merged on purpose (stderr=subprocess.STDOUT), which keeps the progress and error lines in chronological order. That behaviour is right and stays.

Only the reported value is wrong. There is no second pipe to read, so stderr keeps its initial "". Setting that initial value to None fixes it: None is what the standard library means by "not captured", and it is what the print_output=False path already returned via communicate() — the three execution paths simply disagreed with each other.

The docstrings now say that stderr is merged into stdout and callers read .stdout.

@LeMollinger

Copy link
Copy Markdown
Contributor Author

The second commit is unrelated to the fix: pypeline-runner now rejects an unquoted python_version in pypeline.yaml, which fails lint and all test jobs on every PR and on main. Happy to split it into its own PR if you prefer.

@cuinixam cuinixam left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 👍

@cuinixam
cuinixam merged commit ed8dfe4 into cuinixam:main Sep 10, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
release — 762a4518 Deployed Sep 10, 2026 by LeMollinger via release #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants