-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
On Python 3.3+, replace pipes.quote with shlex.quote #342
Conversation
The pipes.quote() function was undocumented, and the pipes module was deprecated in Python 3.11 and will be removed in Python 3.13. Fixes ekalinin#341.
I would suggest to switch to |
It was pointed out that pyupgrade can handle this better than try/except.
That’s an interesting point. I tested it to be sure. With try:
from shlex import quote as _quote # Python 3.3+
except ImportError:
- from pipes import quote as _quote # Python 2.7
+ from shlex import quote as _quote # Python 2.7
import platform which should point out the need remove the If I switch to: if sys.version_info < (3, 3):
from pipes import quote as _quote
else:
from shlex import quote as _quote I get: import argparse
import subprocess
import tarfile
-if sys.version_info < (3, 3):
- from pipes import quote as _quote
-else:
- from shlex import quote as _quote
+from shlex import quote as _quote
import platform
import zipfile
import shutil A human reviewer might still choose to change this back to I did notice that if I slice If Anyway, it seems like this basically supports your suggestion. I’ve added a commit to switch to an |
ruff's |
The checks are broken due to #347, this PR is not the culprit. |
Thanks! |
The
pipes.quote()
function was undocumented, and the pipes module was deprecated in Python 3.11 and will be removed in Python 3.13.Fixes #341.
This is a one-to-one replacement of
pipes.quote
withshlex.quote
; I did not attempt to audit the shell escaping for correctness and safety.