Skip to contentSkip to conversation

patch.py: Use shlex instead of deprecated pipe

PATCH New Ola x Nilsson 1 participant 2 messages Apr 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 patch.py: Use shlex instead of deprecated pipe

The pipe library is deprecated in Python 3.11 and will be removed in Python 3.13. pipe.quote is just an import of shlex.quote anyway.

Clean up imports while we're at it.

---
 meta/lib/oe/patch.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
meta/lib/oe/patch.py +5 -6
index d047b3b947..5990896fdc 100644
@@ -4,9 +4,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
+import os
+import shlex
+import subprocess
 import oe.path
 import oe.types
-import subprocess
 
 class NotFoundError(bb.BBHandledException):
     def __init__(self, path):
@@ -27,8 +29,6 @@ class CmdError(bb.BBHandledException):
 
 
 def runcmd(args, dir = None):
-    import pipes
-
     if dir:
         olddir = os.path.abspath(os.curdir)
         if not os.path.exists(dir):
@@ -37,7 +37,7 @@ def runcmd(args, dir = None):
         # print("cwd: %s -> %s" % (olddir, dir))
 
     try:
-        args = [ pipes.quote(str(arg)) for arg in args ]
+        args = [ shlex.quote(str(arg)) for arg in args ]
         cmd = " ".join(args)
         # print("cmd: %s" % cmd)
         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -217,7 +217,7 @@ class PatchTree(PatchSet):
         with open(self.seriespath, 'w') as f:
             for p in patches:
                 f.write(p)
-         
+
     def Import(self, patch, force = None):
         """"""
         PatchSet.Import(self, patch, force)
@@ -952,4 +952,3 @@ def should_apply(parm, d):
             return False, "applies to later version"
 
     return True, None
-
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 package: Use shlex instead of deprecated pipe

The pipe library is deprecated in Python 3.11 and will be removed in Python 3.13. pipe.quote is just an import of shlex.quote anyway.

---
 meta/lib/oe/package.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
meta/lib/oe/package.py +3 -4
index 7a6b31957a..edb70daaf1 100644
@@ -8,7 +8,7 @@ import errno
 import fnmatch
 import itertools
 import os
-import pipes
+import shlex
 import re
 import glob
 import stat
@@ -41,7 +41,7 @@ def runstrip(arg):
 
     stripcmd = [strip]
     skip_strip = False
-    # kernel module    
+    # kernel module
     if elftype & 16:
         if is_kernel_module_signed(file):
             bb.debug(1, "Skip strip on signed module %s" % file)
@@ -1556,7 +1556,7 @@ def process_shlibs(pkgfiles, d):
         sonames = set()
         renames = []
         ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '')
-        cmd = d.getVar('OBJDUMP') + " -p " + pipes.quote(file) + " 2>/dev/null"
+        cmd = d.getVar('OBJDUMP') + " -p " + shlex.quote(file) + " 2>/dev/null"
         fd = os.popen(cmd)
         lines = fd.readlines()
         fd.close()
@@ -2012,4 +2012,3 @@ def process_depchains(pkgfiles, d):
                 for dep in bb.utils.explode_deps(d.getVar('RDEPENDS:' + base) or ""):
                     add_dep(rdeps, dep)
                 pkg_addrrecs(pkg, base, suffix, func, rdeps, d)
-
Signature · 1 line
2.39.2