Skip to content

Python 3: Replace io.StringIO with io.BytesIO

The ligolw_utils.write_fileobj(xmldoc, message) function in postcoh_finalsink.py seems to want to write binary data to the message variable.

When we instantiate message = StringIO() we receive an error message when writing coinc.xml files that state "TypeError: string argument expected, got bytes":

image

We expect this error had not been found before as the gstreamer_python_upgrade branch hasn't been run to produce coinc.xml files on output.

After changing message to be defined as message = BytesIO with from io import BytesIO, we find the pipeline runs with success and a H1L1V1_1187008882_3_806.xml file is created (albeit with some warnings, of course).

image

Debug Patch

Note that we force this trigger to be written by changing the science requirements to pass the threshold for writing coinc.xml files.

In particular, we change:

  • Line 567:
    def __pass_test(self, candidate):
+       if self.candidate.cohsnr > 12:
+           return True
  • Line 833:
# __need_trigger_control
    - if ((abs(float(trigger.end) - last_time) < 50
    + if ((abs(float(trigger.end) - last_time) < 50 and last_far > 0

These changes are not committed to git.

Merge request reports