PICARD-1867: Handle errors in guess_format

This commit is contained in:
Philipp Wolfer
2020-07-03 15:49:08 +02:00
parent 5586f17a4f
commit 656ac2d097

View File

@@ -183,7 +183,12 @@ class File(QtCore.QObject, Item):
# If loading failed, force format guessing and try loading again
from picard.formats.util import guess_format
alternative_file = guess_format(self.base_filename)
try:
alternative_file = guess_format(self.filename)
except (FileNotFoundError, OSError):
log.error("Guessing format of %s failed", self.filename, exc_info=True)
alternative_file = None
if alternative_file:
# Do not retry reloading exactly the same file format
if type(alternative_file) != type(self): # pylint: disable=unidiomatic-typecheck