summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMassimiliano Minella <massimiliano.minella@se.com>2026-05-04 11:31:31 +0200
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-05-11 20:15:08 +0000
commitfb1d9123351c86d7804e78e1518788913fb7c672 (patch)
treee812234305241713cd7e76487bf205b75309210b
parentf7eb4abba27a54c06432cca45f817f21f5754532 (diff)
downloadmeta-virtualization-fb1d9123351c86d7804e78e1518788913fb7c672.tar.gz
libvirt: fix python3 compatibility in hook_support.py
By default Popen expects all the streams to be bytes-like objects but, in the Popen.communicate() function call, the "input" argument is a string, making the call fail with the error: qemu hook error: a bytes-like object is required, not 'str' Fix the error by setting text mode to True in the subprocess creation. Also fix the "SyntaxWarning: invalid escape sequence '\w'" in the regex used to match script names. Signed-off-by: Massimiliano Minella <massimiliano.minella@se.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rwxr-xr-xrecipes-extended/libvirt/libvirt/hook_support.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/recipes-extended/libvirt/libvirt/hook_support.py b/recipes-extended/libvirt/libvirt/hook_support.py
index 7c5e2a94..63e78b79 100755
--- a/recipes-extended/libvirt/libvirt/hook_support.py
+++ b/recipes-extended/libvirt/libvirt/hook_support.py
@@ -35,7 +35,7 @@ def main():
35 stdin_save = sys.stdin.readlines() 35 stdin_save = sys.stdin.readlines()
36 # Match the name name of the hook + a dash + atleast 36 # Match the name name of the hook + a dash + atleast
37 # one alpha-numeric character. 37 # one alpha-numeric character.
38 matcher = re.compile( "%s-\w+" % hook_name ) 38 matcher = re.compile( rf"%s-\w+" % hook_name )
39 for file_name in sorted( os.listdir( hook_dir ) ): 39 for file_name in sorted( os.listdir( hook_dir ) ):
40 file_path = os.path.join( hook_dir, file_name ) 40 file_path = os.path.join( hook_dir, file_name )
41 if matcher.match( file_name ) \ 41 if matcher.match( file_name ) \
@@ -43,7 +43,7 @@ def main():
43 and os.path.isfile( file_path ) \ 43 and os.path.isfile( file_path ) \
44 and return_value == 0: 44 and return_value == 0:
45 cmd = [ file_path ] + hook_args 45 cmd = [ file_path ] + hook_args
46 p = subprocess.Popen( cmd, stdin=subprocess.PIPE ) 46 p = subprocess.Popen( cmd, stdin=subprocess.PIPE, text=True )
47 p.communicate( input = ''.join( stdin_save ) )[0] 47 p.communicate( input = ''.join( stdin_save ) )[0]
48 return_value = p.wait() 48 return_value = p.wait()
49 except Exception as e: 49 except Exception as e: