Skip to content

Two tests from test.test_asyncio.test_subprocess fail if path to cpython contains spaces #150244

@Jayman2000

Description

@Jayman2000

Bug report

Bug description:

If you’re on a UNIX(-like) system and the path to your local clone of the cpython repository contains spaces, then two of the tests from test.test_asyncio.test_subprocess (test_create_subprocess_env_shell and test_create_subprocess_env_shell) will fail.

Steps to Reproduce

  1. Make sure that the path to your local clone of the cpython repository contains at least one space.

  2. Open a terminal.

  3. (Optional) Make sure that you’re using the same set of dependencies that I did when I built CPython by doing the following:

    1. Make sure that the Nix package manager is installed by running this command:

      nix-shell --version

      If that command finishes successfully, then Nix is installed. If that command gives you an error, then you need to install Nix.

    2. Create a file named shell-for-working-on-cpython.nix that contains the following Nix expression:

      # This file is dedicated to the public domain using 🅭🄍1.0:
      # <https://creativecommons.org/publicdomain/zero/1.0>.
      let
        # At the moment, this commit is the tip of Nixpkgs’s nixos-25.11 branch.
        nixpkgsCommit = "687f05a9184cad4eaf905c48b63649e3a86f5433";
        nixpkgsDirectory = builtins.fetchTarball {
          url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsCommit}.tar.gz";
          sha256 = "1n1lqgnk84mf28v23f3q8z6xwc79biqwqqy84cg75mrrpa65k4mx";
        };
        pkgs = import nixpkgsDirectory { };
      in
      pkgs.mkShell {
        name = "shell-for-working-on-cpython";
      }
    3. Activate that Nix shell by running this command:

      nix-shell <path to shell-for-working-on-cpython.nix>
  4. Change directory into the root of your local copy of the CPython Git repository by running this command:

    cd <path to cpython repo>
  5. (Optional) Switch to a specific revision of CPython that is know to have this issue by running this command:

    git switch --detach 9604fa8c009588a343ac542097273e0aca7a220b
  6. Configure CPython by running this command:

    ./configure --with-pydebug
  7. Build CPython by running this command:

    make -j "$(nproc)"
  8. Run the tests in test.test_asyncio.test_subprocess running this command:

    ./python -m test.test_asyncio.test_subprocess

Results

[nix-shell:~/Documents/Home/VC/Git/Partially mine/cpython/Repo]$ ./python -m test.test_asyncio.test_subprocess
........./bin/sh: line 1: /home/jayman/Documents/Home/VC/Git/Partially: No such file or directory
F................................Unknown child process pid 200364, will report returncode 255
....../bin/sh: line 1: /home/jayman/Documents/Home/VC/Git/Partially: No such file or directory
F................................
======================================================================
FAIL: test_create_subprocess_env_shell (__main__.SubprocessPidfdWatcherTests.test_create_subprocess_env_shell)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/test/test_asyncio/test_subprocess.py", line 784, in test_create_subprocess_env_shell
    self.loop.run_until_complete(self.check_stdout_output(main(), b'bar'))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/test/test_asyncio/test_subprocess.py", line 765, in check_stdout_output
    self.assertEqual(stdout, output)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
AssertionError: b'' != b'bar'

======================================================================
FAIL: test_create_subprocess_env_shell (__main__.SubprocessThreadedWatcherTests.test_create_subprocess_env_shell)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/test/test_asyncio/test_subprocess.py", line 784, in test_create_subprocess_env_shell
    self.loop.run_until_complete(self.check_stdout_output(main(), b'bar'))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/jayman/Documents/Home/VC/Git/Partially mine/cpython/Repo/Lib/test/test_asyncio/test_subprocess.py", line 765, in check_stdout_output
    self.assertEqual(stdout, output)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
AssertionError: b'' != b'bar'

----------------------------------------------------------------------
Ran 81 tests in 8.205s

FAILED (failures=2)

[nix-shell:~/Documents/Home/VC/Git/Partially mine/cpython/Repo]$ 

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions