Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Adam Johnson
Albin Vass
Alex Grönholm
Alexander Loechel
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/2417.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid importing ``pipes`` on Python 3.3+ to avoid ``DeprecationWarning`` on Python 3.11 -- by :user:`adamchainz`
8 changes: 6 additions & 2 deletions src/tox/action.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import, unicode_literals

import os
import pipes
import signal
import subprocess
import sys
Expand All @@ -18,6 +17,11 @@
from tox.util.lock import get_unique_file
from tox.util.stdlib import is_main_thread

if sys.version_info >= (3, 3):
from shlex import quote as shlex_quote
else:
from pipes import quote as shlex_quote


class Action(object):
"""Action is an effort to group operations with the same goal (within reporting)"""
Expand Down Expand Up @@ -89,7 +93,7 @@ def popen(
"""this drives an interaction with a subprocess"""
cwd = py.path.local() if cwd is None else cwd
cmd_args = [str(x) for x in self._rewrite_args(cwd, args)]
cmd_args_shell = " ".join(pipes.quote(i) for i in cmd_args)
cmd_args_shell = " ".join(shlex_quote(i) for i in cmd_args)
stream_getter = self._get_standard_streams(
capture_err,
cmd_args_shell,
Expand Down
4 changes: 2 additions & 2 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
from .parallel import add_parallel_config, add_parallel_flags
from .reporter import add_verbosity_commands

try:
if sys.version_info >= (3, 3):
from shlex import quote as shlex_quote
except ImportError:
else:
from pipes import quote as shlex_quote


Expand Down
9 changes: 7 additions & 2 deletions src/tox/exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import os
import pipes
import signal
import sys

if sys.version_info >= (3, 3):
from shlex import quote as shlex_quote
else:
from pipes import quote as shlex_quote


def exit_code_str(exception_name, command, exit_code):
Expand Down Expand Up @@ -96,7 +101,7 @@ def __init__(self, config):
self.config = config

def __str__(self):
return " ".join(pipes.quote(i) for i in self.config.requires)
return " ".join(shlex_quote(i) for i in self.config.requires)


class BadRequirement(Error):
Expand Down
10 changes: 7 additions & 3 deletions src/tox/venv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import codecs
import json
import os
import pipes
import re
import sys
from itertools import chain
Expand All @@ -19,6 +18,11 @@

from .config import DepConfig

if sys.version_info >= (3, 3):
from shlex import quote as shlex_quote
else:
from pipes import quote as shlex_quote

#: maximum parsed shebang interpreter length (see: prepend_shebang_interpreter)
MAXINTERP = 2048

Expand Down Expand Up @@ -194,7 +198,7 @@ def getcommandpath(self, name, venv=True, cwd=None):

if path is None:
raise tox.exception.InvocationError(
"could not find executable {}".format(pipes.quote(name)),
"could not find executable {}".format(shlex_quote(name)),
)

return str(path) # will not be rewritten for reporting
Expand Down Expand Up @@ -534,7 +538,7 @@ def test(
# happens if the same environment is invoked twice
message = "commands[{}] | {}".format(
i,
" ".join(pipes.quote(str(x)) for x in argv),
" ".join(shlex_quote(str(x)) for x in argv),
)
action.setactivity(name, message)
# check to see if we need to ignore the return code
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/session/test_session.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import pipes
import sys
import textwrap
from threading import Thread
Expand All @@ -11,6 +10,11 @@
from tox.package import resolve_package
from tox.reporter import Verbosity

if sys.version_info >= (3, 3):
from shlex import quote as shlex_quote
else:
from pipes import quote as shlex_quote


def test_resolve_pkg_missing_directory(tmpdir, mocksession):
distshare = tmpdir.join("distshare")
Expand Down Expand Up @@ -355,7 +359,7 @@ def test_command_prev_fail_command_skip_post_run(cmd, initproj, mock_venv):
___________________________________ summary ___________________________________{}
ERROR: py: commands failed
""".format(
pipes.quote(sys.executable),
shlex_quote(sys.executable),
"_" if sys.platform != "win32" else "",
),
)
Expand Down