diff mbox series

[XTF] xtf-runner: python3 fix

Message ID 20230817105111.4413-1-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series [XTF] xtf-runner: python3 fix | expand

Commit Message

Anthony PERARD Aug. 17, 2023, 10:51 a.m. UTC
issue:
  File "/home/xtf/xtf-runner", line 410, in interpret_selection
    if not line.startswith("xen_caps"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Adding `universal_newlines` open stdout as text file, so line should
be a `str`. `universal_newlines` is available on python 2.7. A new
alias `text` is only available in python 3.7.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    I've only tested the patch on Debian Bookworm, with python-is-python3
    package (python symlink) as osstest run `./xtf-runner ...`.
    
    I haven't tried python2.7.

 xtf-runner | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Cooper Aug. 18, 2023, 7:50 p.m. UTC | #1
On 17/08/2023 11:51 am, Anthony PERARD wrote:
> issue:
>   File "/home/xtf/xtf-runner", line 410, in interpret_selection
>     if not line.startswith("xen_caps"):
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> TypeError: startswith first arg must be bytes or a tuple of bytes, not str
>
> Adding `universal_newlines` open stdout as text file, so line should
> be a `str`. `universal_newlines` is available on python 2.7. A new
> alias `text` is only available in python 3.7.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
>
> Notes:
>     I've only tested the patch on Debian Bookworm, with python-is-python3
>     package (python symlink) as osstest run `./xtf-runner ...`.
>     
>     I haven't tried python2.7.

Seems to work on Py2.7.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> and pushed.  Thanks.
diff mbox series

Patch

diff --git a/xtf-runner b/xtf-runner
index 6352a5b..5741e64 100755
--- a/xtf-runner
+++ b/xtf-runner
@@ -403,7 +403,7 @@  def interpret_selection(opts):
 
         host_envs = []
 
-        cmd = Popen(['xl', 'info'], stdout = PIPE)
+        cmd = Popen(['xl', 'info'], stdout = PIPE, universal_newlines=True)
         stdout, _ = cmd.communicate()
 
         for line in stdout.splitlines():