Pass a bytestring to xml.sax.parseString

This fixes the ctest prb.

CI was broken because TestRunner errored at:

    Traceback (most recent call last):
      File "/foundationdb/tests/TestRunner/TestRunner.py", line 373, in <module>
        res = run_simulation_test(basedir, args)
      File "/foundationdb/tests/TestRunner/TestRunner.py", line 313, in run_simulation_test
        options.log_format, return_codes)
      File "/foundationdb/tests/TestRunner/TestRunner.py", line 261, in process_traces
        parser.processTraces()
      File "/foundationdb/tests/TestRunner/TestRunner.py", line 112, in processTraces
        obj = self.processLine(line, linenr)
      File "/foundationdb/tests/TestRunner/TestRunner.py", line 222, in processLine
        xml.sax.parseString(line, handler, errorHandler=errorHandler)
      File "/usr/lib/python3.4/xml/sax/__init__.py", line 45, in parseString
        inpsrc.setByteStream(BytesIO(string))
    TypeError: 'str' does not support the buffer interface

Which means you can't parse a string to parseString.  This was fixed by
3.7, but our CI runs 3.4, so we need to .encode() `line` before passing
it, so that it ends up as a `bytes`.
This commit is contained in:
Alex Miller 2019-02-11 17:12:49 -08:00 committed by Alex Miller
parent 1d12618f7d
commit 2d7f5f505c
1 changed files with 1 additions and 1 deletions

View File

@ -219,7 +219,7 @@ class XMLParser(LogParser):
return None
handler = XMLParser.XMLHandler()
errorHandler = XMLParser.XMLErrorHandler()
xml.sax.parseString(line, handler, errorHandler=errorHandler)
xml.sax.parseString(line.encode('utf-8'), handler, errorHandler=errorHandler)
if len(errorHandler.fatalErrors) > 0:
return self.log_trace_parse_error(linenr, errorHandler.fatalErrors[0])
return handler.result