Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
OS-netbsdtestsTests in the Lib/test dirTests in the Lib/test dirtopic-venvRelated to the venv moduleRelated to the venv moduletype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The test_venv.BasicTest.test_special_chars_csh test fails on NetBSD. NetBSD's csh cannot properly handle the specific character combination '";&&$e|"' even when correctly quoted, because $e is interpreted as a variable reference.
Configuration
./configure --with-pydebugTest
home$ ./python-mtesttest_venv-mtest_special_chars_csh-v==CPython3.15.0a0free-threadingbuild (heads/main:e8382e55c57, Sep232025, 21:04:49) [GCC10.5.0] ==NetBSD-10.1-amd64-x86_64-64bit-ELFlittle-endian==Pythonbuild: free_threadingdebug==cwd:/home/orange/cpython/build/test_python_worker_6821æ==CPUcount: 16==encodings: locale=UTF-8FS=utf-8==resources: alltestresourcesaredisabled, use-uoptiontounskiptestsUsingrandomseed: 35170635750:00:00loadavg: 0.08Run1testsequentiallyinasingleprocess0:00:00loadavg: 0.08 [1/1] test_venvtest_special_chars_csh (test.test_venv.BasicTest.test_special_chars_csh) Testthatthetemplatestringsarequotedproperly (csh) ... prompt: Undefinedvariable. ERROR======================================================================ERROR: test_special_chars_csh (test.test_venv.BasicTest.test_special_chars_csh) Testthatthetemplatestringsarequotedproperly (csh) ----------------------------------------------------------------------Traceback (mostrecentcalllast): File"/home/orange/cpython/Lib/test/test_venv.py", line544, intest_special_chars_cshout, err=check_output([csh, test_script]) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^File"/home/orange/cpython/Lib/test/test_venv.py", line58, incheck_outputraisesubprocess.CalledProcessError( p.returncode, cmd, out, err) subprocess.CalledProcessError: Command'['/bin/csh', '/tmp/tmp82wovfyk/test_special_chars.csh']'returnednon-zeroexitstatus1.----------------------------------------------------------------------Ran1testin1.969sFAILED (errors=1) testtest_venvfailed0:00:02loadavg: 0.15 [1/1/1] test_venvfailed (1error) ==Testsresult: FAILURE==1testfailed: test_venvTotalduration: 2.3secTotaltests: run=1 (filtered) Totaltestfiles: run=1/1 (filtered) failed=1Result: FAILUREhome$Reproduce
importosimporttempfileimportshutilimportsubprocessimportshlexfromvenvimportEnvBuilderdeftest_original_test_case(): print("\n=== Reproducing original test case ===") csh=shutil.which('tcsh') orshutil.which('csh') ifnotcsh: print("No csh/tcsh found, skipping test") returnwithtempfile.TemporaryDirectory() astmpdir: env_name='";&&$e|"'env_dir=os.path.join(os.path.realpath(tmpdir), env_name) try: builder=EnvBuilder(clear=True) builder.create(env_dir) activate=os.path.join(env_dir, 'bin', 'activate.csh') test_script=os.path.join(tmpdir, 'test_special_chars.csh') withopen(test_script, "w") asf: f.write(f'source {shlex.quote(activate)}\n''python -c \'import sys; print(sys.executable)\'\n''python -c \'import os; print(os.environ["VIRTUAL_ENV"])\'\n''deactivate\n') print(f"\nRunning test script with {csh}:") try: result=subprocess.run([csh, test_script], capture_output=True, text=True, timeout=10) print(f"Return code: {result.returncode}") ifresult.returncode==0: print(f"Output: {result.stdout}") else: print(f"Error: {result.stderr}") exceptExceptionase: print(f"Error running test: {e}") exceptExceptionase: print(f"Error in test case: {e}") if__name__=="__main__": test_original_test_case()Output:
home:{5} ./python reproducer.py === Reproducing original testcase === Running test script with /bin/csh: Return code: 1 Error: prompt: Undefined variable. home:{6} echo$SHELL /bin/csh# This FAILS with "Unmatched ." error /bin/csh -c 'echo "Testing: \";&&$e|\""'# This FAILS with "e: Undefined variable." error /bin/csh -c 'echo "Testing: '\'';&&$e|'\''"'# This WORKS correctly /bin/csh -c 'echo '\''";&&$e|"'\'''CPython versions tested on:
CPython main branch, 3.15, 3.14, 3.13
Operating systems tested on:
Other
Linked PRs
- gh-139308: Skip test_special_chars_csh on NetBSD due to csh variable expansion issue #139341
- [3.14] gh-139308: Skip test_special_chars_csh on NetBSD due to csh variable expansion issue (GH-139341) #139559
- [3.13] gh-139308: Skip test_special_chars_csh on NetBSD due to csh variable expansion issue (GH-139341) #139560
Metadata
Metadata
Assignees
Labels
OS-netbsdtestsTests in the Lib/test dirTests in the Lib/test dirtopic-venvRelated to the venv moduleRelated to the venv moduletype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error