Skip to content

Use binary mode buffer for stdout

By default, sys.stdout is in text mode, expecting a str rather than byte. This fails with,

Traceback (most recent call last):
  File "/usr/bin/g-ir-scanner", line 99, in <module>
    sys.exit(scanner_main(sys.argv))
  File "/usr/lib64/gobject-introspection/giscanner/scannermain.py", line 635, in scanner_main
    write_output(data, options)
  File "/usr/lib64/gobject-introspection/giscanner/scannermain.py", line 476, in write_output
    output.write(data)
TypeError: write() argument must be str, not bytes

Change the output destination to the underlying binary buffer to write bytes.

Ref: https://docs.python.org/3/library/sys.html#sys.stdout

Merge request reports