Skip to content
Snippets Groups Projects
Commit c24d8269 authored by Mathieu Bridon's avatar Mathieu Bridon Committed by Eric Engestrom
Browse files

python: Open file in binary mode


The XML parser wants byte strings, not unicode strings.

In both Python 2 and 3, opening a file without specifying the mode will
open it for reading in text mode ('r').

On Python 2, the read() method of the file object will return byte
strings, while on Python 3 it will return unicode strings.

Explicitly specifying the binary mode ('rb') makes the behaviour
identical in both Python 2 and 3, returning what the XML parser
expects.

Signed-off-by: default avatarMathieu Bridon <bochecha@daitauha.fr>
Reviewed-by: default avatarEric Engestrom <eric.engestrom@intel.com>
Reviewed-by: default avatarDylan Baker <dylan@pnwbakers.com>
parent e40200e0
No related branches found
Tags mesa-18.1.0-rc3
No related merge requests found
......@@ -282,7 +282,7 @@ class XmlParser(object):
self.container = None
def parse(self, filename):
with open(filename) as f:
with open(filename, 'rb') as f:
self.parser.ParseFile(f)
def start_element(self, name, attrs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment