ソースを参照

Use shlex instead of pipes

Importing pipes gets a DeprecationWarning. shlex.quote is equivalent to
pipes.quote. Use that instead.

Bug: 1522874
Change-Id: I18b8598f2e961d58ba71d886921bda9d9ad956ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5243707
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Auto-Submit: Gavin Mak <gavinmak@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Gavin Mak 1 年間 前
コミット
b808b1bcdd
2 ファイル変更5 行追加5 行削除
  1. 3 3
      fetch.py
  2. 2 2
      gclient_utils.py

+ 3 - 3
fetch.py

@@ -20,7 +20,7 @@ These parameters will be passed through to the config's main method.
 import json
 import argparse
 import os
-import pipes
+import shlex
 import subprocess
 import sys
 
@@ -57,7 +57,7 @@ class Checkout(object):
         pass
 
     def run(self, cmd, return_stdout=False, **kwargs):
-        print('Running: %s' % (' '.join(pipes.quote(x) for x in cmd)))
+        print('Running: %s' % (' '.join(shlex.quote(x) for x in cmd)))
         if self.options.dry_run:
             return ''
         if return_stdout:
@@ -98,7 +98,7 @@ class GclientCheckout(Checkout):
 
 class GitCheckout(Checkout):
     def run_git(self, *cmd, **kwargs):
-        print('Running: git %s' % (' '.join(pipes.quote(x) for x in cmd)))
+        print('Running: git %s' % (' '.join(shlex.quote(x) for x in cmd)))
         if self.options.dry_run:
             return ''
         return git_common.run(*cmd, **kwargs)

+ 2 - 2
gclient_utils.py

@@ -13,10 +13,10 @@ import io
 import logging
 import operator
 import os
-import pipes
 import platform
 import queue
 import re
+import shlex
 import stat
 import subprocess
 import sys
@@ -369,7 +369,7 @@ def safe_makedirs(tree):
 
 def CommandToStr(args):
     """Converts an arg list into a shell escaped string."""
-    return ' '.join(pipes.quote(arg) for arg in args)
+    return ' '.join(shlex.quote(arg) for arg in args)
 
 
 class Wrapper(object):