Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_cmd_line.test_non_interactive_output_buffering fails when PYTHONUNBUFFERED is enabled #128377

Open
WolframAlph opened this issue Dec 31, 2024 · 0 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@WolframAlph
Copy link
Contributor

WolframAlph commented Dec 31, 2024

Bug report

Bug description:

Reproducer:

➜  cpython git:(main) ✗ export PYTHONUNBUFFERED=1         
➜  cpython git:(main) ✗ python3 -m test test_cmd_line
Using random seed: 2481773783
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 2.40 Run 1 test sequentially in a single process
0:00:00 load avg: 2.40 [1/1] test_cmd_line
test test_cmd_line failed -- Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/test/test_cmd_line.py", line 348, in test_non_interactive_output_buffering
    self.assertEqual(proc.stdout,
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
                     'False False False\n'
                     ^^^^^^^^^^^^^^^^^^^^^
                     'False False True\n')
                     ^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'False True False\nFalse True False\n' != 'False False False\nFalse False True\n'
- False True False
?       ^^^
+ False False False
?       ^^^^
- False True False
+ False False True


test_cmd_line failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_cmd_line

Total duration: 2.8 sec
Total tests: run=59 failures=1 skipped=1
Total test files: run=1/1 failed=1
Result: FAILURE

Test expects buffered stdio but does not check for PYTHONUNBUFFERED.
Init config for buffering:

cpython/Python/initconfig.c

Lines 1786 to 1790 in e389d6c

int unbuffered_stdio = 0;
_Py_get_env_flag(use_env, &unbuffered_stdio, "PYTHONUNBUFFERED");
if (unbuffered_stdio) {
config->buffered_stdio = 0;
}

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

@WolframAlph WolframAlph added the type-bug An unexpected behavior, bug, or error label Dec 31, 2024
@WolframAlph WolframAlph changed the title test_cmd_line fails when PYTHONUNBUFFERED is enabled test_cmd_line.test_non_interactive_output_buffering fails when PYTHONUNBUFFERED is enabled Dec 31, 2024
@picnixz picnixz added the tests Tests in the Lib/test dir label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants