From 3025e68d1f63489504db1466456616c09f14f7ca Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 29 Jan 2024 00:01:04 +0100 Subject: [PATCH] Handle exceptions if ~filesize is not numeric --- picard/file.py | 5 ++++- picard/ui/infodialog.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/picard/file.py b/picard/file.py index 101a3b003..857ee99f7 100644 --- a/picard/file.py +++ b/picard/file.py @@ -826,7 +826,10 @@ class File(QtCore.QObject, Item): if not value and not get_config().setting['clear_existing_tags']: value = self.orig_metadata[column] if column == '~filesize': - value = bytes2human.binary(value) + try: + value = bytes2human.binary(value) + except ValueError: + pass return value def _lookup_finished(self, lookuptype, document, http, error): diff --git a/picard/ui/infodialog.py b/picard/ui/infodialog.py index c58c7487b..6d34cf1cc 100644 --- a/picard/ui/infodialog.py +++ b/picard/ui/infodialog.py @@ -287,7 +287,10 @@ def format_file_info(file_): info.append((_("Format:"), file_.orig_metadata['~format'])) if '~filesize' in file_.orig_metadata: size = file_.orig_metadata['~filesize'] - sizestr = "%s (%s)" % (bytes2human.decimal(size), bytes2human.binary(size)) + try: + sizestr = "%s (%s)" % (bytes2human.decimal(size), bytes2human.binary(size)) + except ValueError: + sizestr = _("unknown") info.append((_("Size:"), sizestr)) if file_.orig_metadata.length: info.append((_("Length:"), format_time(file_.orig_metadata.length)))