#735 Fix encoding issue in runroot with python3
Closed 6 years ago by mikem. Opened 6 years ago by puiterwijk.
puiterwijk/koji py3-runroot-encoding  into  master

file modified
+1 -1
@@ -90,7 +90,7 @@ 

      if 'runroot.log' in output:

          for volume in output['runroot.log']:

              log = session.downloadTaskOutput(task_id, 'runroot.log', volume=volume)

-             sys.stdout.write(log)

+             sys.stdout.write(log.decode('utf8'))

      info = session.getTaskInfo(task_id)

      if info is None:

          sys.exit(1)

This will make sure that the log from the server is correctly decoded, since
sys.stdout only accepts strings, not raw bytes, which is what downloadTaskOutput
returns.

Signed-off-by: Patrick Uiterwijk patrick@puiterwijk.org

I have tested this on both py2 and py3, and it works as expected and fixes the following output with py3 koji runroot:

23558770
TypeError: write() argument must be str, not bytes

comment so I can follow status of this PR

I'm not sure this is quite correct in the py2 case.

I was about to suggest using _fix_print(), but I think this runroot output is a special case.

The runroot.log output is generated by an arbitrary command in a buildroot. It could be anything. The intent of the runroot command output is to be a direct pass through, so we could like to avoid any translation of the output if we can help it. We basically just want to cat this file.

I wonder if we should has do something like:

    if six.PY3:
        sys.stdout.buffer.write(log)
    else: ...

merged #828, closing this one

Pull-Request has been closed by mikem

6 years ago
Metadata