GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_venv.test_special_chars_csh fails on NetBSD · Issue #139308 · python/cpython

test_venv.test_special_chars_csh fails on NetBSD #139308

New issue
Copy link
New issue
Copy link
Closed
Closed
test_venv.test_special_chars_csh fails on NetBSD#139308
Copy link
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

@furkanonder
furkanonder
opened on Sep 24, 2025
Issue body actions

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-pydebug

Test

home$ ./python -m test test_venv -m test_special_chars_csh -v
== CPython 3.15.0a0 free-threading build (heads/main:e8382e55c57, Sep 23 2025, 21:04:49) [GCC 10.5.0]
== NetBSD-10.1-amd64-x86_64-64bit-ELF little-endian
== Python build: free_threading debug
== cwd: /home/orange/cpython/build/test_python_worker_6821æ
== CPU count: 16
== encodings: locale=UTF-8 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests

Using random seed: 3517063575
0:00:00 load avg: 0.08 Run 1 test sequentially in a single process
0:00:00 load avg: 0.08 [1/1] test_venv
test_special_chars_csh (test.test_venv.BasicTest.test_special_chars_csh)
Test that the template strings are quoted properly (csh) ... prompt: Undefined variable.

ERROR

======================================================================
ERROR: test_special_chars_csh (test.test_venv.BasicTest.test_special_chars_csh)
Test that the template strings are quoted properly (csh)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/orange/cpython/Lib/test/test_venv.py", line 544, in test_special_chars_csh
    out, err = check_output([csh, test_script])
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/orange/cpython/Lib/test/test_venv.py", line 58, in check_output
    raise subprocess.CalledProcessError(
        p.returncode, cmd, out, err)
subprocess.CalledProcessError: Command '['/bin/csh', '/tmp/tmp82wovfyk/test_special_chars.csh']' returned non-zero exit status 1.

----------------------------------------------------------------------
Ran 1 test in 1.969s

FAILED (errors=1)
test test_venv failed
0:00:02 load avg: 0.15 [1/1/1] test_venv failed (1 error)

== Tests result: FAILURE ==

1 test failed:
    test_venv

Total duration: 2.3 sec
Total tests: run=1 (filtered)
Total test files: run=1/1 (filtered) failed=1
Result: FAILURE
home$

Reproduce

import os
import tempfile
import shutil
import subprocess
import shlex
from venv import EnvBuilder


def test_original_test_case():
    print("\n=== Reproducing original test case ===")

    csh = shutil.which('tcsh') or shutil.which('csh')
    if not csh:
        print("No csh/tcsh found, skipping test")
        return
    with tempfile.TemporaryDirectory() as tmpdir:
        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')
            with open(test_script, "w") as f:
                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}")
                if result.returncode == 0:
                    print(f"Output: {result.stdout}")
                else:
                    print(f"Error: {result.stderr}")
            except Exception as e:
                print(f"Error running test: {e}")

        except Exception as e:
            print(f"Error in test case: {e}")


if __name__ == "__main__":
    test_original_test_case()

Output:

home: {5} ./python reproducer.py

=== Reproducing original test case ===

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

Activity

  1. furkanonder
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    testsTests in the Lib/test dirTests in the Lib/test dir
    topic-venvRelated to the venv moduleRelated to the venv module
    OS-unsupported
    on Sep 24, 2025
  2. github-project-automation
    added this to Unsupported platformson Sep 24, 2025
  3. StanFromIreland
    added
    OS-netbsd
    and removed
    OS-unsupported
    on Sep 24, 2025
  4. furkanonder commented on Sep 25, 2025

    @furkanonder
    furkanonder
    on Sep 25, 2025
    ContributorAuthor
    More actions

    Based on the related NetBSD bug report #17826: {t,}csh backquote/braces expansion bug, which demonstrates that NetBSD's csh has issues with quote handling during expansion phases, I found a working approach:

    # This works - uses single quotes around the entire string
    /bin/csh -c 'echo '\''";&&$e|"'\'''

    Why this works; PR #17826 revealed that NetBSD's csh expansion routines don't properly respect quote boundaries. The workaround above uses nested single quotes (''') to completely isolate the problematic string from any expansion phases, similar to the recommendations in that bug report.

    I think we should skip this test on NetBSD.

  5. StanFromIreland
    removed this from Unsupported platformson Sep 25, 2025
  6. FFY00
    added 2 commits that reference this issue on Oct 4, 2025

    Merge branch 'main' into pythongh-139308

    bafe08c

    gh-139308: Skip test_special_chars_csh on NetBSD due to csh variable …

    ae6e7f5
  7. miss-islington
    added 2 commits that reference this issue on Oct 4, 2025

    pythongh-139308: Skip test_special_chars_csh on NetBSD due to csh var…

    3bd1a77

    pythongh-139308: Skip test_special_chars_csh on NetBSD due to csh var…

    f4115be
  8. furkanonder
    closed this as completedon Oct 6, 2025
  9. danigm
    added a commit that references this issue on Oct 7, 2025

    pythongh-139308: Skip test_special_chars_csh on NetBSD due to csh var…

    692c357
  10. encukou
    added a commit that references this issue on Oct 7, 2025

    [3.14] gh-139308: Skip test_special_chars_csh on NetBSD due to csh va…

    b4c3c0f
  11. vstinner
    added a commit that references this issue on Oct 8, 2025

    [3.13] gh-139308: Skip test_special_chars_csh on NetBSD due to csh va…

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

Metadata

Metadata

Assignees

No one assigned

    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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.