Open metadata in binary mode for Python 3 compatibility.
Python 3 handles character data read from a file differently than Python 2 does. Python 3 opens files in text mode by default, causing file reads to return string data decoded from file using encoding specified as argument of open() builtin function. If encoding is not specified, open() uses some default encoding that can even be ASCII. Hence, using open() in text mode without specifying encoding is dangerous in Python 3 and can lead to unexpected results. However, it's safe to open metadata in binary mode, it gets encoded to UTF-8 later anyway. Signed-off-by: Oleg Girko <ol@infoserver.lv>
This commit is contained in:
@@ -589,7 +589,7 @@ class MetaDataFile(InMemoryMetaData):
|
||||
self.cert = cert
|
||||
|
||||
def get_metadata_content(self):
|
||||
return open(self.filename).read()
|
||||
return open(self.filename, 'rb').read()
|
||||
|
||||
def load(self):
|
||||
_txt = self.get_metadata_content()
|
||||
|
Reference in New Issue
Block a user