From 9d0007a369deb4a6346f5ab7a9e6d432a8ed14fe Mon Sep 17 00:00:00 2001 From: Massimiliano Minella Date: Wed, 3 Jun 2026 18:36:18 +0200 Subject: 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 Signed-off-by: Bruce Ashfield (cherry picked from commit fb1d9123351c86d7804e78e1518788913fb7c672) --- recipes-extended/libvirt/libvirt/hook_support.py | 4 ++-- 1 file 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(): stdin_save = sys.stdin.readlines() # Match the name name of the hook + a dash + atleast # one alpha-numeric character. - matcher = re.compile( "%s-\w+" % hook_name ) + matcher = re.compile( rf"%s-\w+" % hook_name ) for file_name in sorted( os.listdir( hook_dir ) ): file_path = os.path.join( hook_dir, file_name ) if matcher.match( file_name ) \ @@ -43,7 +43,7 @@ def main(): and os.path.isfile( file_path ) \ and return_value == 0: cmd = [ file_path ] + hook_args - p = subprocess.Popen( cmd, stdin=subprocess.PIPE ) + p = subprocess.Popen( cmd, stdin=subprocess.PIPE, text=True ) p.communicate( input = ''.join( stdin_save ) )[0] return_value = p.wait() except Exception as e: -- cgit v1.2.3-54-g00ecf